
function finalvalidchk(form) 
{
   var uname_1=form.uname_1.value;
   var email=form.email.value;

   var pass_1=form.pass_1.value;
   
   var passwordlength=form.pass_1.value.length;
   var confirmpassword=form.cpass.value;

  

   var mtype=form.mtype.value;

   

   var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;

   var passRegex=/^(\w(\s)?)+$/;

   
   
   
     if(uname_1=="")

	 {

	inlineMsg('uname_1','You Must Enter User Name.',2);  

	return false;

	 }
   
   
        

	 if(uname_1!="")

	 {

		 var usernameblank=form.uname_1.value.substring(0,1);

		 if(usernameblank == ' ')

		 {

	       inlineMsg('uname_1','First letter shouldnot blank in UserName.',2);  

	       return false;

		 }

	 }

	 

	 if(uname_1!="")

	 {

		  var assignvalid=form.assignvalid.value;

		 if(assignvalid == 1)

		 {

	       inlineMsg('uname_1','UserName Already Exist ! Try Other.',2);  

	       return false;

		 }

	 }

	 
   
   
   
     if(email=="")

	 {

	inlineMsg('email','You Must Enter Email Address.',2);

    return false;

	 }

	 if(!email.match(emailRegex)) 

	 {

        inlineMsg('email','You have entered an invalid Email.',2);

        return false;

     } 
   
   
   

	 

	 

	 if(pass_1=="")

	 {

		inlineMsg('pass_1','You Must Enter Password.',2);

        return false;

	 }

	 if(!pass_1.match(passRegex))

	 {

    inlineMsg('pass_1','You have entered an invalid Password.',2);

    return false;

     }

	  if(passwordlength<6)

	 {

	inlineMsg('pass_1','Password Should be maximum 6 characters',2);

    return false;

	 }

	  if(passwordlength>15)

	 {

	inlineMsg('pass_1','Password Should be minimum 15 characters',2);

    return false;

	 }

	 

	 if(confirmpassword=="")

	 {

	inlineMsg('cpass','You Must Enter Confirm Password.',2);

    return false;

	 }



	 if(pass_1 != confirmpassword)

	 {

	inlineMsg('cpass','Password and Confirm Password Should Be Same.',2);

    return false;

	 }

	 
	 if(mtype=="")

	 {

	inlineMsg('mtype','Select Member Type.',2);

    return false;

	 }

	


	 

}

function validateindex(form) 
{
	
	txt_offernum=form.txt_offernum.value;
	
	 if(txt_offernum=="")
	 {
	    inlineMsg('txt_offernum','You Must Enter Offer Number.',2);  
        return false;
     }
	 
	
	 if(txt_offernum!="")
	 {

		  var assignvalid=form.assignvalid.value;
		 if(assignvalid == 1)

		 {

	       inlineMsg('txt_offernum','OfferName Already Exist ! Try Other.',2);  

	       return false;

		 }

	 }

	
	
}

function validatestep1(form) 
{
	  var txt_offernum=form.txt_offernum.value;
      var make=form.make.value;
	  var Models_id=form.Models_id.value;
	  var derivative=form.derivative.value;
	  var der=form.der.value;
	   var fuel=form.fuel.value;
	  var registration=form.registration.value;
	  var doors=form.doors.value;
	  var transmission=form.transmission.value;
	  var body_color=form.body_color.value;
	  
	  if(txt_offernum=="")
	 {
	    inlineMsg('txt_offernum','You Must Enter Offer Number.',2);  
        return false;
     }
	  if(txt_offernum!="")
	 {

		  var assignvalid=form.assignvalid.value;

	 if(assignvalid == 1)

		 {

	       inlineMsg('txt_offernum','OfferName Already Exist ! Try Other.',2);  

	       return false;

		 }

	 }
	 
	  if(make=="")
	 {
	    inlineMsg('make','You Must Select Manufacturer.',2);  
        return false;
     }
	  if(Models_id=="")
	 {
	    inlineMsg('Models_id','You Must Select Model.',2);  
        return false;
     }
	 if(der=='1')
	 {
		 if(derivative=="")
		 {
			inlineMsg('derivative','You Must Enter Car Derivative.',2);  
			return false;
		 }
	 }
	 if(fuel=="0")
	 {
	    inlineMsg('fuel','You Must Select Fuel Type.',2);  
        return false;
     }
	  if(registration=="")
	 {
	    inlineMsg('registration','You Must Select  Registration Year.',2);  
        return false;
     }
	   if(doors=="")
	 {
	    inlineMsg('doors','You Must Enter  Doors ',2);  
        return false;
     }
	    if(transmission=="")
	 {
	    inlineMsg('transmission','You Must Select  Transmission Type ',2);  
        return false;
     }
	   if(body_color=="")
	 {
	    inlineMsg('body_color','You Must Enter  Body Color ',2);  
        return false;
     }
	document.getElementById('carPageDiv1').style.display='none';
	document.getElementById('carPageDiv2').style.display='block';
}

