function validateQuestion(){
	var isValid = true;	
	isFieldFocusSet = false;
	if(isEmptyValue("name")){xAlert('Please enter name','question_name'); isValid=false;}	
	else {xAlert('','question_name');}
	if(isEmptyValue("emailId")){xAlert('Please enter email','question_email'); isValid=false;}	
	else {xAlert('','question_email');}	
	if(!emailCheck("emailId")){xAlert('Please enter valid email ','question_email');
		if(isFieldFocusSet != true){
	  		document.getElementById("emailId").focus();
	  		}
	  	isValid=false;}	
	else {xAlert('','question_email');}	
	if(isEmptyValue("company")){xAlert('Please enter company name','question_company'); isValid=false;}	
	else {xAlert('','question_company');}	
	if(isEmptyValue("designation")){xAlert('Please enter designation','question_designation'); isValid=false;}	
	else {xAlert('','question_designation');}	
	if(document.getElementById("sourceId").selectedIndex==0){
		xAlert('Please select how do you know about us','question_SourceId');document.getElementById("sourceId").focus();isValid=false;
	}else if((document.getElementById("sourceId").options[document.getElementById("sourceId").selectedIndex].text).toUpperCase()=="OTHER"){
		if(isEmptyValue("source")){xAlert('Please specify the source','question_SourceId'); isValid=false;}	
		else {xAlert('','question_SourceId');}		
	}else{
		xAlert('','question_SourceId');
	}
	if(isEmptyValue("question")){xAlert('Please enter question','question_question'); isValid=false;}	
	else {
		if((document.getElementById("question").value).length>1000){
			xAlert('Question could not exceed 1000 letters','question_question'); isValid=false;
		}else{xAlert('','question_question');}
	}	
	return isValid;	
}
function validateQuestionFromMail(){
	var isValid = true;	
	isFieldFocusSet = false;
	if(isEmptyValue("name")){xAlert('Please enter name','question_name'); isValid=false;}	
	else {xAlert('','question_name');}
	if(isEmptyValue("emailId")){xAlert('Please enter email','question_email'); isValid=false;}	
	else {xAlert('','question_email');}	
	if(!emailCheck("emailId")){xAlert('Please enter valid email ','question_email');
		if(isFieldFocusSet != true){
	  		document.getElementById("emailId").focus();
	  		}
	  	isValid=false;}	
	else {xAlert('','question_email');}	
	if(isEmptyValue("company")){xAlert('Please enter company name','question_company'); isValid=false;}	
	else {xAlert('','question_company');}	
	if(isEmptyValue("designation")){xAlert('Please enter designation','question_designation'); isValid=false;}	
	else {xAlert('','question_designation');}	
	if(isEmptyValue("question")){xAlert('Please enter question','question_question'); isValid=false;}	
	else {
		if((document.getElementById("question").value).length>1000){
			xAlert('Question could not exceed 1000 letters','question_question'); isValid=false;
		}else{xAlert('','question_question');}
	}	
	return isValid;	
}
function validateAdminQuestionForm()
{
	var isValid = true;	
	isFieldFocusSet = false;
	if(isEmptyValue("fromDate")){xAlert('Please select from date','question_fromDate'); isValid=false;}	
	else {xAlert('','question_fromDate');
	}	
	if(isEmptyValue("toDate")){xAlert('Please slecet to date','question_toDate'); isValid=false;}	
	else {xAlert('','question_toDate');
	}	
	 return isValid;
}
/*
	Method to check whether the given field value is empty
	If true, then triggers for inline error message and set the field focus if not already the focus is set for some other field
	in the same form.
*/
function isEmptyValue(fieldName){
	var fieldRef = document.getElementById(fieldName);
	if(fieldRef == null)
	  return true;
	var value = fieldRef.value;
	if (value == null || value == '' || value.trim() == '' || value.trim() == '<br>')
	{
		if(!isFieldFocusSet){fieldRef.focus();isFieldFocusSet = true;};
		return true;
	}
	return false;
}
/*
	xAlert function to display validation error msgs inline
	msg - repsresents the error message to be displayed
	divId - represents the error message div field id.
*/
function xAlert(msg, divId) 
	{
	var divObj = document.getElementById(divId);
	if(divObj != undefined) 
	{
		divObj.style.display='';

		if(msg!="")
		{
		divObj.innerHTML ="<div style='float: left;clear: right;padding-top: 3px;'><img width='17px' height='17px' src='http://www.pacificcresttrans.com/images/errorAlert.gif'></div><div style='float: left;clear: none;padding-top: 4px;'>"+msg+"</div>";
		}else
		{
		divObj.innerHTML =msg;
		}
	}
}
function emailCheck(fieldName){
	var inputvalue = document.getElementById(fieldName).value;	
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue)){ 
		return true; 
    }else{   
		return false; 
    }
}
function restrictText(event,value,errorDiv){
	key = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if(key==8 || key == 46 || key == 37){
		if(trim(value).length<=999)
			xAlert('',errorDiv);
		return true;
	}
	if(value.length>999){
		xAlert('Should not exceed 1000 characters',errorDiv);
		return false;
	}else{
		xAlert('',errorDiv);
		return true;
	}
}

function hideUnhideOtherSource(ctrl){
	var w = ctrl.selectedIndex;
	var selected_text = ctrl.options[w].text;
 	if(selected_text.toUpperCase() == 'OTHER'){
 		document.getElementById("otherSource").style.display='block';
// 		document.getElementById("otherSource1").style.display='block';
 	}else{
 		document.getElementById("otherSource").style.display='none';
// 		document.getElementById("otherSource1").style.display='none';
 	}
}
function hideUnhideOtherSource1(ctrl){
	var w = ctrl.selectedIndex;
	var selected_text = ctrl.options[w].text;
 	if(selected_text.toUpperCase() == 'OTHER'){
 		document.getElementById("otherSource").style.display='block';
 		document.getElementById("caption").style.display='block';
 	}else{
 		document.getElementById("otherSource").style.display='none';
 		document.getElementById("caption").style.display='none';
 	}
}
