// JavaScript Document
function open_calendar_window(mode)
{
	window.open("includes/calendar_popup.php?mode="+mode,"calendar","width=125,height=175,top=200,left=560,scrollbars=no");
}

function image_preview(file_name)
{
	window.open("image_preview.php?file_name="+file_name,"img_preview","width=500,height=410,top=100,left=250,scrollbars=yes;resize=yes");
}

function video_preview(file_name)
{
	window.open("video_preview.php?file_name="+file_name,"vid_preview","width=500,height=380,top=100,left=250,scrollbars=yes;resize=yes");
}

function open_emails_list_window()
{
	window.open("emails_list.php","emails_list","width=390,height=500,top=25,left=250,scrollbars=yes");
}

function get_emails_list(data)
{
	frm.to_emails.value=frm.to_emails.value+data;
}

function end_date(d)
{
	split_date="";
	split_date=d.split("-");
	
	frm.end_date.value=split_date[0]+"-"+split_date[1]+"-"+split_date[2];
}

function generate_upload(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=100% border=0  cellpadding=0 cellspacing=0 >";
	for(i=0;i<loop;i++)
	{
	upload_contents=upload_contents+"<tr><td><table width=100% border=0 cellpadding=0 cellspacing=0><tr> ";
	upload_contents=upload_contents+"<td><input name=image"+i+" type=file size=55></td></tr></table></td></tr>";
	}
	upload_contents=upload_contents+"</table>";
	uploads.innerHTML=upload_contents;
	}
}

function generate_slideshow(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=100% border=0  cellpadding=0 cellspacing=0 >";
		for(i=0;i<loop;i++)
		{
			upload_contents=upload_contents+"<tr>";
			upload_contents=upload_contents+"<td class=normal_text>Image Name:</td>";
			upload_contents=upload_contents+"<td><input name=image"+i+" type=file size=36></td>";
			upload_contents=upload_contents+"</tr>";
		}
		upload_contents=upload_contents+"</table>";
		uploads.innerHTML=upload_contents;
	}
}

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 view_sub_menu(parent_name,catalog_menu,padding_left,padding_top)
{
	left_pos=calculateSumOffset(parent_name,"offsetLeft");
	top_pos=calculateSumOffset(parent_name,"offsetTop");
	document.getElementById(catalog_menu).style.left=left_pos+padding_left;
	document.getElementById(catalog_menu).style.top=top_pos+padding_top;
	document.getElementById(catalog_menu).style.visibility='visible';
}
function show_sub_menu(destination_div)
{
	document.getElementById(destination_div).style.visibility='visible';
}

function hide_sub_menu(destination_div)
{
	document.getElementById(destination_div).style.visibility='hidden';
}

function delete_advertisements(id)
{
	return_confirm=confirm("Are you sure that you want to delete this Advertisement?");
	if(return_confirm==true)
	{
		window.location="advertisements.php?id="+id+"&delete_advertisements=1";
	}
}

function delete_fund_raisers(id)
{
	return_confirm=confirm("Are you sure that you want to delete this delete Fund Raiser?");
	if(return_confirm==true)
	{
		window.location="fund_raisers.php?id="+id+"&delete_fund_raisers=1";
	}
}

function delete_article(id,category,offset)
{
	return_confirm=confirm("Are you sure that you want to delete this Article?");
	if(return_confirm==true)
	{
		window.location="articles.php?id="+id+"&category="+category+"&offset="+offset+"&mode=delete";
	}
}

function delete_module_category(page_name,id)
{
	return_confirm=confirm("Are you sure that you want to delete this category?");
	if(return_confirm==true)
	window.location=page_name+"?id="+id+"&delete_category=1";
}