function validatestep2(form) 
{
	
	  var mileage=form.mileage.value;
      //var MOTvalid=form.MOTvalid.value;
	  //var Taxedvalid=form.Taxedvalid.value;
	  var carimport=form.carimport.value;
	  var v5_available=form.v5_available.value;
	  var owner=form.owner.value;
	  var history=form.history.value;
	  var finance=form.finance.value;
     
	 
	  
	
	
	  
	  if(mileage=="")
	 {
	    inlineMsg('mileage','You Must Enter Current  Mileage.',2);  
        return false;
     }
	 /* if(MOTvalid=="")
	 {
	    inlineMsg('MOTvalid','You Must Enter MOT Valid.',2);  
        return false;
     }
	  if(Taxedvalid=="")
	 {
	    inlineMsg('Taxedvalid','You Must Enter Taxed .',2);  
        return false;
     }*/
	 if(carimport=="")
	 {
	    inlineMsg('carimport','You Must Select Car Import.',2);  
        return false;
     }
	  if(v5_available=="")
	 {
	    inlineMsg('v5_available','You Must Select  V5/Log Book .',2);  
        return false;
     }
	   if(owner=="")
	 {
	    inlineMsg('owner','You Must Select Number of Owners.',2);  
        return false;
     }
	    if(history=="")
	 {
	    inlineMsg('history','You Must Select Service History. ',2);  
        return false;
     }
	   if(finance=="")
	 {
	    inlineMsg('finance','You Must Select Finance Outstanding. ',2);  
        return false;
     }

	document.getElementById('carPageDiv2').style.display='none';
	document.getElementById('carPageDiv3').style.display='block';
	
}

function hideValidation2()
{
	document.getElementById('carPageDiv2').style.display='none';
	document.getElementById('carPageDiv1').style.display='block';
}

function radio_clicked(val)
{
	document.add_product.radio_num.value=val;
}



function validatestep3(form) 
{
      var state=form.state.value;
	  var advs=form.advs.value;
	  var hid_member_type=document.getElementById('hid_member_type').value;
	  if(hid_member_type==2)
	  {
							  
				if(document.getElementById('car_dealer_status').value=="")
				{
				alert ("Kindly select the car Status")
				return false;
				}
				if(document.getElementById('car_dealer_price').value=="")
				{
				alert ("Kindly select the car Price")
				return false;
				}
				if(document.getElementById('car_dealer_price').selectedIndex=="1")
				{
						document.getElementById('open_price').style.display='block';
						if(document.getElementById('dealer_car_amt').value=="")
							{
							alert ("Kindly Enter the car Price")
							return false;
							}
				}
	  }
	  

	  if(document.getElementById('state1').checked==false && document.getElementById('state2').checked==false && document.getElementById('state3').checked==false && document.getElementById('state4').checked==false && document.getElementById('state5').checked==false && document.getElementById('state6').checked==false && document.getElementById('state7').checked==false && document.getElementById('state8').checked==false && document.getElementById('state9').checked==false && document.getElementById('state10').checked==false && document.getElementById('state11').checked==false && document.getElementById('state12').checked==false && document.getElementById('state13').checked==false && document.getElementById('state14').checked==false)
	{
	    inlineMsg('state1','You Must Select Atleast One State ',2);  
        return false;
	}
	
	document.getElementById('carPageDiv3').style.display='none';
	document.getElementById('carPageDiv4').style.display='block';
	  
}


