
//_-------------valid email-id----------//
function isValidEmailId(obj, name)
{
   obj.value=trim(obj.value);
   if (obj.value=='')
   {
	   alert('"'  + name + '" can not be blank. Please enter it.' );
	   obj.focus();
	   return false;
   }
   
   if (! isValidEmail(obj.value))
   {
      alert("Invalid e-Mail-Id entered.");
	  obj.focus();
	  return false;
   }
   return true;
}

function isValidEmail(elm)
{
 if(elm.indexOf('@',1) ==-1)
 	return (false);
 
 if(elm.indexOf('.',1) ==-1)
 	return (false);
 
 return true;
}

function trim(p_str)
{
   var i=0;
   while(1)
   {
     if ( p_str.charAt(0)==" " || p_str.charAt(0)=="\n" || p_str.charAt(0)=="\r") 
       p_str = p_str.substr(i+1);
     else
       break;
    } 
   
   while(1)
   {
     i=p_str.length;
     if ( p_str.charAt(i-1)==" " || p_str.charAt(i-1)=="\n" || p_str.charAt(i-1)=="\r") 
       p_str=p_str.substr(0,i-1);
     else
       break;
   }
  return p_str; 
}

function creditvalidation()
{	
	obj= document.myform;
	if(obj.txtname.value=="")
	{
		alert("Please Enter Your First Name");
		obj.txtname.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txtlast.value=="")
	{
		alert("Please Enter Your Last Name");
		obj.txtlast.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txtstreet.value=="")
	{
		alert("Please Enter Your Street Address");
		obj.txtstreet.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txtsal.value=="")
	{
		alert("Please Enter Your Gross Salary");
		obj.txtsal.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txtcity.value=="")
	{
		alert("Please Enter Your City");
		obj.txtcity.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txthm.value=="")
	{
		alert("Please Enter Your Residence Phone no.");
		obj.txthm.focus();
		return false;
	}	
	obj=document.myform.txtemail;
	if(!isValidEmailId(obj, " Email "))
	{
			return false;
	}
	obj= document.myform;
	if(obj.txtwrk.value=="")
	{
		alert("Please Enter Your Work Phone no.");
		obj.txtwrk.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txtdate.value=="")
	{
		alert("Please Enter Your Date of Birth");
		obj.txtdate.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txtlong.value=="")
	{
		alert("Please Enter How Long You Have Worked");
		obj.txtlong.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txtemp.value=="")
	{
		alert("Please Enter Your Place of Employment");
		obj.txtemp.focus();
		return false;
	}
	obj= document.forms[0];
	if(!obj.cre_status[0].checked && !obj.cre_status[1].checked)
	{
		alert("Please enter your choice for authorization")
		//obj.mem_gender.focus();
		return false;
	}
		return true;
}

function validappointment()
{	
	obj= document.myform;
	if(obj.txtname.value=="")
	{
		alert("Please Enter Your First Name ");
		obj.txtname.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txtlast.value=="")
	{
		alert("Please Enter Your Last Name ");
		obj.txtlast.focus();
		return false;
	}
	obj=document.myform.txtmail;
	if(!isValidEmailId(obj, " Email "))
	{
			return false;
	}
	obj= document.myform;
	if(obj.txtdayph.value=="")
	{
		alert("Please Enter Your Day Time Phone no.");
		obj.txtdayph.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txtmonth.value=="")
	{
		alert("Please Enter Month ");
		obj.txtmonth.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txtday.value=="")
	{
		alert("Please Enter Day ");
		obj.txtday.focus();
		return false;
	}	
	obj= document.myform;
	if(obj.txttime.value=="")
	{
		alert("Please Enter Time ");
		obj.txttime.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txtpurchase.value=="")
	{
		alert("Please Enter the plan ");
		obj.txtpurchase.focus();
		return false;
	}
	return true;
}

function validcontact()
{	
	obj= document.myform;
	if(obj.txtname.value=="")
	{
		alert("Please Enter Your Name ");
		obj.txtname.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txtcity.value=="")
	{
		alert("Please Enter Your City Name ");
		obj.txtcity.focus();
		return false;
	}
	
	obj= document.myform;
	if(obj.txtph.value=="")
	{
		alert("Please Enter Your Day Time Phone no.");
		obj.txtph.focus();
		return false;
	}
	obj=document.myform.txtmail;
	if(!isValidEmailId(obj, " Email "))
	{
			return false;
	}
	obj= document.myform;
	if(obj.message.value=="")
	{
		alert("Please Enter Your Message ");
		obj.message.focus();
		return false;
	}
	return true;
}

