function changediv(register_popup,user_login_question)
{
enterLeads(register_popup);
enterLeads(user_login_question);
}

function opendiv(register_popup,user_login_question)
{
enterLeads(user_login_question);
enterLeads(register_popup);
}

function submitinsertquestionform(userinformation,pop_dialog_question,user_login_question,contextpath)
	{
		if(document.getElementById("m_ques").value.length==0 || document.getElementById("m_ques").value==" ") {
			alert("Please Enter Your Question ");
			return false;
		  }
		if(document.getElementById("m_categoryC").value.length==0 || document.getElementById("m_categoryC").value==" ") {
			alert("Please Select categories for Question ");
			return false;
		  }
		if( userinformation=="") {
			enterLeads(pop_dialog_question)
			enterLeads(user_login_question)
		  }
		if(userinformation!="") {
     	var mques=document.getElementById("m_ques").value;
	    var mcategoryCode=document.getElementById("m_categoryC").value;
	    userquestionSubmitHelper.leadSubmit(mques,mcategoryCode,contextpath)
	    alert("successfully add your question");
	    enterLeads(pop_dialog_question);
		  }
}

function registerforquestion(contextpath)
{
	var re10digit=/^\d{10}$/;
    var re11digit=/^\d{11}$/;
    var re6digit=/^\d{6}$/;
    var emailFilter=/^.+@.+\..{2,6}$/;
    var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
    var passFilter = /^[a-zA-Z]\w{3,14}$/ ;
		var firstName=document.getElementById("firstName").value;
		var lastName=document.getElementById("lastName").value;
		var emailId=document.getElementById("emailIdforregistration").value;
		var passWord=document.getElementById("passWord").value;
		var phoneNo=document.getElementById("phoneNo").value;
		var errorString="";
		if(firstName.length==0) {
			errorString=errorString+ "** firstName: Please enter a firstName.**<br>" ;
			}
		if(lastName.length==0)	{
			errorString=errorString+ "** lastName: Please enter a lastName.**<br>" ;
			}
		if(emailId.length==0){
			errorString = errorString+'** Mail Id is a mandatory Field **<br>';
			}
		else if(!(emailFilter.test(emailId))||(emailId.match(illegalChars))) {
       errorString= '** <b>Invalid EMAIL address</b>:please enter a valid ID **<br>';
	    }
		if(passWord.length==0) {
			errorString=errorString+ "** passWord: Please enter a Password.**<br>" ;
			}
		if(phoneNo.length==0) {
			errorString = errorString+'** Phone is a mandatory Field **<br>';
	    }
		else if((phoneNo.search(re10digit)==-1)&&(phoneNo.search(re11digit)==-1)) {
			errorString  = '** Phone no should be 10 or 11 digit long if you are using landline please give the STD code. **<br>';
	    }

		if(errorString.length>1) {
			var error=document.getElementById("registerpopuperror");
			error.style.display = 'block';
			error.innerHTML=errorString;
		  return false;
			}

     userregisterSubmitHelper.leadSubmit(firstName,lastName,emailId,passWord,phoneNo,1,contextpath);
}

function loginforquestion(contextPath)
{
		var usedcaremailId=document.getElementById("email-id").value;
		var password=document.getElementById("password").value;
		var errorString="";
		if( document.getElementById("email-id").value=="") {
			errorString="<br>* Enter Your emailid ";
			}
		if(document.getElementById("password").value=="") {
			errorString=errorString+"<br/>* Enter Password";
			}

		if(errorString.length>1) {
			var error=document.getElementById("loginpopuperror");
			error.style.display = 'block';
			error.innerHTML=errorString;
		  return false;
			}
     //2 for login
    userregisterSubmitHelper.leadSubmit(null,null,usedcaremailId,password,null,2,contextPath);
}

RegisterSubmitForQuestion = function(){}
RegisterSubmitForQuestion.createInstance = function( doc, dynamicProperties ) {
	if( doc != null )
	{
		var helper = new RegisterSubmitForQuestion();
		return helper;
	}
	return null;
}

