﻿<!--
function checkForm(obj)

	{			
		var name1 = obj.name1.value;
		var day = obj.day.value;
		var month = obj.month.value;
		var year = obj.year.value;
		var contact = obj.contact.value;		
		var mobile = obj.mobile.value;	
		var address = obj.address.value;
		var modelno = obj.modelno.value;
		var backno = obj.backno.value;
		var code = obj.security_code.value;
		var theresult = obj.theresult.value;				
		
		var message ="Please complete the following \n\n";
		
		var cntr = 5;
		
	

	
if ( name1 =="" ) { message += "* Name \n"; bgON('q1');} else { bgOFF('q1');}		

// gender..		
if ( !isCheckedRadio(obj.sex) ) { message += "* Gender \n";  bgON('q2'); } else { bgOFF('q2'); }	


// birth date here..	
if (month == "" || year == "" || day=="" ){ 
bgON('q3'); message += "* Birth date  \n"; 
}else { 
		if ( isNotDigit(obj.year) || obj.year=="Year" || obj.year.value.length<4) {
			message += "* Invalid year of birth\n";
			bgON('q3');
		}else{
			bgOFF('q3');
		}										 
}

// educ..		
if ( !isCheckedRadio(obj.educ) ) { message += "* Education level \n";  bgON('q4'); } else { bgOFF('q4'); }	

// occu..		
if ( !isCheckedRadio(obj.occupation) ) { message += "* Occupation \n";  bgON('q5'); } else { bgOFF('q5'); }	


// contact..		
if ( contact =="" ) { message += "* Contact No. \n"; bgON('q6');} else { bgOFF('q6');}

// mobile..		
if ( mobile =="" ) { message += "* Mobile No. \n"; bgON('q7');} else { bgOFF('q7');}				

// address..		
if ( address =="" ) { message += "* Address \n"; bgON('q8');} else { bgOFF('q8');}
				
// modelno..		
if ( modelno =="" ) { message += "* Watch Model No. \n"; bgON('q9');} else { bgOFF('q9');}				

// backno..		
if ( backno =="" ) { message += "* Watch Case Back No. \n"; bgON('q10');} else { bgOFF('q10');}	


// first time..		
if ( !isCheckedRadio(obj.firstpur) ) { message += "* First time to purchase Vagary watch ? \n";  bgON('q11'); } else { bgOFF('q11'); }	

// purpose..		
if ( !isCheckedRadio(obj.purposepur) ) { message += "* Purpose to purchase Vagary watch ? \n";  bgON('q12'); } else { bgOFF('q12'); }	


// Q13 checking..			
	//loop for reason 
		for (i=1; i<=17; i++){				
			var have_reason =0;
	  		obj13 = eval('obj13=obj.reason_' + i +'.checked');			
			if (obj13==true){ have_reason++; break;} }
	//end loop		
		
		if (have_reason==0) { 
		message += "* Reason for purchasing ?  \n"; bgON('q13') }		
		else { 
		bgOFF('q13');}																		
// reason Q13			


// Q14 checking..			
	//loop for channel 
		for (i=1; i<=9; i++){				
			var have_channel =0;
	  		obj14 = eval('obj14=obj.channel_' + i +'.checked');			
			if (obj14==true){ have_channel++; break;} }
	//end loop		
		
		if (have_channel==0) { 
		message += "* Channel received information from ?  \n";  bgON('q14') } 
		else { 
		bgOFF('q14');}																		
// channel Q14		


// Q15 checking..			
	//loop for brand 
		for (i=1; i<=11; i++){				
			var have_brand =0;
	  		obj15 = eval('obj15=obj.brand_' + i +'.checked');			
			if (obj15==true){ have_brand++; break;} }
	//end loop		
		
		if (have_brand==0) { 
		message += "* Other brand consider to purchase ?  \n"; bgON('q15') } 
		else { 
		bgOFF('q15');}																		
// brand Q15	


// Q16 Purchase again..		
if ( !isCheckedRadio(obj.puragain) ) { message += "* Consider to purchase Vagary watch again ? \n"; bgON('q16'); } else { bgOFF('q16'); }	




if (code!=theresult){
message +="* Invalid indentification code \n";
bgON('q17');
}else { bgOFF('q17');}

if (message!="Please complete the following \n\n"){
alert(message);
return false;
}else{
return true;
}


}


