// JavaScript Document
function change_img(id, img)
{
	document.getElementById(id).src = "images/"+img;
}

function EmbedSWF1()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="55" height="65">');
document.write('<param name="movie" value="images/running_man_small.swf">');
document.write('<param name="quality" value="high">');
document.write('<param name="wmode" value="transparent">');
document.write('<param name="menu" value="false">');
document.write('<embed src="images/running_man_small.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="55" height="65" hspace="0" vspace="0" SwLiveConnect="true" wmode="transparent" menu="false"></embed>');
document.write('</object>');
}

function EmbedSWF2()
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="54" height="80">');
document.write('<param name="movie" value="images/piggy.swf">');
document.write('<param name="quality" value="high">');
document.write('<param name="wmode" value="transparent">');
document.write('<param name="menu" value="false">');
document.write('<embed src="images/piggy.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="54" height="80" hspace="0" vspace="0" SwLiveConnect="true" wmode="transparent" menu="false"></embed>');
document.write('</object>');
}



//------------------------------------------------------------------------------------------------------------
// FUNCTION TO PRELOAD AND DISPLAY MENU ITEMS ON MOUSEHOVER
//------------------------------------------------------------------------------------------------------------
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//--------------------------------------------------------------------------------------------------------
// Function to Display Subcategory
//--------------------------------------------------------------------------------------------------------

function show_amt(quantity, unit_cost) 
{  
	var name = quantity.name;
	var no = name.replace("quantity","");
	
	var final_total = 0;
	if(!isNaN(quantity.value))
	{
		if(unit_cost != 0)
		{
			var sub_total = quantity.value * parseFloat(unit_cost);	
		}
		if(unit_cost == 0)
		{
			var sub_total = quantity.value;	
		}
		document.getElementById("sub_amt"+no).innerHTML =  sub_total;
	}
	else
	{
		alert("Please enter a number");
		document.getElementById("sub_amt"+no).innerHTML =  0;
	}
	var count = document.donation_form.count.value;
	for(var i=1; i<=count; i++ )
	{
		final_total = final_total + parseFloat(document.getElementById("sub_amt"+i).innerHTML);
	}
	document.donation_form.total_amt.value = final_total;
	
} 

//--------------------------------------------------------------------------------------
// Show/ Hide Divs
//--------------------------------------------------------------------------------------
function disp_div(divname, divno, count)
{
	for(var i=1; i<=count; i++)
	{
		if(i == divno)
		{
			var name = divname+divno;
			show_div(name);
		}
		if(i != divno)
		{
			var name = divname+i;
			hide_div(name);
		}
	}
	
}
function disp_div2(divname, divno, count)
{
	for(var i=1; i<=count; i++)
	{
		if(i == divno)
		{
			var name = divname+divno;
			hide_div(name);
		}
		if(i != divno)
		{
			var name = divname+i;
			show_div(name);
		}
	}
	
}
function show_div(name)
{
	document.getElementById(name).style.visibility = "visible";
	document.getElementById(name).style.display = "block";
}

function hide_div(name)
{
	document.getElementById(name).style.visibility = "hidden";
	document.getElementById(name).style.display = "none";

}
//--------------------------------------------------------------------
// Validate donation form
//--------------------------------------------------------------------
function chk_donation()
{
	var flag = 0;
	var temp = 0;
	if(document.donation_form.national[0].checked){flag++;}
	if(document.donation_form.national[1].checked){flag++;}
	
	if(document.donation_form.payment_option[0].checked){temp++;}
	if(document.donation_form.payment_option[1].checked){temp++;}
	
	var email_Regxp = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/;
	
	var msg = "";
	if(isNaN(document.donation_form.total_amt.value)){ msg = msg+"Donation amount\n";}
	if(document.donation_form.total_amt.value == 0){ msg = msg+"Donation amount\n";}
	if(document.donation_form.fname.value == ""){ msg = msg+"First Name\n";}
	if(document.donation_form.lname.value == ""){ msg = msg+"Last Name\n";}
	if(document.donation_form.email.value == "" || email_Regxp.test(document.donation_form.email.value) == false){ msg = msg+"Email\n";}
	if(document.donation_form.address.value == ""){ msg = msg+"Address\n";}
	if(document.donation_form.city.value == ""){ msg = msg+"City\n";}
	if(document.donation_form.state.value == ""){ msg = msg+"State\n";}
	if(document.donation_form.country.value == ""){ msg = msg+"Country\n";}
	if(document.donation_form.pincode.value == ""){ msg = msg+"Pincode/ Zip\n";}
	if(document.donation_form.telephone.value == ""){ msg = msg+"Telephone\n";}
	if(flag == 0){ msg = msg+"Nationality\n";}
	if(document.donation_form.national[0].checked == true)
	{
		if(document.donation_form.total_amt.value >= 10000)
		{
			if(document.donation_form.pan.value == ""){ msg = msg+"PAN No\n";}
		}
	}
	
	if(temp == 0) {	msg = msg+"Payment Option\n";}
	if(document.donation_form.terms.checked == false){ msg = msg+"Terms & Conditions\n";}
	if(document.donation_form.scode.value == ""){ msg = msg+"Security Code\n";}
	
	if(msg == "")
	{
		document.donation_form.submit();
	}	
	else
	{
		alert("Enter appropriate values in \n\n"+msg);	
	}
	
	
}
//--------------------------------------------------------------------------------------
// Check from date and to date
//--------------------------------------------------------------------------------------
function check_date()
{
	var msg = "";
	//alert(document.date_form.end.value);
	if (document.date_form.end.value == "") { msg = msg + "To Date\n"; } 
	if (document.date_form.start.value == "") { msg = msg + "From Date\n"; }
	
	if (msg == "")
	{
		document.date_form.submit()
	}
	else
	{
		alert("Please enter...\n\n"+msg)
	}
}

//--------------------------------------------------------------------------------------
// Check from date and to date
//--------------------------------------------------------------------------------------

function chk_pwd()
{
	var msg = "";
	if(document.form1.curr_pwd.value == ""){msg += 'Current Password\n';}
	if(document.form1.new_pwd1.value == ""){msg += 'New Password\n';}
	if(document.form1.new_pwd2.value == ""){msg += 'Re-Enter New Password\n';}
	if(msg != "")
	{
		alert("Enter appropriate values in following fields!\n\n"+msg);
	}
	else if(document.form1.new_pwd1.value != document.form1.new_pwd2.value)
	{
		alert("Enter same values in new password fields");
	}
	else
	{
		document.form1.submit();	
	}
		
}

