var submitRequired = 'false';

function openwindw(obj,properties){
	window.open(obj.href,'',properties,false);
	return false;
}
function curbAppeal(){
	var sidingchk = false;
 	var otherschk =false;
 	var checkservice ;	
 	var siding = false;
 	var gutters = false;
 	var productchk = false;
 	serviceValue = document.getElementById('service').value;

	if(serviceValue == "HOME_EXTERIOR_GROUP"){
		if(document.getElementById('DIVPC').className == 'tshow'){
		
			document.form.submit();
			document.getElementById('submitBtn').className = 'thide';
			document.getElementById('processing').className = 'tshow';
			
		}else{
		
			for(ps=0;ps<document.form.ProductService.length;ps++){
					if(document.form.ProductService[ps].checked){
						productchk = true;
					}
			}
			for(i=0;i<document.form.ProductService.length;i++){
		
				   if(document.form.ProductService[i].checked && document.form.ProductService[i].value == 'SIDING'){
				   
						for(var st=0;st<document.form.SidingType.length;st++)
						{
							if(document.form.SidingType[st].checked){sidingchk = true;}
						}
					}
					if(document.form.ProductService[i].checked && document.form.ProductService[i].value == 'Other'){
						
						if(document.form.OtherServiceList.value == -1){otherschk = true;}
						else if(document.form.OtherServiceList.value != -1){
						
							if(document.form.OtherServiceList.value == "GUTTERS"){
								
								for(var gi=0;gi<document.form.GuttersInterest.length;gi++)
								{
									if(document.form.GuttersInterest[gi].checked){otherschk = true;}
								}
							}else
							{
								otherschk = true;
							}
						}	
					}
					
					if(document.form.ProductService[i].value == 'SIDING')
						siding = (document.form.ProductService[i].checked);
					if(document.form.ProductService[i].value == 'Other')
						gutters = (document.form.ProductService[i].checked);
				
				}	// for		
					
					if((!sidingchk && siding) || (!otherschk && gutters) ){
						if(!sidingchk && siding){					
							document.getElementById('ErrorSidingType').className = 'tshow' ;
						}else if(siding){	
							document.getElementById('ErrorSidingType').className = 'thide' ;	
						}
						
						if(!otherschk && gutters){
							document.getElementById('ErrorGuttersInterest').className = 'tshow' ;
						}else if(gutters){	
							document.getElementById('ErrorGuttersInterest').className = 'thide' ;
						}	
						return false;
					}
					 else if(!productchk){
						if(!productchk ){
							document.getElementById('ErrorProductService').className = 'tshow' ;
						}else{	
							document.getElementById('ErrorProductService').className = 'thide' ;
						}					
						return false;
					
					}
					else{
						document.getElementById('DIVPC').className = 'tshow';
						document.getElementById('DIVOwnHome').className = 'tshow';
						document.getElementById('DIVBuyTimeframe').className = 'tshow';	 
						document.getElementById('ext_prompt').className='thide';
						document.getElementById('ext_html').className='thide'; 
						document.getElementById('Exterior_OtherServices').className='thide';
						document.getElementById('DIVSidingType').className='thide';
						document.getElementById('DIVGuttersInterest').className='thide';
						document.getElementById('DIVGuttersInterest').className='thide';
						if(document.getElementById('ErrorSidingType')!=null)
							document.getElementById('ErrorSidingType').className = 'thide' ;	
						if(document.getElementById('ErrorGuttersInterest')!=null)
							document.getElementById('ErrorGuttersInterest').className = 'thide' ;
						return false;
					}
			return false;
		}// else	
		
	}	
	
	if(serviceValue == "KITCHEN_REMODELING"){

		var kitchenFalg = false;
		var productServiceFlag = false;
		if(document.getElementById('DIVPC').className == 'tshow'){
			document.form.submit();
			document.getElementById('submitBtn').className = 'thide';
			document.getElementById('processing').className = 'tshow';
		}else{

			for(kr=0;kr<document.form.ProductService.length;kr++){
				if(document.form.ProductService[kr].checked){
					if(document.form.ProductService[kr].value == 'KITCHEN_REMODELING')
					{	kitchenFalg = true;	
					}
					else if(document.form.ProductService[kr].value == 'CABINET_REFACING'){
								kitchenFalg = true;	
					}
					else if(document.form.ProductService[kr].value == 'FULL_KITCHEN_REMODELING'){
						for(fkr=0;fkr<document.form.OptIn.length;fkr++){

							if(document.form.OptIn[fkr].checked){
								kitchenFalg = true;	
							}
						}	

					}
						
				}								
			}
			
			if(kitchenFalg)
			{
			  	document.getElementById('DIVPC').className = 'tshow';
				document.getElementById('DIVOwnHome').className = 'tshow';
				document.getElementById('DIVBuyTimeframe').className = 'tshow';	 
				document.getElementById('DIVOptIn').className = 'thide';
//				document.getElementById('DIVInterestInCabinets').className = 'thide';
				document.getElementById('DIVProductService').className = 'thide';
//				document.getElementById('ERRORInterestInCabinets').className = 'thide';	
				document.getElementById('ERRORProductService').className = 'thide';	
				document.getElementById('ERROROptIn').className = 'thide';		 				
			}else{

				for(chkKR=0;chkKR<document.form.ProductService.length;chkKR++){
					
					if(document.form.ProductService[chkKR].checked){
						
						if(document.form.ProductService[chkKR].value == 'KITCHEN_REMODELING'){
							productServiceFlag = true;
							document.getElementById('ERRORProductService').className = 'tshow';	
							
						}
//						else if(document.form.ProductService[chkKR].value == 'CABINET_REFACING'){
//							productServiceFlag = true;
//							document.getElementById('ERRORInterestInCabinets').className = 'tshow';	
//							document.getElementById('ERRORProductService').className = 'thide';
							
//						}
						else if(document.form.ProductService[chkKR].value == 'FULL_KITCHEN_REMODELING'){
							productServiceFlag = true;
							document.getElementById('ERROROptIn').className = 'tshow';	
							document.getElementById('ERRORProductService').className = 'thide';
						
						}
					}else
					{
						if(!productServiceFlag)
						document.getElementById('ERRORProductService').className = 'tshow';	
					}		
				}
				return false;
			}
			return false;
		}
	}
}
	function showOtherServices(thisObj){
		if(document.getElementById('ErrorProductService') != null)
			document.getElementById('ErrorProductService').className = 'thide' ;
					

		if(thisObj != null && (thisObj.value).indexOf('Other') > -1){
		
			if(thisObj.checked){
				document.getElementById('Exterior_OtherServices').className='tshow';
				if(document.form.OtherServiceList != null && document.form.OtherServiceList.value == 'GUTTERS'){
					document.getElementById('DIVGuttersInterest').className='tshow';
					if(document.getElementById('ErrorGuttersInterest') != null) 
						document.getElementById('ErrorGuttersInterest').className = 'thide' ;					
					if(document.form.GuttersInterest == null || document.form.GuttersInterest.value == "")
						document.getElementById('ErrorGuttersInterest').className='thide'
				}else{
					document.getElementById('DIVGuttersInterest').className='thide';	
					document.getElementById('ErrorGuttersInterest').className='thide'				
				}
				
			}else{
				document.getElementById('Exterior_OtherServices').className='thide';
				document.getElementById('DIVGuttersInterest').className='thide'; 	
																
			}
		}
		if(thisObj != null && (thisObj.value).indexOf('SIDING') > -1){
		
			if(document.getElementById('ErrorSidingType') != null)
				document.getElementById('ErrorSidingType').className = 'thide' ;
			
			if(thisObj.checked){
				document.getElementById('DIVSidingType').className='tshow';
			}
			else{
				document.getElementById('DIVSidingType').className='thide';

			}

		}

		
		if(thisObj != null && (thisObj.value).indexOf('FULL_KITCHEN_REMODELING') > -1){ 
			if(document.getElementById('ERRORProductService') != null) 
				document.getElementById('ERRORProductService').className = 'thide';
			if(document.getElementById('ERROROptIn') != null) 
				document.getElementById('ERROROptIn').className = 'thide' ;
//			if(document.getElementById('ERRORInterestInCabinets') != null)
//				document.getElementById('ERRORInterestInCabinets').className = 'thide' ;				
			
			if(thisObj.checked){
				document.getElementById('DIVOptIn').className='tshow';
			}
			else{
				document.getElementById('DIVOptIn').className='thide';

			}
//			if(document.getElementById('DIVInterestInCabinets') != null) 
//				document.getElementById('DIVInterestInCabinets').className='thide';
		}
		
		if(thisObj != null && (thisObj.value).indexOf('CABINET_REFACING') > -1){
			if(document.getElementById('ERRORProductService') != null) 
				document.getElementById('ERRORProductService').className = 'thide';
			if(document.getElementById('ERROROptIn') != null) 
				document.getElementById('ERROROptIn').className = 'thide' ;
			if(document.getElementById('DIVOptIn') != null) 
				document.getElementById('DIVOptIn').className='thide';	

		} 
	
		if((thisObj != null) && ((thisObj.value)== ('KITCHEN_REMODELING'))) {
			
			if(document.getElementById('ERRORProductService') != null) 
				document.getElementById('ERRORProductService').className = 'thide';
			if(document.getElementById('ERROROptIn') != null) 
				document.getElementById('ERROROptIn').className = 'thide' ;
/*			if(document.getElementById('ERRORInterestInCabinets') != null)
				document.getElementById('ERRORInterestInCabinets').className = 'thide' ;	
			
			if(document.getElementById('DIVInterestInCabinets') != null) 
				document.getElementById('DIVInterestInCabinets').className='thide';
*/			
			if(document.getElementById('DIVOptIn') != null) 
				document.getElementById('DIVOptIn').className='thide';	

		}
		

	}
	function checkOtherServices(){
		
		if(document.form.OtherServiceList != null){
			
			for(i=0;i<document.form.ProductService.length;i++){
				if(document.form.ProductService[i].checked && document.form.ProductService[i].value == 'Other'){
					showOtherServices(document.form.ProductService[i]);
				}								
			}
		}
	}
	