var self_ptr_sms_register=null;
var Flag=null;
var contextpath=null;
RegisterSubmitForQuestion.prototype.leadSubmit=function(firstName,lastName,emailId,passWord,phoneNo,flag,contextPath)
{
contextpath=contextPath;
Flag=flag;
if(Flag==1) {
	var registerflagdefault="register";
  var params = "firstName=" + firstName + "&lastName="  + lastName + "&emailId="  + emailId+ "&passWord="  + passWord+ "&mobileNo="  + phoneNo +"&registerflag=" +registerflagdefault;

  if(window.XMLHttpRequest)
    this.sendsmsvar = new XMLHttpRequest();
  else
 	 this.sendsmsvar = new ActiveXObject("MSXML2.XMLHTTP");
  var url = contextPath + "/caruserregister.do";
  this.sendsmsvar.onreadystatechange = this.SendFriendCallBack;
  this.sendsmsvar.open( "POST", url,true );
  this.sendsmsvar.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	this.sendsmsvar.setRequestHeader("Content-length", params.length);
	this.sendsmsvar.setRequestHeader("Connection", "close");
  self_ptr_sms_register = this;
  this.sendsmsvar.send(params);
  }
else {
  var login="loginflag";
  var params = "emailid=" + emailId + "&password="  + passWord +"&loginflag=" +login;
  if(window.XMLHttpRequest)
    this.sendsmsvar = new XMLHttpRequest();
  else
 	 this.sendsmsvar = new ActiveXObject("MSXML2.XMLHTTP");
  var url = contextPath + "/manageadminmodule.do";
  this.sendsmsvar.onreadystatechange = this.SendFriendCallBack;
  this.sendsmsvar.open( "POST", url,true );
  this.sendsmsvar.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	this.sendsmsvar.setRequestHeader("Content-length", params.length);
	this.sendsmsvar.setRequestHeader("Connection", "close");
  self_ptr_sms_register = this;
  this.sendsmsvar.send(params);
  }
}

RegisterSubmitForQuestion.prototype.SendFriendCallBack=function()
{
  if(self_ptr_sms_register)
  {
    var ajaxvar = self_ptr_sms_register.sendsmsvar;
    if(ajaxvar.readyState == 4)
    {
      if(ajaxvar.status == 200)
      {
        var responsetext = ajaxvar.responseText;
           	self_ptr_sms_register.setLeadSubmitResponse(responsetext);
      }
    }
  }
}
/**
 * Sets the Email response box with the passed message
 * @param textToSet The message which is to be set in the Email response box
 */
RegisterSubmitForQuestion.prototype.setLeadSubmitResponse=function(textToSet)
{
if(Flag==1) {
	if(textToSet=="This Email id already exist.\r\n") {
	  var error=document.getElementById("registerpopuperrorforajx");
	  document.getElementById("registerpopuperror").style.display = 'none';
	  error.style.display = 'block';
	  error.innerHTML=textToSet;
	  }
	else {
  	var mques=document.getElementById("m_ques").value;
	  var mcategoryCode=document.getElementById("m_categoryC").value;
	  userquestionSubmitHelper.leadSubmit(mques,mcategoryCode,contextpath)
	  alert("successfully add your question");
	  enterLeads('register_popup');
	  return null;
	  }
  }
else {
	if(textToSet=='Wrong EmailId and Password\r\n') {
  	var error=document.getElementById("loginpopuperror");
	  error.style.display = 'block';
	  error.innerHTML=textToSet;
  	}
	else {
  	var mques=document.getElementById("m_ques").value;
	  var mcategoryCode=document.getElementById("m_categoryC").value;
	  userquestionSubmitHelper.leadSubmit(mques,mcategoryCode,contextpath)
	  alert("successfully add your question");
	  enterLeads('user_login_question');
	  return null;
  	}
  }
}