function loadCode(){
checkcode();
}


///////// CHECK CODE
var url = "checkCode.php?code="; // The server-side script 
function handleHttpResponse() {
 if (http.readyState == 4) { 
        if(http.status==200) { 		
              var results=http.responseText; 					
			  
			  newresults = results.replace(/^\s*|\s*$/,"");
			  
			  document.getElementById("theresult").value=newresults;
			  		  																											
																								
																											
			  } 
           } 
        }         
		
				
        function checkcode() {      
            var sId = document.getElementById("sec_code").value; 
            http.open("GET", url + escape(sId), true); 
            http.onreadystatechange = handleHttpResponse; 

            http.send(null); 
        } 
function getHTTPObject() { 
  var xmlhttp; 

  if(window.XMLHttpRequest){ 
    xmlhttp = new XMLHttpRequest(); 
  } 
  else if (window.ActiveXObject){ 
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
    if (!xmlhttp){ 
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
    } 
    
} 
  return xmlhttp; 
  
  
} 
var http = getHTTPObject(); // We create the HTTP Object 



function clearYear(){
document.getElementById("year").value="";
}


function othersEduc(){ 
	for (i=1; i<=5; i++){
	document.getElementById("educ_"+i).checked=false;				
	}
	document.getElementById("educ_6").checked=true;	
				
}

function othersOccu(){ 
	for (i=1; i<=5; i++){
	document.getElementById("occu_"+i).checked=false;				
	}
	document.getElementById("occu_5").checked=true;	
				
}

function othersQ16(){ 
				document.getElementById("puragain_3").checked=true;				
				document.getElementById("puragain_1").checked=false;
				document.getElementById("puragain_2").checked=false;	
				}


// Function for REASONS 3 maximum answers only !

function othersReason(){ document.getElementById("reason_17").checked=true;				
				reason17 = document.getElementById("reason_17");	
				checkCountReason(reason17);
				}


function checkCountReason(thisId){		

		var have_reason =0;
		for (i=1; i<=17; i++){										  		
			obj13 =document.getElementById("reason_"+i).checked;							
			if (obj13==true){ 		
				if (have_reason <3){
					have_reason++;						
				}else{
					alert("You have already choosen 3,\n deselect one to change.");					
					thisId.checked=false;
				}
					
			}
										
		}								
}



// Function for CHANNEL 3 maximum answers only !

function othersChannel(){ document.getElementById("channel_9").checked=true;				
				channel9 = document.getElementById("channel_9");	
				checkCountChannel(channel9);
				}


function checkCountChannel(thisId){		

		var have_channel =0;
		for (i=1; i<=9; i++){										  		
			obj14 =document.getElementById("channel_"+i).checked;							
			if (obj14==true){ 		
				if (have_channel <3){
					have_channel++;						
				}else{
					alert("You have already choosen 3,\n deselect one to change.");
					thisId.checked=false;
				}
					
			}
										
		}								
}


// Function for BRAND 3 maximum answers only !

function othersBrand(){ document.getElementById("brand_11").checked=true;				
				brand11 = document.getElementById("brand_11");	
				checkCountBrand(brand11);
				}

function checkCountBrand(thisId){		

		var have_brand =0;
		for (i=1; i<=11; i++){										  		
			obj15 =document.getElementById("brand_"+i).checked;							
			if (obj15==true){ 		
				if (have_brand <3){
					have_brand++;						
				}else{
					alert("You have already choosen 3,\n deselect one to change.");
					thisId.checked=false;
				}
					
			}
										
		}								
}



function bgON(trid){
   document.getElementById(trid).style.backgroundColor='#efefef';
}
function bgOFF(trid){
  document.getElementById(trid).style.backgroundColor='#ffffff';
}


function isCheckedRadio(obj) {
	var isCheck = false;
	if (obj.length) {
		for (i=0;i<obj.length;i++) {
			if (obj[i].checked) {
				isCheck = true;
			}
		}
	} else {
		if (obj.checked) {
			isCheck = true;
		}
	}

	if (!isCheck) {
		return false;
	}
	return true;
}
	

function isNotDigit(obj) {
		return isNaN(obj.value);
}


function isSelectedPullDown(obj) {
		if ( trim(obj.options[obj.selectedIndex].value) == "" ) {
			return false;
		}
		return true;
}

//-->
