// JavaScript Document

function validate_frm()
{	
	obj = document.frmDestination;	
		
	if(obj.txtfname.value == '')
	{
		alert("Please enter your first name");
//		obj.txtfname.value = '';
		obj.txtfname.focus();
		return false;
	}
	else if(obj.txtlname.value == '')
	{
		alert("Please enter your last name");		
//		obj.txtlname.value = '';
		obj.txtlname.focus();
		return false;
	}
	else if(obj.txtaddress.value == '')
	{
		alert("Please enter your address");	
//		obj.txtaddress.value = '';
		obj.txtaddress.focus();
		return false;
	}
	else if(obj.txtcity.value == '')
	{
		alert("Please enter your city");	
//		obj.txtcity.value = '';
		obj.txtcity.focus();
		return false;
	}	
	else if(document.getElementById('state').value == '0')
	{
		alert("Please select state");	
		obj.state.focus();
		return false;
	}
	else if(obj.txtzipcode.value == '')
	{
		alert("Please enter your zip code");	
//		obj.txtzipcode.value = '';
		obj.txtzipcode.focus();
		return false;
	}
	
	else if(obj.txtstdcode.value == '')
	{
		alert("Please enter Area code");	
		obj.txtstdcode.focus();
		return false;
	}
	else if(obj.txtphonenumber.value == '')
	{
		alert("Please enter your phone number");	
//		obj.txtphonenumber.value = '';
		obj.txtphonenumber.focus();
		return false;
	}
	else if(obj.txtemail.value == '')
	{
		alert("Please enter your email address");	
//		obj.txtemail.value = '';
		obj.txtemail.focus();
		return false;
	}else if(!checkEmail("txtemail")){
			alert("Please enter your valid email address");	
			obj.txtemail.focus();
			return false;
	}else if(obj.txtemailrepeat.value == '')
	{
		alert("Please enter your email address - Repeat");	
//		obj.txtemailrepeat.value = '';
		obj.txtemailrepeat.focus();
		return false;
	}else if(!checkEmail("txtemailrepeat")){
			alert("Please enter your valid email address - Repeat");	
			obj.txtemailrepeat.focus();
			return false;
	}
	else if(obj.txtemail.value != obj.txtemailrepeat.value)
	{
		alert("Please enter same email");	
//		obj.txtemailrepeat.value = '';
		obj.txtemailrepeat.focus();
		return false;		
	}
	
	var myindex = document.getElementById('destinationid').value;
	if (myindex == 'select') 
	{
		alert("Please select total quilts needing destination");	
		document.getElementById('destinationid').focus();
		return false;
	}

        //var otherid_m_value = document.getElementById('otherid_m').value;
        //var branch_name_value = document.getElementById('other_m_branch').value;
        /*if (otherid_m_value > 0 && branch_name_value == "")
	{
		alert("Please select Branch");
		document.getElementById('other_m_branch').focus();
		return false;
	}*/
	
/*	var p_m = document.getElementById('patrioticid_m').value;
	if (p_m == 'select') 
	{
		alert("Please select number of Male for patriotic");
		document.getElementById('patrioticid_m').focus();
		return false;
	}	

	var p_f = document.getElementById('patrioticid_f').value;
	if (p_f == 'select') 
	{
		alert("Please select number of Female for patriotic");
		document.getElementById('patrioticid_f').focus();
		return false;
	}
	
	var p_o = document.getElementById('patrioticid_o').value;
	if (p_o == 'select') 
	{
		alert("Please select number of Unisex for patriotic");
		document.getElementById('patrioticid_o').focus();
		return false;
	}
	
	var g_m = document.getElementById('genericid_m').value;
	if (g_m == 'select') 
	{
		alert("Please select number of Male for Generic");
		document.getElementById('genericid_m').focus();
		return false;
	}	

	var g_f = document.getElementById('genericid_f').value;
	if (g_f == 'select') 
	{
		alert("Please select number of Female for Generic");
		document.getElementById('genericid_f').focus();
		return false;
	}
	
	var g_o = document.getElementById('genericid_o').value;
	if (g_o == 'select') 
	{
		alert("Please select number of Unisex for Generic");
		document.getElementById('genericid_o').focus();
		return false;
	}
	
	var o_m = document.getElementById('otherid_m').value;
	if (o_m == 'select') 
	{
		alert("Please select number of Male for Other");
		document.getElementById('otherid_m').focus();
		return false;
	}
	
	var o_f = document.getElementById('otherid_f').value;
	if (o_f == 'select') 
	{
		alert("Please select number of Female for Other");
		document.getElementById('otherid_f').focus();
		return false;
	}
	
	var o_o = document.getElementById('otherid_o').value;
	if (o_o == 'select') 
	{
		alert("Please select number of Unisex for Other");
		document.getElementById('otherid_o').focus();
		return false;
	}	

	var s_m = document.getElementById('specialtyid_m').value;
	if (s_m == 'select') 
	{
		alert("Please select number of Male for Specialty");
		document.getElementById('specialtyid_m').focus();
		return false;
	}
	
	var s_f = document.getElementById('specialtyid_f').value;
	if (s_f == 'select') 
	{
		alert("Please select number of Female for Specialty");
		document.getElementById('specialtyid_f').focus();
		return false;
	}

	var s_o = document.getElementById('specialtyid_o').value;
	if (s_o == 'select') 
	{
		alert("Please select number of Unisex for Specialty");
		document.getElementById('specialtyid_o').focus();
		return false;
	}
*/
//	alert(obj.destination.value + "    " +document.getElementById('tot_id').value);
	
	//alert(parseInt(document.getElementById('tot_id').innerHTML));
	
	/*
	if(obj.destination.value != document.getElementById('tot_id').value )	
	{
		alert("Total number of quilts dose not match")
		obj.destination.focus();
		return false;
	}
	*/
	
//	document.frmDestination.action = '';
//	document.frmDestination.method= 'post';	
//	document.frmDestination.submit();
return true;
}