function hideValidation3()
{
	document.getElementById('carPageDiv3').style.display='none';
	document.getElementById('carPageDiv2').style.display='block';
}

function hideValidation4()
{
	document.getElementById('carPageDiv4').style.display='none';
	document.getElementById('carPageDiv3').style.display='block';
}


function finalSubmit(pageValue)
{
if(pageValue==1)
	{
		document.getElementById('carPageDiv4').style.display='none';
		document.getElementById('carPageDiv5').style.display='block';
	}
	else
	{
document.getElementById('hdnAction').value=1;
document.getElementById('bttn').style.display='none';
document.getElementById('bttn2').style.display='block';
document.add_product.action='post_car.php';
document.add_product.submit();
	}
}

function validatestep4(form)
{
	
	var title=form.title.value;
	var first_contact=form.first_contact.value;
	var second_contact=form.second_contact.value;
	var email=form.email.value;
	var conformemail=form.conformemail.value;
	var telephone=form.telephone.value;
	var town=form.town.value;
	var private_username=form.private_username.value;
	var private_password=form.private_password.value;
	var passwordlength=form.private_password.value.length;
	
	 var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	 
	  var passRegex=/^(\w(\s)?)+$/;
	  
	  if(title=="")
	 {
	    inlineMsg('title','You Must Select Title.',2);  
        return false;
     }
	  if(first_contact=="")
	 {
	    inlineMsg('first_contact','You Must Enter ForeName.',2);  
        return false;
     }
	  if(second_contact=="")
	 {
	    inlineMsg('second_contact','You Must Enter SurName.',2);  
        return false;
     }
	  if(email=="")
	 {
	    inlineMsg('email','You Must Enter Email.',2);  
        return false;
     }
	  if(!email.match(emailRegex)) 
	 {

        inlineMsg('email','You have entered an invalid Email.',2);
        return false;
     } 
      if(conformemail=="")
	 {
    	inlineMsg('conformemail','You Must Enter Confirm Email.',2);
        return false;
	 }
	 if(email != conformemail)
    {
	   inlineMsg('conformemail','Email and Confirm Email Should Be Same.',2);
       return false;

	 }
	  if(telephone=="")
	 {
	    inlineMsg('telephone','You Must Enter Contact Number.',2);  
        return false;
     }
	  if(town=="")
	 {
	    inlineMsg('town','You Must Enter Post Town.',2);  
        return false;
     }
	   if(private_username=="")
	 {
	    inlineMsg('private_username','You Must Enter UserName.',2);  
        return false;
     }
	  if(private_username!="")
	 {

		 var private_usernameblank=form.private_username.value.substring(0,1);
		 if(private_usernameblank == ' ')
		 {
	       inlineMsg('private_username','First letter shouldnot blank in UserName.',2);  
	       return false;
		 }
	 }


	 if(private_username!="")
	 {
		  var assignvalid=form.assignvalid.value;
		 if(assignvalid == 1)
		 {
           inlineMsg('private_username','UserName Already Exist ! If you have Account,Please Login.',2);  
	       return false;
		 }
	 }
     
	  if(private_password=="")
	 {

		inlineMsg('private_password','You Must Enter Password.',2);
        return false;

	 }

	 if(!private_password.match(passRegex))
	 {
       inlineMsg('private_password','You have entered an invalid Password.',2);
       return false;
     }

	  if(passwordlength<6)
	 {
     	inlineMsg('private_password','Password Should be maximum 6 characters',2);
        return false;
	 }
	  if(passwordlength>15)
    {
    	inlineMsg('private_password','Password Should be minimum 15 characters',2);
       return false;
	 }


document.getElementById('bttn').style.display='none';
document.getElementById('bttn2').style.display='block';
document.getElementById('hdnAction').value=2;
document.add_product.action='post_car.php';
document.add_product.submit();
	
}


function hideValidation4()
{
	document.getElementById('carPageDiv4').style.display='none';
	document.getElementById('carPageDiv3').style.display='block';
}



