// JavaScript Document

function show_image(object_id,image_name,width,height)
{
x_pos=event.screenX+document.body.scrollLeft;
y_pos=event.screenY+document.body.scrollTop;
image_div.style.left=x_pos+10;
image_div.style.top=y_pos+10-height;
image_div.style.visibility='visible';
image_div.innerHTML="<img src='"+image_name+"' width="+width+" height="+height+" class=empty_border>";
}
function hide_image()
{
image_div.style.visibility='hidden';
image_div.innerHTML="";
}

function image_preview(file_name,width,height)
{
window.open("image_preview.php?file_name="+file_name+"&width="+width+"&height="+height,"img_preview","width="+width+",height="+height+",top=100,left=250,scrollbars=no,resizable=yes");
}


function video_preview(file_name)
{
window.open("video_preview.php?file_name="+file_name,"vid_preview","width=400,height=300,top=100,left=250,scrollbars=no,resizable=yes");
}

function delete_module_category(module,id)
{
	return_confirm=confirm("Are you sure that you want to delete this category?");
	if(return_confirm==true)
	window.location="module_configuration.php?module="+module+"&id="+id+"&delete_category=1";
}



function confirm_delete()
{
	return_confirm=confirm("Are you sure that you want to delete these data?");
	if(return_confirm==true)
	{
		frm.trash.value=1;
		frm.submit();
	}
}

function confirm_item_delete(path)
{
	return_confirm=confirm("Are you sure that you want to delete this data?");
	if(return_confirm==true)
	{
		if(path!='')
		{
			window.location=path;
		}
	}
}


function open_pdf_page(id,module)
{
window.open("pdf_page.php?id="+id+"&module="+module,"pdf","width=50,height=50,scrollbars=no,resizable=no");
}

function open_email_page(id,module)
{
window.open("send_email.php?id="+id+"&module="+module,"email","width=600,height=600,top=100,left=350,scrollbars=yes,resizable=yes");
}

function open_print_page(id,module)
{
window.open("print_page.php?id="+id+"&module="+module,"print","width=600,height=600,top=100,left=350,scrollbars=yes,resizable=yes");
}


function data_preview(id,module)
{
window.open("data_preview.php?id="+id+"&module="+module,"preview","width=600,height=600,top=100,left=350,scrollbars=yes,resizable=yes");
}


function create_uploads(loop)
{
if(loop<=0)
frm.upload_num.value=1;
else
frm.upload_num.value=loop;

if(loop>0)
{
i=0;
upload_contents="";
upload_contents=upload_contents+"<table width=85% border=0  cellpadding=2 cellspacing=2 align=center>";
for(i=0;i<loop;i++)
{
upload_contents=upload_contents+"<tr><td align=center><table width=100% border=0 cellpadding=0 cellspacing=0 align=center>";
upload_contents=upload_contents+"<tr><td width=25% class=normal_text align=left>File: "+(i+1)+" </td><td align=left><input name=file_"+i+" type=file size=40></td></tr>";
upload_contents=upload_contents+"</table></td></tr>";
}
upload_contents=upload_contents+"</table>";
uploads.innerHTML=upload_contents;
}
}



function CreateControl(DivID, CLSID, ObjectID, WIDTH, HEIGHT, URL)
{
  var d = document.getElementById(DivID);
  contents="";
  contents=contents+"<object classid='"+CLSID+"' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' id='"+ObjectID+"' width='"+WIDTH+"' height='"+HEIGHT+"'>";
  contents=contents+"<param name='allowScriptAccess' value='sameDomain' />";
  contents=contents+"<param name='movie' value='"+URL+"' />";
  contents=contents+"<param name='loop' value='false' />";
  contents=contents+"<param name='menu' value='false' />";
  contents=contents+"<param name='quality' value='high' />";
  contents=contents+"<param name='wmode' value='transparent' />";
  contents=contents+"<param name='bgcolor' value='#ffffff' />";
  contents=contents+"<embed src='"+URL+"' loop='false' menu='false' quality='high' wmode='transparent' bgcolor='#ffffff'  width='"+WIDTH+"' height='"+HEIGHT+"' name='"+ObjectID+"' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
  contents=contents+"</object>";
      
  d.innerHTML =contents;
}



function open_calendar_window(target)
{
window.open("calendar_popup.php?module=calendar&target="+target,"calendar","width=175,height=160,top=200,left=560,scrollbars=no");
}