function servicepagequestion()
{
	
	quest1check= false;
	if(document.getElementsByName('quest1')!=null)
	{quest1length = document.getElementsByName('quest1').length;}
	// If statement will submit the form for the second set of questions
	
	if(document.getElementById('quest1')== null){
		document.getElementById('submit').className = 'thide';
		document.getElementById('processing').className = 'tshow';
	}
	if(document.getElementById('quest1').className == 'thide'){
	
		document.form.submit();
 		document.getElementById('submit').className = 'thide';
		document.getElementById('processing').className = 'tshow';
		return true;
	}else
	{
	
	// else will display the Div having service specific question 
	// and hide the defualt i.e.(Buytimeframe,PC,Ownhome)
		var count =0;
	// Displayquest is a hidden field to get count of the number of service questions displayed	
		var displayquestcount = document.getElementsByName('displayquest').length;
	// Iterate through the service questions 	
		for(var dq=0;dq <= displayquestcount ; dq++){
	
			count = count +1;
			optionselected = false;
			var servicequest = (document.getElementsByName('displayquest')[dq]).value;
		
			var chkval = "document.form." + servicequest + ".length";
			var answerfieldcount = eval(chkval);
	// Iterate through the  options of each service questions 		
			  for(var chkin=0 ; chkin < answerfieldcount ; chkin++){
					var checkvalue = "document.form."+servicequest+"["+chkin+"].checked";
					if(eval(checkvalue))
					{
						optionselected = true;
					}
				}
	// Check if the user has selected options			
			if(optionselected ){
				var errormessage = "document.getElementById('error" +servicequest+"').className = 'thide'";
				eval(errormessage);
	
				if(count!=displayquestcount){continue;}
				if(quest1check){return false;}
				document.getElementById('quest2').className = 'tshow';
			
				for(var quest1count=0 ; quest1count<quest1length ;quest1count++){
					(document.getElementsByName('quest1')[quest1count]).className = 'thide'
				}	
			}else{
				quest1check = true;
				for(var quest1count=0 ; quest1count<quest1length ;quest1count++){
					(document.getElementsByName('quest1')[quest1count]).className = 'tshow'
				}
				var errormessage = "document.getElementById('error" +servicequest+"').className = 'tshow'";
				eval(errormessage);
				if(count==displayquestcount && !optionselected){
					document.getElementById('quest2').className = 'thide';
					return false;
				}			
			}	
			if(count==displayquestcount){
				return false;
			}
		}
		return false;
	}
}
function homepagequestion() {

 checkboxflag = false;
 optinval = true;
 optinval1 = false;

 if(document.getElementById('quest2').className == 'tshow'){
 		document.form.submit();
 		document.getElementById('submit').className = 'thide';
		document.getElementById('processing').className = 'tshow';

 		 for (var k = 0; k < document.form.PortalServiceCode.length; k++) {
	 
			if (document.form.PortalServiceCode[k].checked==true){
				if("FULL_KITCHEN_REMODELING" == document.form.PortalServiceCode[k].value){
				  optinval1 = true;
				}  
				
			}	
		}
			
			if(document.getElementById('optin').className == 'thide'){
				if(!optinval1){
					document.getElementById('optin').className = 'thide';
				}else{
					document.getElementById('optin').className = 'tshow';
				}
				
			}else{
				document.getElementById('optin').className = 'tshow';
			}
   }else
   {
	   for (var k = 0; k < document.form.PortalServiceCode.length; k++) {

			if (document.form.PortalServiceCode[k].checked==true){
				checkboxflag = true;
				if("FULL_KITCHEN_REMODELING" == document.form.PortalServiceCode[k].value){
				  optinval = false;
				}  
				
			}	
		}
	   if(!checkboxflag){ 
		   document.getElementById('errorPortalServiceCode').className = 'tshow'; 
		   return false;
		}else{
		document.getElementById('errorPortalServiceCode').className = 'thide'; 
		document.getElementById('quest1').className = 'thide'; 	
		document.getElementById('quest2').className = 'tshow';

		if(!optinval){
			if(document.getElementById('optin'))
				document.getElementById('optin').className = 'tshow';
		}else{
			if(document.getElementById('optin'))
				document.getElementById('optin').className = 'thide';
		}
		return false;
	   }	
	}
}
function doProcessing()
{
	document.getElementById('submit').className = 'thide';
	document.getElementById('processing').className = 'tshow';
}