function show_table(id)
{
	for(i=1;i<28;i++)
	{
		document.getElementById('t_'+i).style.display='none';
	}
	document.getElementById('t_'+id).style.display='block';
	
}
function show_hid(id1,id2)
{
	
	document.getElementById('no_dam').innerHTML='';
	document.getElementById('c_'+id1).style.display='block';
	document.getElementById('c_'+id1+'_text').innerHTML=id2;
}
function remove_cond(ids,cid,fid)
{
	for(i=1;i<ids;i++)
	{	
		var tr=fid+'_'+i;
		document.getElementById(tr).checked=false;
		
		
	}
	
	document.getElementById('c_'+cid).style.display='none';
	document.getElementById('c_'+cid+'_text').innerHTML='';

}





function validatedealerstep1(form)
{
	
	var company_type=form.company_type.value;
	var businessname=form.businessname.value;
	var address1=form.address1.value;
	var address2=form.address2.value;
	var post_town=form.post_town.value;
	var post_code=form.post_code.value;
	var website=form.website.value;
	var contact_person=form.contact_person.value;
	var position=form.position.value;
	var contact_number=form.contact_number.value;
	var email=form.email.value;
	var conformemail=form.conformemail.value;
	var dealerbid_username=form.dealerbid_username.value;
	var dealerbid_password=form.dealerbid_password.value;
	var dealerbid_cpassword=form.dealerbid_cpassword.value;
	var passwordlength=form.dealerbid_password.value.length;
	
	 var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	 
	 var passRegex=/^(\w(\s)?)+$/;
	 
	 
	 
	  if(company_type=="")
	 {
	    inlineMsg('company_type','You Must Select Company Type.',2);  
        return false;
     }
	  if(businessname=="")
	 {
	    inlineMsg('businessname','You Must Enter Business Name.',2);  
        return false;
     }
	  if(address1=="")
	 {
	    inlineMsg('address1','You Must Enter Address 1.',2);  
        return false;
     }
	  if(address2=="")
	 {
	    inlineMsg('address2','You Must Enter Address 2.',2);  
        return false;
     }
	  if(post_town=="")
	 {
	    inlineMsg('post_town','You Must Enter Post Town.',2);  
        return false;
     } 
	  if(post_code=="")
	 {
	    inlineMsg('post_code','You Must Enter Post Code.',2);  
        return false;
     } 
	 if(website=="")
	 {
	    inlineMsg('website','You Must Enter Website.',2);  
        return false;
     } 
	 if(contact_person=="")
	 {
	    inlineMsg('contact_person','You Must Enter Contact Person.',2);  
        return false;
     } 
	 if(position=="")
	 {
	    inlineMsg('position','You Must Enter Position.',2);  
        return false;
     } 
	 if(contact_number=="")
	 {
	    inlineMsg('contact_number','You Must Enter Contact Number.',2);  
        return false;
     } 
	 if(email=="")
	 {
	    inlineMsg('email','You Must Enter Email.',2);  
        return false;
     } 
	 if(!email.match(emailRegex)) 
	 {

        inlineMsg('email','You have entered an invalid Email.',2);
        return false;
     } 
      if(conformemail=="")
	 {
    	inlineMsg('conformemail','You Must Enter Confirm Email.',2);
        return false;
	 }
	 if(email != conformemail)
    {
	   inlineMsg('conformemail','Email and Confirm Email Should Be Same.',2);
       return false;

	 }
	   if(dealerbid_username=="")
	 {
	    inlineMsg('dealerbid_username','You Must Enter UserName.',2);  
        return false;
     }
	  if(dealerbid_username!="")
	 {

		 var dealerbid_usernameblank=form.dealerbid_username.value.substring(0,1);
		 if(dealerbid_usernameblank == ' ')
		 {
	       inlineMsg('dealerbid_username','First letter shouldnot blank in UserName.',2);  
	       return false;
		 }
	 }


	 if(dealerbid_username!="")
	 {
		  var assignvalid=form.assignvalid.value;
		 if(assignvalid == 1)
		 {
           inlineMsg('dealerbid_username','UserName Already Exist ! Try Other.',2);  
	       return false;
		 }
	 }
     
	  if(dealerbid_password=="")
	 {

		inlineMsg('dealerbid_password','You Must Enter Password.',2);
        return false;

	 }

	 if(!dealerbid_password.match(passRegex))
	 {
       inlineMsg('dealerbid_password','You have entered an invalid Password.',2);
       return false;
     }

	  if(passwordlength<6)
	 {
     	inlineMsg('dealerbid_password','Password Should be maximum 6 characters',2);
        return false;
	 }
	  if(passwordlength>15)
    {
    	inlineMsg('dealerbid_password','Password Should be minimum 15 characters',2);
       return false;
	 }
	 
	  if(dealerbid_cpassword=="")
	 {

		inlineMsg('dealerbid_cpassword','You Must Enter Conform Password.',2);
        return false;

	 }
	  
      if(dealerbid_password != dealerbid_cpassword)
    {
	   inlineMsg('dealerbid_cpassword','Email and Confirm Email Should Be Same.',2);
       return false;

	 }
	 
	 
	 
	 
	
}