function get_date(target,date)
{

split_date="";
split_date=date.split("-");
document.getElementById(target).value=split_date[1]+"-"+split_date[2]+"-"+split_date[0];
}


function create_uploads(loop,file_txt)
{
if(loop<=0)
frm.upload_num.value=1;
else
frm.upload_num.value=loop;

if(loop>0)
{
i=0;
upload_contents="";
upload_contents=upload_contents+"<table width=85% border=0  cellpadding=2 cellspacing=2>";
for(i=0;i<loop;i++)
{
upload_contents=upload_contents+"<tr><td align=center><table width=100% border=0 cellpadding=0 cellspacing=0 align=center>";
upload_contents=upload_contents+"<tr><td width=25% class=normal_text>"+file_txt+" "+(i+1)+" :</td><td><input name=file_"+i+" type=file size=40></td></tr>";
upload_contents=upload_contents+"</table></td></tr>";
}
upload_contents=upload_contents+"</table>";
uploads.innerHTML=upload_contents;
}
}

function create_catalog_uploads(loop,file_txt)
{
if(loop<=0)
frm.upload_num.value=1;
else
frm.upload_num.value=loop;

if(loop>0)
{
i=0;
upload_contents="";
upload_contents=upload_contents+"<table width=85% border=0  cellpadding=2 cellspacing=2>";
for(i=0;i<loop;i++)
{
upload_contents=upload_contents+"<tr><td align=center><table width=100% border=0 cellpadding=0 cellspacing=0 align=center>";
upload_contents=upload_contents+"<tr><td width=25% class=normal_text>File Title "+(i+1)+" :</td><td><input name=title_"+i+" type=text size=40> </td></tr>";
upload_contents=upload_contents+"<tr><td width=25% class=normal_text>"+file_txt+" "+(i+1)+" :</td><td><input name=file_"+i+" type=file size=40> </td></tr>";
upload_contents=upload_contents+"<tr><td width=25% class=normal_text>File Type:</td><td class=normal_text>Manual <input name=type_"+i+" type=radio value='manual'>&nbsp;&nbsp;Certificate <input name=type_"+i+" type=radio value='certificate'></td></tr>";
upload_contents=upload_contents+"</table></td></tr>";
}
upload_contents=upload_contents+"</table>";
uploads.innerHTML=upload_contents;
}
}

function generate_item_info(loop)
{
if(loop<=0)
frm.upload_num.value=1;
else
frm.upload_num.value=loop;

if(loop>0)
{
	var i=0;
	var class_css="";
	var upload_contents="";
	upload_contents=upload_contents+"<table border=0  width=90% cellpadding=1 cellspacing=3 align=center>";
	
	upload_contents=upload_contents+"<tr class=cell3 height=30>";
	upload_contents=upload_contents+"<td class=normal_text><span>#</td>";
	upload_contents=upload_contents+"<td class=normal_text><span>Data Order</td>";
	upload_contents=upload_contents+"<td class=normal_text><span>Item Number</td>";
	upload_contents=upload_contents+"<td class=normal_text>Size</td>";
	upload_contents=upload_contents+"<td class=normal_text>Standard</td>";
	upload_contents=upload_contents+"</tr>";

	for(i=0;i<loop;i++)
	{
		var m=i+1;
		if(i%2==0)
		class_css="cell1";
		else
		class_css="cell2";
		upload_contents=upload_contents+"<tr class='"+class_css+"'>";
		
		upload_contents=upload_contents+"<td class=normal_text><b>"+m+"</b></td>";
		upload_contents=upload_contents+"<td class=normal_text><input name=data_order_"+i+" type=text size=10></td>";
		upload_contents=upload_contents+"<td class=normal_text><input name=item_no_"+i+" type=text size=20></td>";
		upload_contents=upload_contents+"<td class=normal_text><input name=size_"+i+" type=text size=10></td>";
		upload_contents=upload_contents+"<td class=normal_text><input name=standard_"+i+" type=text size=10></td>";
		upload_contents=upload_contents+"</tr>";
	}
		
	upload_contents=upload_contents+"<tr class=cell3>";
	upload_contents=upload_contents+"<td class=normal_text colspan=5 align=center><input type='submit' value=' Add / Update' name='info'  style='background-color:#455C8E;color:#FFFFFF'></td>";
	upload_contents=upload_contents+"</tr>";

	upload_contents=upload_contents+"</table>";
	uploads.innerHTML=upload_contents;
}
}
