// JavaScript Document
function open_calendar_window(mode)
{
	window.open("includes/calendar_popup.php?mode="+mode,"calendar","width=240,height=210,top=200,left=560,scrollbars=no");
}

function open_emails_list_window()
{
	window.open("emails_list.php","emails_list","width=390,height=495,top=100,left=250,scrollbars=no");
}

function get_emails_list(data)
{
	frm.to_emails.value=frm.to_emails.value+data;
}

function get_date(date_feild,date)
{
	split_date="";
	split_date=date.split("-");
	document.getElementById(date_feild).value=split_date[0]+"-"+split_date[1]+"-"+split_date[2];
}


function showhide(id){ 
if (document.getElementById)
   { 
		obj = document.getElementById(id); 
		if (obj.style.display == "none")
		{ 
			obj.style.display = ""; 
			return 'images/minus_menu.gif';
		} 
		else 
		{ 
			obj.style.display = "none"; 
			return './images/plus_menu.gif';
		} 
	} 
}

function show_hide_menu(link_id,menu_id)
{ 
	offset_left=calculateSumOffset(link_id,'offsetLeft');
	offset_top=calculateSumOffset(link_id,'offsetTop');
	if (menu_id.style.visibility == "hidden")
	 { 
		menu_id.style.left=offset_left;
		menu_id.style.top= offset_top+parseInt(link_id.height);
		menu_id.style.visibility = "visible";
	 } 
	else 
	 { 
		menu_id.style.visibility = "hidden";
	 } 
}

function calculateSumOffset(idItem, offsetName)
{
	var totalOffset = 0;
	var item = eval('idItem');
	do
	{
		totalOffset += eval('item.'+offsetName);
		item = eval('item.offsetParent');
	} while (item != null);
	return totalOffset;
}

function generate_upload(loop)
{
	frm.upload_num.value=loop<=0?1:loop;
	i=0;
	upload_contents="";
	upload_contents=upload_contents+"<table width=100% border=0  cellpadding=0 cellspacing=0 >";
	for(i=0;i<frm.upload_num.value;i++)
	{
		upload_contents=upload_contents+"<tr><td><table width=100% border=0 cellpadding=0 cellspacing=0><tr> ";
		upload_contents=upload_contents+"<td width=10% class=normal_text>image "+(i+1)+" </td><td><input name=image_"+i+" type=file size=33></td></tr></table></td></tr>";
	}
	upload_contents=upload_contents+"</table>";
	uploads.innerHTML=upload_contents;
}

function generate_document_upload(loop)
{
	frm.upload_num.value=loop<=0?1:loop;
	i=0;
	upload_contents="";
	upload_contents=upload_contents+"<table width=100% border=0  cellpadding=0 cellspacing=0 >";
	for(i=0;i<frm.upload_num.value;i++)
	{
		upload_contents=upload_contents+"<tr><td><table width=100% border=0 cellpadding=0 cellspacing=0><tr> ";
		upload_contents=upload_contents+"<td width=12% class=normal_text>document "+(i+1)+" </td><td><input name=document_"+i+" type=file size=33></td></tr></table></td></tr>";
	}
	upload_contents=upload_contents+"</table>";
	uploads.innerHTML=upload_contents;
}

function image_preview(image_name,width,height)
{
	width=width>300? width: 300;
	height=height>200? height: 200;
	window.open("image_preview.php?image_name="+image_name,"img_preview","width="+width+",height="+(height+50)+",top=100,left=250,scrollbars=yes,resize=yes");
}

function video_preview(video_name)
{
	window.open("video_preview.php?video_name="+video_name,"video_preview","width=475,height=350,top=100,left=250,scrollbars=yes;resize=yes");
}

function insert_date(field_name,d)
{
	split_date="";
	split_date=d.split("-");
	document.getElementById(field_name).value=split_date[0]+"-"+split_date[1]+"-"+split_date[2];
}