function validatedealerstep5(form)
{
/*	var myOption=-1;
	var i;
	
	for (i=form.payment_way.length-1; i > -1; i--)
	 {

	    if (form.payment_way[i].checked) 
		{
             
	         myOption = i; i = -1;
	    }

	 }
	 if(myOption == -1)
	 {
		inlineMsg('radiomsg','You must Select Any one of Payment Gateway.',2);
	    return false;
	 }
	*/
	
   /*  if(document.getElementById('payment_way1').checked==true)
	{
	form.action="https://www.paypal.com/cgi-bin/webscr";
	}*/
	if(document.getElementById('payment_way2').checked==true)
	{	
		//form.deb_pay.value=1;
		//form.action="profile.php";
		form.action="https://www.snapdda.co.uk/clients/dealerbid/dealerbidsnapddasignup.aspx";
	}// JavaScript Document
	
	
}


function validatedealerstep3(form)
{
	/*var myOption=-1;
	var i;
	
	for (i=form.payment_way.length-1; i > -1; i--)
	 {

	    if (form.payment_way[i].checked) 
		{
             
	         myOption = i; i = -1;
	    }

	 }
	 if(myOption == -1)
	 {
		inlineMsg('radiomsg','You must Select Any one of Payment Gateway.',2);
	    return false;
	 }*/
	
	
}
function validatedealerstep4(form)
{
	
	var termsconditions=form.termsconditions.checked;
	
	if(termsconditions == false)
	{
		 inlineMsg('termsconditions','You Must Accept Term & Condition.',2);
	     return false;
	}
	
	
}



function validatefeedback(form)
{
	
	var name=form.name.value;
	var email=form.email.value;
	var phone=form.phone.value;
	var comments=form.comments.value;
	
	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	
	
	  if(name=="")
	 {
	    inlineMsg('name','Please ! Enter Name.',2);  
        return false;
     }
	  if(email=="")
	 {
	    inlineMsg('email','Please ! Enter Email.',2);  
        return false;
     }
	  if(!email.match(emailRegex)) 
	 {

        inlineMsg('email','You have entered an invalid Email.',2);
        return false;
     } 
	  if(phone=="")
	 {
	    inlineMsg('phone','Please ! Enter Phone Number.',2);  
        return false;
     }
	  if(comments=="")
	 {
	    inlineMsg('comments','Please ! Enter Your Valuable Comments.',2);  
        return false;
     }
	 
	
	
}


function validatecontactus(form)
{
	
	var name=form.name.value;
	var email=form.email.value;
	var phone=form.phone.value;
	var comments=form.comments.value;
	
	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	
	
	  if(name=="")
	 {
	    inlineMsg('name','Please ! Enter Name.',2);  
        return false;
     }
	  if(email=="")
	 {
	    inlineMsg('email','Please ! Enter Email.',2);  
        return false;
     }
	  if(!email.match(emailRegex)) 
	 {

        inlineMsg('email','You have entered an invalid Email.',2);
        return false;
     } 
	  if(phone=="")
	 {
	    inlineMsg('phone','Please ! Enter Phone Number.',2);  
        return false;
     }
	  if(comments=="")
	 {
	    inlineMsg('comments','Please ! Enter Your Valuable Comments.',2);  
        return false;
     }
	 
	
	
}