function onlyNumber(objEvent) 
{
  if(objEvent.ctrlKey==true)
  	return false;
  var iKeyCode;  	
  browser=navigator.appName;
 
  if(browser.appName=="Netscape")
  {
	  iKeyCode = objEvent.which;  
  }
  else
  {
	  iKeyCode = objEvent.keyCode;
  }
  if(iKeyCode==8 || iKeyCode==9  || (iKeyCode>=48 && iKeyCode<=57) ||( iKeyCode>=96 && iKeyCode<=105) )
  	return true;
  else
	 return false;
}
function checkEmail(ctrlname)
{
	var obj = document.getElementById(ctrlname);
	//alert(obj) ; return false;
	if(obj.value != "")
	{
		if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj.value))
		{	
			return true;
		}
		else
		{
			//alert("Please enter your valid email address.");
		//	obj.value = "";
			//obj.focus();
			return false;
		}
	}
}

function doTotalSum() {
    var patValue = parseInt(document.getElementById("patrioticid_m").value);
    var femValue = parseInt(document.getElementById("feminine_m").value);
    var genValue = parseInt(document.getElementById("genericid_m").value);
    var ArmyValue = parseInt(document.getElementById("army_m").value);
	var MarinesValue = parseInt(document.getElementById("marines_m").value);
	var AirforceValue = parseInt(document.getElementById("airforce_m").value);
	var NavyValue = parseInt(document.getElementById("navy_m").value);
	var CoastGuardValue = parseInt(document.getElementById("coastguard_m").value);
    
    document.getElementById("tot_id").innerHTML = patValue + femValue + genValue + ArmyValue + MarinesValue
	  + AirforceValue + NavyValue + CoastGuardValue;
}