function mailsubscribe(operation)
{
   mail_frm.operation_type.value=operation;
   if(operation=='add')
   {
		if(mail_frm.subscriber_name.value=="") 
		{
			alert("Please enter your name");
			mail_frm.subscriber_name.focus();
		}
		else
  		if(mail_frm.subscriber_email.value=="") 
		{
			alert("Please enter the E-mail address");
			mail_frm.subscriber_email.focus();
		}
		else
		if(mail_frm.subscriber_email.value.indexOf("@",1)==-1) 
		{
			alert("Invalid E-mail address");
			mail_frm.subscriber_email.focus();
		}
		else
		if(mail_frm.subscriber_email.value.indexOf("@",1)==0) 
		{
			alert("Invalid E-mail address");
			mail_frm.subscriber_email.focus();
		}
		else
		if(mail_frm.subscriber_email.value.indexOf("@",mail_frm.subscriber_email.value.indexOf("@",1)+1)>-1) 
		{
			alert("Invalid E-mail address");
			mail_frm.subscriber_email.focus();
		}
		else
		if(mail_frm.subscriber_email.value.indexOf(".",mail_frm.subscriber_email.value.indexOf("@",1)+2)==-1)	
		{
			alert("Invalid E-mail address");
			mail_frm.subscriber_email.focus();
		}
		else
		if(mail_frm.authentication_number.value=="") 
		{
			alert("Please type in the code exactly as it appears in the graphic image");
			mail_frm.authentication_number.focus();
		}
		else		
  			mail_frm.submit();
	}
	else
	{
  		if(mail_frm.subscriber_email.value=="") 
		{
			alert("Please enter the E-mail address");
			mail_frm.subscriber_email.focus();
		}
		else
		if(mail_frm.subscriber_email.value.indexOf("@",1)==-1) 
		{
			alert("Invalid E-mail address");
			mail_frm.subscriber_email.focus();
		}
		else
		if(mail_frm.subscriber_email.value.indexOf("@",1)==0) 
		{
			alert("Invalid E-mail address");
			mail_frm.subscriber_email.focus();
		}
		else
		if(mail_frm.subscriber_email.value.indexOf("@",mail_frm.subscriber_email.value.indexOf("@",1)+1)>-1) 
		{
			alert("Invalid E-mail address");
			mail_frm.subscriber_email.focus();
		}
		else
		if(mail_frm.subscriber_email.value.indexOf(".",mail_frm.subscriber_email.value.indexOf("@",1)+2)==-1)	
		{
			alert("Invalid E-mail address");
			mail_frm.subscriber_email.focus();
		}
		else
		if(mail_frm.authentication_number.value=="") 
		{
			alert("Please type in the code exactly as it appears in the graphic image");
			mail_frm.authentication_number.focus();
		}
		else		
  			mail_frm.submit();
	}
}

function check_authentication(image_code)
{
	if(ccoptin.ea.value=="") 
	{
		alert("Please enter the E-mail address");
		ccoptin.ea.focus();
	}
	else
	if(ccoptin.ea.value.indexOf("@",1)==-1) 
	{
		alert("Invalid E-mail address");
		ccoptin.ea.focus();
	}
	else
	if(ccoptin.ea.value.indexOf("@",1)==0) 
	{
		alert("Invalid E-mail address");
		ccoptin.ea.focus();
	}
	else
	if(ccoptin.ea.value.indexOf("@",ccoptin.ea.value.indexOf("@",1)+1)>-1) 
	{
		alert("Invalid E-mail address");
		ccoptin.ea.focus();
	}
	else
	if(ccoptin.ea.value.indexOf(".",ccoptin.ea.value.indexOf("@",1)+2)==-1)	
	{
		alert("Invalid E-mail address");
		ccoptin.ea.focus();
	}
	else		
		ccoptin.submit();
			
}

function print_article(id)
{
	window.open("print_article.php?id="+id,"print_article","width=600,height=550,top=100,left=250,scrollbars=yes");
}

function email_article(id)
{
	window.open("email_article.php?id="+id,"email_article","width=600,height=550,top=100,left=250,scrollbars=yes");
}

function print_news(id)
{
	window.open("print_news.php?id="+id,"print_news","width=600,height=550,top=100,left=250,scrollbars=yes");
}

function email_news(id)
{
	window.open("email_news.php?id="+id,"email_news","width=600,height=550,top=100,left=250,scrollbars=yes");
}

function clear_intro_text()
{
	if(frm.keywords_idntify.value=="") 
	{
		frm.keywords.value="";
		frm.keywords_idntify.value=1;
	}
}