function validateforgotpassword(form)
{
	var email=form.keyword.value;
	  if(email=="")
	 {
	    alert('Please ! Enter the Email ID');  
        return false;
     }
	 document.login.action='forgotpassword.php';
	 document.login.submit();
	 
	 
}



function validatelogin(form)
{
	var username=form.username.value;
	var password=form.password.value;
	  if(username=="")
	 {
	    alert('Please ! Enter User Name.');  
        return false;
     }
	   if(password=="")
	 {
	    alert('Please ! Enter Password.');  
        return false;
     }
}

// START OF MESSAGE SCRIPT //



var MSGTIMER = 20;

var MSGSPEED = 5;

var MSGOFFSET = 3;

var MSGHIDE = 3;



// build out the divs, set attributes and call the fade function //

function inlineMsg(target,string,autohide) {

  var msg;

  

  var msgcontent;

  if(!document.getElementById('msg')) {

    msg = document.createElement('div');

    msg.id = 'msg';

    msgcontent = document.createElement('div');

    msgcontent.id = 'msgcontent';

    document.body.appendChild(msg);

    msg.appendChild(msgcontent);

    msg.style.filter = 'alpha(opacity=0)';

    msg.style.opacity = 0;

    msg.alpha = 0;

  } else {

    msg = document.getElementById('msg');

    msgcontent = document.getElementById('msgcontent');

  }

  msgcontent.innerHTML = string;

  msg.style.display = 'block';

  var msgheight = msg.offsetHeight;

  var targetdiv = document.getElementById(target);

  targetdiv.focus();

  var targetheight = targetdiv.offsetHeight;

  var targetwidth = targetdiv.offsetWidth;

  var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2);

  var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET;

  msg.style.top = topposition + 'px';

  msg.style.left = leftposition + 'px';

  clearInterval(msg.timer);

  msg.timer = setInterval("fadeMsg(1)", MSGTIMER);

  if(!autohide) {

    autohide = MSGHIDE;  

  }

  window.setTimeout("hideMsg()", (autohide * 1000));

}



// hide the form alert //

function hideMsg(msg) {

  var msg = document.getElementById('msg');

  if(!msg.timer) {

    msg.timer = setInterval("fadeMsg(0)", MSGTIMER);

  }

}



// face the message box //

function fadeMsg(flag) {

  if(flag == null) {

    flag = 1;

  }

  var msg = document.getElementById('msg');

  var value;

  if(flag == 1) {

    value = msg.alpha + MSGSPEED;

  } else {

    value = msg.alpha - MSGSPEED;

  }

  msg.alpha = value;

  msg.style.opacity = (value / 100);

  msg.style.filter = 'alpha(opacity=' + value + ')';

  if(value >= 99) {

    clearInterval(msg.timer);

    msg.timer = null;

  } else if(value <= 1) {

    msg.style.display = "none";

    clearInterval(msg.timer);

  }

}



// calculate the position of the element in relation to the left of the browser //

function leftPosition(target) {

  var left = 0;

  if(target.offsetParent) {

    while(1) {

      left += target.offsetLeft;

      if(!target.offsetParent) {

        break;

      }

      target = target.offsetParent;

    }

  } else if(target.x) {

    left += target.x;

  }

  return left;

}



// calculate the position of the element in relation to the top of the browser window //

function topPosition(target) {

  var top = 0;

  if(target.offsetParent) {

    while(1) {

      top += target.offsetTop;

      if(!target.offsetParent) {

        break;

      }

      target = target.offsetParent;

    }

  } else if(target.y) {

    top += target.y;

  }

  return top;

}



// preload the arrow //

if(document.images) {

	

  arrow = new Image(7,80); 

  arrow.src = "../images/msg_arrow.gif"; 

}

// JavaScript Document// JavaScript Document