function ShowPayout(){	
	
	
	var url = urlpath+"PopupPayoutAddress.php";
	document.getElementById('div_fade_bg_mask').style.display = 'block';
	
	httpObj.open("POST",url,true);
	httpObj.onreadystatechange = function(){		
		if(httpObj.readyState==1||httpObj.readyState==2||httpObj.readyState==3){
			
			document.getElementById('popup_address').style.height='500px';
			document.getElementById('fade_bg55').innerHTML = '<div id="popup" class="popup"><div style="padding:200px 0px 200px 370px;"><img src="'+urlpath+'images/loading_large.gif"/></div></div>';
			document.getElementById('fade_bg_main').style.display = 'block';
		}
		if(httpObj.readyState==4){
			strContent=httpObj.responseText;
			document.getElementById('fade_bg55').innerHTML = strContent;
			document.getElementById('fade_bg_main').style.display = 'block';
		}
	}
	httpObj.send(null);
}
function PayoutAddressValidation(){

	var address = document.getElementById('baddress').value;
	
	if(address=='' || address=='Address'){ 
		document.getElementById('baddressError').style.display="block";
		document.getElementById("baddress").className = 'input_error';
	    document.getElementById('baddressError').innerHTML='<img src="'+urlpath+'images/error.png"  align="absmiddle" width="15" height="15" style="padding-bottom:5px;display:none;"/>&nbsp;We need an address to send you the cheque.';	
		return false;
	
	}else{
		document.getElementById('baddressError').style.display="none";
		document.getElementById("baddress").className = 'input_rounded';
		document.getElementById('baddressError').innerHTML='';
	}
	return true;	
}
function PayoutStateValidation(){
	var state = document.getElementById('bstate').value;
	var value = NameValidity(state);
	if(state=='' || state=='State'){ 
		
		document.getElementById("bstate").className = 'input_error';
		document.getElementById('bstateError').style.display="block";
		document.getElementById('bstateError').innerHTML='<img src="'+urlpath+'images/error.png"  align="absmiddle" width="15" height="15" style="padding-bottom:5px;display:none;"/>&nbsp;State required.';	
		return false;
	}else{
		document.getElementById('bstateError').style.display="none";
		document.getElementById("bstate").className = 'input_rounded';
		document.getElementById('bstateError').innerHTML='';
	}
	return true;
}
function PayoutCityValidation(){
	
	var city = document.getElementById('bcity').value;
	var other_city = document.getElementById('other_city').value;
	var value = NameValidity(city); 
	if(city==''  || city=='City'){ 
		
		document.getElementById("bcity").className = 'input_error';
		document.getElementById('bcityError').style.display="block";
		document.getElementById('bcityError').innerHTML='<img src="'+urlpath+'images/error.png"  align="absmiddle" width="15" height="15" style="padding-bottom:5px;display:none;"/>&nbsp;City required.';	
		return false;
	}else if(city=='other'){

		if(other_city==''){ 
			
			document.getElementById("other_city").className = 'input_error';
			document.getElementById('bothercityError').style.display="block";
			document.getElementById('bcityError').style.display="none";
			document.getElementById("bcity").className = 'input_rounded';
			document.getElementById('bothercityError').innerHTML='<img src="'+urlpath+'images/error.png"  align="absmiddle" width="15" height="15" style="padding-bottom:5px;display:none;"/>&nbsp;Other City required.';	
			return false;
		}else{
			document.getElementById("bcity").className = 'input_rounded';
			document.getElementById("other_city").className = 'input_rounded';
			document.getElementById('bothercityError').style.display="none";
			document.getElementById('bcityError').style.display="none";
			document.getElementById("bcity").className = 'input_rounded';
			document.getElementById('bothercityError').innerHTML='';
		}
		
	}else{
		document.getElementById("bcity").className = 'input_rounded';
		document.getElementById("other_city").className = 'input_rounded';
		document.getElementById('bcityError').style.display="none";
		document.getElementById('bothercityError').style.display="none";
		document.getElementById('bcityError').innerHTML='';	
	}
	return true;
} 
function PayoutAreaValidation(){
	
	var barea = document.getElementById('barea').value;
	var other_area = document.getElementById('other_area').value;
	var value = NameValidity(barea); 
	if(barea==''  || barea=='Area'){ 
		
		document.getElementById("barea").className = 'input_error';
		document.getElementById('bareaError').style.display="block";
		document.getElementById('bareaError').innerHTML='<img src="'+urlpath+'images/error.png"  align="absmiddle" width="15" height="15" style="padding-bottom:5px;display:none;"/>&nbsp;Area required.';	
		return false;
	}else if(barea=='other'){

		if(other_area==''){ 
			
			document.getElementById("other_area").className = 'input_error';
			document.getElementById("barea").className = 'input_rounded';
			document.getElementById('bareaError').style.display="none";
			document.getElementById('botherareaError').style.display="block";
			document.getElementById('botherareaError').innerHTML='<img src="'+urlpath+'images/error.png"  align="absmiddle" width="15" height="15" style="padding-bottom:5px;display:none;"/>&nbsp;Other area required.';	
			return false;
		}else{
			document.getElementById("barea").className = 'input_rounded';
			document.getElementById("other_area").className = 'input_rounded';
			document.getElementById('bareaError').style.display="none";
			document.getElementById('botherareaError').style.display="none";
			document.getElementById('botherareaError').innerHTML='';
		}
		
	}else{
		document.getElementById("barea").className = 'input_rounded';
		document.getElementById("other_area").className = 'input_rounded';
		document.getElementById('bareaError').style.display="none";
		document.getElementById('botherareaError').style.display="none";
		document.getElementById('bareaError').innerHTML='';	
	}
	return true;
}
function PayoutPincodeValidation(){ 
	document.getElementById('bareaError').innerHTML='';	
	var pincode = document.getElementById('bpincode').value;
	var value = CheckPinCode(pincode);
	if(pincode=='' || pincode=='Pincode'){ 
		
		document.getElementById("bpincode").className = 'input_error';
		document.getElementById('bpincodeError').style.display="block";
		document.getElementById('bpincodeError').innerHTML='<img src="'+urlpath+'images/error.png"  align="absmiddle" width="15" height="15" style="padding-bottom:5px;display:none;"/>&nbsp;Pincode required.';	
		return false;
	}else if(value){ 
		
		document.getElementById("bpincode").className = 'input_error';
		document.getElementById('bpincodeError').style.display="block";
		document.getElementById('bpincodeError').innerHTML='<img src="'+urlpath+'images/error.png"  align="absmiddle" width="15" height="15" style="padding-bottom:5px;display:none;"/>&nbsp;Please enter a valid pincode.';	
		return false;		
	}else{
		document.getElementById('bpincodeError').style.display="none";
		document.getElementById("bpincode").className = 'input_rounded';
		document.getElementById('bpincodeError').innerHTML='';
	}
	return true;
} 
function Payout(){
	
	var baddress = document.getElementById("baddress").value;
	var bcity = document.getElementById("bcity").value;
	var othercity = document.getElementById("other_city").value;
	var barea = document.getElementById("barea").value;
	var otherarea = document.getElementById("other_area").value;
	var bcountry = document.getElementById("bcountry").value;
	var bstate = document.getElementById("bstate").value;
	var bpincode = document.getElementById("bpincode").value;
	if(!PayoutAddressValidation()) return false;		
	if(!PayoutStateValidation()) return false;
	if(!PayoutCityValidation()) return false;		
	if(!PayoutAreaValidation()) return false;		
	if(!PayoutPincodeValidation()) return false;	
	document.getElementById('bpincodeError').innerHTML='';
	var url = urlpath+"UpdatePayout.php?baddress="+baddress+"&bcity="+bcity+"&othercity="+othercity+"&barea="+barea+"&otherarea="+otherarea+"&bcountry="+bcountry+"&bstate="+bstate+"&bpincode="+bpincode; 
	

	
	
	httpObj.open("POST",url,true);
	httpObj.onreadystatechange = function(){
		
		
		
		if(httpObj.readyState==1||httpObj.readyState==2||httpObj.readyState==3){
			document.getElementById('loading1').innerHTML = '<div style="position:absolute;"><img src="'+urlpath+'images/loading.gif"/></div>';
		}
		if(httpObj.readyState==4){
			
			strContent=httpObj.responseText;
			if(strContent=='--1--'){
				document.getElementById('loading1').innerHTML='';	
				document.getElementById('pop_header').style.display='none';	
				document.getElementById('signup').innerHTML='<div style="margin:0px;"><span style="font-size:22px; color:#517800;"> Your address updated successfully. </span><br /><br /><span style="font-size:18px; color:#414141;">We will send you a verification code by courier at your billing address after which you can get your Cashback.</span></div>';
				
			}
			
		}
	}
	httpObj.send(null);
	//return false;
}