QuestionSubmitForQuestion = function(){ }
QuestionSubmitForQuestion.createInstance = function( doc, dynamicProperties )
{
	if( doc != null )
	{
		var helper = new QuestionSubmitForQuestion();
		return helper;
	}
	return null;
}
var self_ptr_sms_question=null;
QuestionSubmitForQuestion.prototype.leadSubmit=function(mques,mcategoryCode,contextPath)
{
  var params = "m_question=" + mques + "&m_categoryCode="  + mcategoryCode ;
  if(window.XMLHttpRequest)
    this.sendsmsvar = new XMLHttpRequest();
  else
 	 this.sendsmsvar = new ActiveXObject("MSXML2.XMLHTTP");
  var url = contextPath + "/insertaskquestion.do?insert=insertquestion";
  this.sendsmsvar.onreadystatechange = this.SendFriendCallBack;
  this.sendsmsvar.open( "POST", url,true );
  this.sendsmsvar.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	this.sendsmsvar.setRequestHeader("Content-length", params.length);
	this.sendsmsvar.setRequestHeader("Connection", "close");
  self_ptr_sms_question = this;
  this.sendsmsvar.send(params);
}
QuestionSubmitForQuestion.prototype.SendFriendCallBack=function()
{
  if(self_ptr_sms_question)
  {
    var ajaxvar = self_ptr_sms_question.sendsmsvar;
    if(ajaxvar.readyState == 4)
    {
      if(ajaxvar.status == 200)
      {
        var responsetext = ajaxvar.responseText;
           	self_ptr_sms_question.setLeadSubmitResponse(responsetext);
      }
    }
  }
}
/**
 * Sets the Email response box with the passed message
 * @param textToSet The message which is to be set in the Email response box
 */
QuestionSubmitForQuestion.prototype.setLeadSubmitResponse=function(textToSet) { }


function hideexpertreview()
{
  document.getElementById("expertdiv").style.display = 'none';
}

function showfullreview()
{
document.getElementById("expertdiv").style.display = 'block';
document.getElementById("hiding").style.display = 'none';
document.getElementById("toggle-review").style.overflow = 'none';
document.getElementById("toggle-review").style.height = 'auto';
}

function collapse()
{
document.getElementById("expertdiv").style.display = 'none';
document.getElementById("hiding").style.display = 'block';
document.getElementById("toggle-review").style.overflow = 'hidden';
document.getElementById("toggle-review").style.height = '70px';
}

function makeUrlForCity(searchId){
				if(document.getElementById("city").selectedIndex==0){
					return false;
				}
				var city=document.getElementById("city")[document.getElementById("city").selectedIndex].text;				
				if(searchId!='' && searchId!="details" && searchId!="overview" && searchId!="colors" && searchId!="specs" && searchId!="features" && searchId!="dimension"){
					var carName=document.getElementById("carName").value;					
					var urlstr="carmodels/" + removeSpaces(searchId) + "/" + removeSpaces(carName);					
				}
				else
				{
					var carVariantId=document.getElementById("carVariantId").value;
					var modelName=document.getElementById("modelName").value;
					if(searchId=="details")
					  var urlstr= "details/" + removeSpaces(carVariantId);
					else if(searchId=="overview")
					var urlstr= "overview/" + removeSpaces(modelName) + "/"  + removeSpaces(carVariantId)+".htm";

					else if(searchId=="colors")
					var urlstr= "colors/" + removeSpaces(modelName) + "/"  + removeSpaces(carVariantId)+"-colors.htm";

					else if(searchId=="specs")
					var urlstr= "specs/" + removeSpaces(modelName) + "/"  + removeSpaces(carVariantId)+"-specification.htm";

					else if(searchId=="features")
					var urlstr= "features/" + removeSpaces(modelName) + "/"  + removeSpaces(carVariantId)+"-features.htm";

					else if(searchId=="dimension")
					var urlstr= "dimension/" + removeSpaces(modelName) + "/"  + removeSpaces(carVariantId)+"-dimension.htm";
					else					
				  		return false;
				}		  
					document.getElementById("getPrice").action=urlstr;
					document.getElementById("getPrice").submit();
}

