﻿function doIpack(){
	var cname=document.frmcsr.txtcusname.value;
	var contact=document.frmcsr.txtContact.value
	var des=document.frmcsr.txtDes.value;
	var site=document.frmcsr.txtSite.value;
	var addr1=document.frmcsr.txtAddress.value;
	var city=document.frmcsr.txtCity.value;
	var pin=document.frmcsr.txtpin.value;
	var state=document.frmcsr.ddstate.options[document.frmcsr.ddstate.selectedIndex].value;
	var phone=document.frmcsr.txtPhone.value;
	var email=document.frmcsr.txtEmail.value;
	var win=document.frmcsr.tbwin.value;
	var sp=document.frmcsr.tbservice.value;
	var model=document.frmcsr.tbprod.value;
	var unit=document.frmcsr.txtunit.value;
	var exstart=document.frmcsr.tbExtstart.value;
	var exend=document.frmcsr.tbExtend.value;
	//var model=document.frmcsr.ddmodel.options[document.frmcsr.ddmodel.selectedIndex].value;
	//var unit=document.frmcsr.txtunit.value;
	//var problemdesc=document.frmcsr.txtproblem.value;
	
	if(cname.length==0 || cname.length=='null')
	{
	alert("Name Field should not be Empty");
	document.frmcsr.txtcusname.focus();
	document.frmcsr.txtcusname.select();
	return false;
	}

	ch1=cname.substring(0,1);
	if((ch1<"a" || ch1>"z") && (ch1<"A" || ch1>"Z") && ch1==" ")
		{
			alert("The Name Field should begin with an Alphabetic Character.");
			document.frmcsr.txtcusname.focus();
			document.frmcsr.txtcusname.select();
			return false;
		}

	for (var i=0; i<cname.length; i++) 
		{
			var ch =cname.substring(i, i + 1);
			if ( ((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && (ch != ' ')) 
			{
				alert("The Name Field  accepts Letters Only.\n\nPlease Re-enter");
				document.frmcsr.txtcusname.focus();
				document.frmcsr.txtcusname.select();
				return false;
			}
		}
		
	if(contact.length==0 || contact.length=='null')
	{
	alert("company Field should not be Empty.");
	document.frmcsr.txtContact.focus();
	return false;
	}

	if(pin.length==0 || pin.length=='null')
	{
	alert("Pincode Field should not be Empty.");
	document.frmcsr.txtpin.focus();
	return false;
	}
	if(phone.length==0 || phone.length=='null')
	{
	alert("Phone Field should not be Empty, Please Enter");
	document.frmcsr.txtPhone.focus();
	return false;
	}
	if(phone.substring(0,1)==" ")
	{
	alert("Phone Field Should Begin With a Number.")
	document.frmcsr.txtPhone.focus();
	document.frmcsr.txtPhone.select();
	return false;
	}
	for (var i=0;i<phone.length;i++)
	{
	var ch=phone.substring(i,i+1)
	if ( isNaN(ch) && (ch !="-") && (ch !="/") && (ch !=" "))
	{
	alert("Phone field accepts Numbers, - and / only.");
	document.frmcsr.txtPhone.focus();
	document.frmcsr.txtPhone.select();
	return false;
	}
	}
	if(phone.length<5)
	{
	alert("Phone Field accepts more than 5 numbers only.");
	document.frmcsr.txtPhone.focus();
	return false;
	}

	elen= email.length;
		efirstchar = email.substring(0, 1);
		elastchar  = email.substring(elen-1, elen);

		atPos = email.indexOf("@",1)	
		if (atPos == -1) 
		{
			alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();
			return false;
		}
		if (email.indexOf("@",atPos+1) != -1) 
		{
		alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select(); 
			return false;
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) 
		{	
		alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();
			return false;
		}
		if (periodPos+3 > elen)	
		{ alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();
			return false;
		}
		if (email.indexOf("..",1) != -1)
		 {
		alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();
			return false;
		}
		if (email.indexOf("@.",1) != -1) {
		alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();
			return false;
		}
		if (email.indexOf(".@",1) != -1)
		 {
		 alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();
			return false;
		}
	if (email.indexOf("-@",1) != -1)
		 {
		 alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();
			return false;
		}
	if (email.indexOf("@-",1) != -1)
		 {
		 alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();
			return false;
		}
	if (email.indexOf("-.",1) != -1)
		 {
		 alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();
			return false;
		}
	if (email.indexOf(".-",1) != -1)
		 {
		 alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();
			return false;
		}
	if (email.indexOf("--",1) != -1)
		 {
		 alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();
			return false;
		}        
	if((efirstchar<"a" || efirstchar>"z") && (efirstchar<"A" || efirstchar>"Z"))
		{
		alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();
			return false;
		}

		if((elastchar<"a" || elastchar>"z") && (elastchar<"A" || elastchar>"Z"))
		{
			alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();	
			return false;
		}

	    	for (var i = 1; i < elen; i++)
			{
			var ch = email.substring(i, i + 1);
			if ( ((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && (ch < "0" || "9" < ch) && (ch != '_') && (ch != "@") && (ch != ".") && (ch !="-"))
			{	
				alert("Please Enter Valid Email Id");
			document.frmcsr.txtEmail.focus();
			document.frmcsr.txtEmail.select();
				return false;
			}
			}
			
	/*if (model==0)
	{
		alert("Select Model")
		document.frmcsr.ddmodel.focus();
		return false;
	}		
	
	if(unit.length==0 || unit.length=='null')
	{
	alert("Unit Serial Number Field should not be Empty.");
	document.frmcsr.txtunit.focus();
	return false;
	}
	
	if(problemdesc.length==0 || problemdesc.length=='null')
	{
	alert("Problem Description Field should not be Empty.");
	document.frmcsr.txtproblem.focus();
	return false;
	}*/
	
	document.frmcsr.action="cus-support-ipack-reg-handler.asp"
	document.frmcsr.submit();
}

function onshowRibbons()
{
if(document.getElementById("hdRibbons").value=='0')
{
document.getElementById("trribbons").style.display='';
document.getElementById("hdRibbons").value='1';
}
else
{
document.getElementById("trribbons").style.display='none';
document.getElementById("hdRibbons").value='0';
}
}

function doshowtab(x)
{ 
//alert(x);  
    for( i=1 ; i<=3 ; i++ )
    {
     document.getElementById('trconsu'+i).style.display="none";
    }
    document.getElementById('trconsu'+x).style.display="";
    
}

function displaycontent(a,tot)
{
	//alert(tot);
	//alert(a);
  for (i=1;i<=parseInt(tot);i++)
	 {
		
		  if (i==a)
		    {		 
		      if (eval("document.getElementById('trow" + a + "')").style.display=="")
			   {				
				  eval("document.getElementById('trow" + a + "')").style.display="none";
			   }
			 else
			   {
				  eval("document.getElementById('trow" + i + "')").style.display="";				  
			   }
		    }
		else
		{
	
			eval("document.getElementById('trow" + i + "')").style.display="none";
				
		}
	}	
}

function displayshow(a,tots)
{

  for (i=1;i<=parseInt(tots);i++)
	 {
		  if (i==a)
		    {
		      if (eval("document.getElementById('trrow" + a + "')").style.display=="")
			   {				
				  eval("document.getElementById('trrow" + a + "')").style.display="none";
			   }
			 else
			   {
				  eval("document.getElementById('trrow" + i + "')").style.display="";				   
			   }
		    }	
	}	
}

function displaycontent2(a,tot)
{

  for (i=1;i<=parseInt(tot);i++)
	 {
		  if (i==a)
		    {
		      if (eval("document.getElementById('trrrow" + a + "')").style.display=="")
			   {				
				  eval("document.getElementById('trrrow" + a + "')").style.display="none";
			   }
			 else
			   {
				  eval("document.getElementById('trrrow" + i + "')").style.display="";				   
			   }
		    }
		else
		{
			eval("document.getElementById('trrrow" + i + "')").style.display="none";
		}
	}	
}