
function submitcontact(type){
	if(type=='thanks')
		{
	
	var alertlist="";
	var fcs="";
	if(!validateNotEmpty(document.feedbackform.txtName.value)){alertlist+="Please enter \" Name\"\n";fcs+="-txtName";}
	if(validateNotEmpty(document.feedbackform.txtName.value))
		{
			 if(document.feedbackform.txtName.value==0)
			{
				alert('"Name" should not have only zeroes');
				document.feedbackform.txtName.focus();
				return false;
			}
			if(!validateAlpha2(document.feedbackform.txtName.value))
			{
				alert('Please enter valid "Name"');
				document.getElementById("txtName").focus();
				return false;
			}       
		}
	
	if(!validateNotEmpty(document.feedbackform.txtCompany.value)){alertlist+="Please enter \"Company Name\"\n";fcs+="-txtCompany";}
	if(validateNotEmpty(document.feedbackform.txtCompany.value))
    {
		 if(validateNumeric(document.getElementById("txtCompany").value))
        {
            alert('Please enter valid "Company Name"');
            document.getElementById("txtCompany").focus();
            return false;
        }
		if(!validateOrg(document.getElementById("txtCompany").value))			
        {
            alert('Please enter valid "Company Name"');
            document.getElementById("txtCompany").focus();
            return false;
        }
		if(document.getElementById("txtCompany").value==0)
        {
            alert('"Company name" should not have only zeroes');
            document.getElementById("txtCompany").focus();
            return false;
        }   
	}
	
	if(!validateNotEmpty(document.feedbackform.txtPhonoNo.value)){alertlist+="Please enter \"Contact Number\"\n";fcs+="-txtPhonoNo";}
    if(validateNotEmpty(document.feedbackform.txtPhonoNo.value)) 
    {
		//alert(validate_Phonenumber('txtPhonoNo','Phone','yes','',''))
		if(validate_Phonenumber('txtPhonoNo','phone','yes','','')==false)
			{
				//alert('Please enter valid "Contact Number"');
				document.getElementById("txtPhonoNo").focus();
				return false;
			}   

	}
	
    if(!validateNotEmpty(document.feedbackform.date2.value)){alertlist+="Please select \"Preferred Date\"\n";fcs+="-txtrefdate";}

	serverdate=document.getElementById("serverdate").value;
	selecteddate=document.feedbackform.date2.value;
	if(Date.parse(serverdate)>Date.parse(selecteddate))
	{
		alertlist+="Selected date should not be less than current date";
		fcs+="-date2";
	}
		

	
	
	if((document.getElementById("TxtTime1").value) >= (document.getElementById("TxtTime3").value))  
	{
		if((document.getElementById("TxtTime2").value) >= (document.getElementById("TxtTime4").value))
		{
		  alert('Please select correct "Preferred time"');
		   document.getElementById("TxtTime3").focus();
		   return false;
		}
	}
	if(alertlist!="")
	{
		
		alert(alertlist);
		fcs_splt=fcs.split("-");
		//alert(fcs_splt[1]);
		if(fcs_splt[1]!="txtrefdate")
		document.getElementById(fcs_splt[1]).focus();
		alertlist="";
		fcs="";
		return false;
	}
		
		document.feedbackform.operation.value="feedback";
		document.feedbackform.button1.disabled=true;
		document.feedbackform.button2.disabled=true;
		//document.feedbackform.button3.disabled=true;
		document.feedbackform.submit();
		//return false;  
	}
	if(type=='close'){
		document.feedbackform.operation.value="close";
		document.feedbackform.submit();
	}
}
function LTrim( value )
{
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}
function RTrim( value )
{
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}
function str_trim( fld ) 
{
	vl=document.getElementById(fld).value;
	document.getElementById(fld).value=LTrim(RTrim(vl));
}
function gettoupperfirst(str){ // code added by yogaraja this function used to change the string first char is chang to upper case and also remove the continious space
		
	/*var strval="";
	var space=0;
	for (i=0;i<str.length ;i++ ){
		if(strval=="")
			strval=str.charAt(i).toUpperCase();
		else{
			if(!(str.charAt(i)==' ' && str.charAt(i+1)==' '))
				strval=strval+str.charAt(i);
		}
	}*/
	return str.toUpperCase();
}