function sumofPatriotic(m,f,o)
{
	if (m == 'select')	m = 0;
	if (f == 'select')	f = 0;
	if (o == 'select')	o = 0;
	
	var total_of_P = parseInt(m) + parseInt(f) + parseInt(o);
	document.getElementById("tot_pid").innerHTML = total_of_P;
	document.getElementById("tot_pid").value = total_of_P;
	
	var p = document.getElementById("tot_pid").value;
	var g = document.getElementById("tot_gid").value;
	var o = document.getElementById("tot_oid").value;
	var s = document.getElementById("tot_sid").value;
	
	//alert(p + "  " + g + "  " + o + "  " + s);
	if(p == null)	{	p = 0;	}
	if(g == null)	{	g = 0;	}
	if(o == null)	{	o = 0;	}
	if(s == null)	{	s = 0;	}
	
	document.getElementById("tot_id").innerHTML = parseInt(p) + parseInt(g) + parseInt(o) + parseInt(s);
	document.getElementById("tot_id").value = parseInt(p) + parseInt(g) + parseInt(o) + parseInt(s);
}

function sumofGeneric(m,f,o)
{
	if (m == 'select')	m = 0;
	if (f == 'select')	f = 0;
	if (o == 'select')	o = 0;

	var total_of_G = parseInt(m) + parseInt(f) + parseInt(o);
	document.getElementById("tot_gid").innerHTML = total_of_G;
	document.getElementById("tot_gid").value = total_of_G;

	var p = document.getElementById("tot_pid").value;
	var g = document.getElementById("tot_gid").value;
	var o = document.getElementById("tot_oid").value;
	var s = document.getElementById("tot_sid").value;
	
	if(p == null)	{	p = 0;	}
	if(g == null)	{	g = 0;	}
	if(o == null)	{	o = 0;	}
	if(s == null)	{	s = 0;	}		
	
	document.getElementById("tot_id").innerHTML = parseInt(p) + parseInt(g) + parseInt(o) + parseInt(s);
	document.getElementById("tot_id").value = parseInt(p) + parseInt(g) + parseInt(o) + parseInt(s);
}

function sumofOther(m,f,o)
{
	if (m == 'select')	m = 0;
	if (f == 'select')	f = 0;
	if (o == 'select')	o = 0;

	var total_of_O = parseInt(m) + parseInt(f) + parseInt(o);
	document.getElementById("tot_oid").innerHTML = total_of_O;
	document.getElementById("tot_oid").value = total_of_O;

	var p = document.getElementById("tot_pid").value;
	var g = document.getElementById("tot_gid").value;
	var o = document.getElementById("tot_oid").value;
	var s = document.getElementById("tot_sid").value;

	if(p == null)	{	p = 0;	}
	if(g == null)	{	g = 0;	}
	if(o == null)	{	o = 0;	}
	if(s == null)	{	s = 0;	}		
	
	document.getElementById("tot_id").innerHTML = parseInt(p) + parseInt(g) + parseInt(o) + parseInt(s);
	document.getElementById("tot_id").value = parseInt(p) + parseInt(g) + parseInt(o) + parseInt(s);
}

function sumofSpecialty(m,f,o)
{
	if (m == 'select')	m = 0;
	if (f == 'select')	f = 0;
	if (o == 'select')	o = 0;

	var total_of_S = parseInt(m) + parseInt(f) + parseInt(o);
	document.getElementById("tot_sid").innerHTML = total_of_S;
	document.getElementById("tot_sid").value = total_of_S;

	var p = document.getElementById("tot_pid").value;
	var g = document.getElementById("tot_gid").value;
	var o = document.getElementById("tot_oid").value;
	var s = document.getElementById("tot_sid").value;
	
	//alert(s);

	if(p == null)	{	p = 0;	}
	if(g == null)	{	g = 0;	}
	if(o == null)	{	o = 0;	}
	if(s == null)	{	s = 0;	}		
	
	
	document.getElementById("tot_id").innerHTML = parseInt(p) + parseInt(g) + parseInt(o) + parseInt(s);
	document.getElementById("tot_id").value =  parseInt(p) + parseInt(g) + parseInt(o) + parseInt(s);
}