function validcarsection()
{	
	obj= document.myform;
	if(obj.txtname.value=="")
	{
		alert("Please Enter Your Name ");
		obj.txtname.focus();
		return false;
	}
	obj= document.myform;
	if(obj.txtcity.value=="")
	{
		alert("Please Enter Your City Name ");
		obj.txtcity.focus();
		return false;
	}
	
	obj= document.myform;
	if(obj.txtph.value=="")
	{
		alert("Please Enter Your Day Time Phone no.");
		obj.txtph.focus();
		return false;
	}
	obj=document.myform.txtmail;
	if(!isValidEmailId(obj, " Email "))
	{
			return false;
	}
	obj= document.myform;
	if(obj.txtmk.value=="")
	{
		alert("Please Enter Your Make Type ");
		obj.txtmk.focus();
		return false;
	}

	obj= document.myform;
	if(obj.message.value=="")
	{
		alert("Please Enter Your Message ");
		obj.message.focus();
		return false;
	}
	return true;
}

function validmail()
{
	obj=document.myform.txtname;
    if(isEmpty(obj,"Name"))
        return false;

	obj=document.myform.txtemail;
	if(!isValidEmailId(obj, "Email ID"))
	{
			return false;
	}

	obj=document.myform.femail;
	if(!isValidEmailId(obj, "Friend's Email ID"))
	{
			return false;
	}

	obj=document.myform.txtcomments;
    if(isEmpty(obj,"Comments"))
        return false;
	 return true;
}




function validcareers()
{
	 
	obj=document.myform.fname;
     if(isEmpty(obj,"First Name"))
        return false;

	obj=document.myform.lname;
    if(isEmpty(obj,"Last Name"))
        return false;

	obj=document.myform.address;
    if(isEmpty(obj,"Address"))
        return false;


	obj=document.myform.email;
	if(!isValidEmailId(obj, "Email ID"))
	{
			return false;
	}

	 return true;
}
function validquotes()
{
	obj=document.myform.txtname;
    if(isEmpty(obj,"Name"))
        return false;

	obj=document.myform.txtlast;
    if(isEmpty(obj,"Last Name"))
        return false;

	obj=document.myform.txtmail;
	if(!isValidEmailId(obj, "Email ID"))
	{
			return false;
	}
	
	obj=document.myform.txtph;
    if(isEmpty(obj,"Phone No."))
        return false;
	

	obj=document.myform;
   
	if(obj.cmbplan.value=="-1")
	{
		alert("Please select Plan")
		obj.cmbplan.focus();
		return false;
	}
		 return true;
}
/////////////////////////////////Ajax Insert Function

function feedBack_ajaxFunction(){
 
	var ajaxRequest;  // The variable that makes Ajax possible!
 	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}

 
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function()
		{
	 
 		if(ajaxRequest.readyState == 4){
		 var ajaxDisplay = document.getElementById('msg');		  
		  ajaxDisplay.innerHTML = ajaxRequest.responseText;
		  		  		  
 		 	document.getElementById('txtname').value=""; 
	  		document.getElementById('txtadd').value="";
	 		document.getElementById('txtph').value="";
	 		document.getElementById('email').value="";
	 		document.getElementById('txtcomments').value="";
 		}
	}

	var name = document.getElementById('txtname').value; 
	var add = document.getElementById('txtadd').value;
	var phone = document.getElementById('txtph').value;
	var mail = document.getElementById('email').value;
	var comments = document.getElementById('txtcomments').value;
	 
	 if(name=="")
	 	{
		alert("Name Should Not be Blank");
		return false
		}
	 if(add=="")
	 	{
		alert("Address Should Not be Blank");
		return false
		
		}
		 
		obj=document.myForm.email;
		if(!isValidEmailId(obj, "Email ID"))
		{
				return false 
		}		
		if(comments=="")
	 	{
		alert("Comments Should Not be Blank");
		return false
		}
		
/*
		var name = document.txtname.value; 
		var add = document.txtadd.value;
		var phone = document.txtph.value;
		var mail = document.email.value;
		var comments = document.txtcomments.value;
*/
	
	var queryString = "?name=" + name + "&add=" + add + "&phone=" + phone + "&mail=" + mail+ "&comments=" + comments;
 
	ajaxRequest.open("POST", "feedback_ajx_query.php" + queryString, true);
	ajaxRequest.send(null); 
}
 
/////////////////

function smallnewwin(id)
{
	mywindow = window.open ("view_contact_detail.php?aid="+id,"","scrollbars, width=480, height=460, status,toolbar=Off,menubar=Off");
}

function popup_pressreport(id)
{
	window.open("pressreport_image.php?aid="+id,"", "status,scrollbars=yes, width=550, height=500, menubar=Off, toolbar=Off, resizable=1");
}