function checkPhoneNumber()
{
	if(event.keyCode<=47 || event.keyCode>57)
	{
		if(event.keyCode==45){
			event.returnValue=true;
		}	
		else{
			event.returnValue=false
		}
	}
}
function Check_Phone_Number(str){
	phone=str.value;
	y=0;
	for (i=0;i< phone.length;i++ )
	{
		if(phone.charAt(i)=="-")
			y=1;
	}
	if(y==1){
		phonearray=str.value.split("-");
		if(phonearray.length > 3 || phonearray.length < 3){
			alert("Please enter valid phone number format like(91-44-54545445).");
			str.focus();
			return false;
		}
		for (i=0;i< phonearray.length;i++ )
		{
			if(phonearray[i]==0){
				alert("Please enter valid phone number format like(91-44-54545445).");
				str.focus();
				return false;
			}
			if(!validateInteger1(phonearray[i])){
				alert("Please enter numbers only");
				//str.focus();
				return false;
			}
		}
	}
	else{
		alert("Please enter valid phone number format like(91-44-54545445).");
		str.focus();
		return false;
	}
}
function validateOrg( strValue ) 
{
    var objRegExp;
    objRegExp  = /^[a-zA-Z0-9\@\s\/\_\-\.\,\&\(\)]+$/;
    return objRegExp.test(strValue);
}
function validateAlpha1( strValue ) {
    var objRegExp;
    objRegExp  = /^[a-zA-Z\s]+$/;
    return objRegExp.test(strValue);
}
function validateInteger1( strValue ) 
{
	var objRegExp;
    objRegExp  = /^[0-9]+$/;
    return objRegExp.test(strValue);
}
function onloadfunction(){
	document.feedbackform.txtName.focus();
}
/*
function timeval()
{
	if(document.feedbackform.TxtFormat.value=="AM")
	{
			if(document.feedbackform.txtTime.value!="" && document.feedbackform.txtTime.value> 11)
			{
				alert("Please enter time between 9am to 6pm");
				document.feedbackform.txtTime.focus();
				return false;
			}
	}
	if(document.feedbackform.TxtFormat.value=="PM")
	{
			if(document.feedbackform.txtTime.value!="" && document.feedbackform.txtTime.value> 6)
			{
				alert("Please enter time between 9am to 6pm");
				document.feedbackform.txtTime.focus();
				return false;
			}

	 }
	 if(document.feedbackform.TxtFormat.value=="PM" &&  document.feedbackform.txtTime.value==6)
	{
			if(document.feedbackform.txtMin.value> 0)
			{
				alert("Please enter time between 9am to 6pm");
				document.feedbackform.txtMin.focus();
				return false;
			}
	}
	if(document.feedbackform.txtMin.value!="" && document.feedbackform.txtMin.value> 59)
	{
		alert("Min should be less than 59");
		document.feedbackform.txtMin.focus();
		return false;
	}
}*/
function checkHr()
{
	if(document.feedbackform.TxtFormat.value=="AM")
	{
		//alert('Time '+document.feedbackform.txtTime.value);
		if(document.feedbackform.txtTime.value!="" && document.feedbackform.txtTime.value>11)
		{
			alert("Please enter time between 9am to 6pm");
			document.feedbackform.txtTime.focus();
			return false;
		}
		if(document.feedbackform.txtTime.value!="" && document.feedbackform.txtTime.value< 9)
		{
			alert("Please enter time between 9am to 6pm");
			document.feedbackform.txtTime.focus();
			return false;
		}	
	return true;
	}
	else if(document.feedbackform.TxtFormat.value=="PM")
	{
		if(document.feedbackform.txtTime.value!="" && document.feedbackform.txtTime.value> 6 && document.feedbackform.txtTime.value!=12) 
		{
			alert("Please enter time between 9am to 6pm");
			document.feedbackform.txtTime.focus();
			return false;
		}
	return true;
	}
}
function checkMin()
{
	if(document.feedbackform.txtMin.value!="" && document.feedbackform.txtMin.value> 59)
	{
		alert("Min should be less than 59");
		document.feedbackform.txtMin.focus();
		return false;
	}

}
function cal6()
{
if(document.feedbackform.TxtFormat.value=="PM" &&  document.feedbackform.txtTime.value==6)
	{
	if(document.feedbackform.txtMin.value> 0)
	{
		alert("Please enter time between 9am to 6pm");
		document.feedbackform.txtMin.focus();
		return false;
	}
	}
}
function checkNumeric()
{

	if(event.keyCode<=45 || event.keyCode>57)
    {
		event.returnValue=false

		}
}
function post_value(d){
	
var dt=new String(d);
var d1=dt.split("?");
var d2=d1[1];
	d2=d2.split("&");
var d3=d2[0];
var m1=d2[1];
var y1=d2[2];

var day=d3.split("=");
var mon=m1.split("=");
var year=y1.split("=");
	day=day[1];
	if(day<10) { day="0"+day; }
	mon=mon[1];
	if(mon<10) { mon="0"+mon; }
	year=year[1];

opener.document.feedbackform.date2.value =day+"/"+mon+"/"+year;
self.close();
}
