function show(id){
	document.getElementById(id).style.display = "";
}

function hide(id){
	document.getElementById(id).style.display = "none";
}

function redirect(form){
	url = form.quickLinks.value;
	if(url != ""){
		window.location = url;
	}
	return false;
}

function validateInput(form){
	error = "";
	if(!isUsername(form.username)){
			if(errorType == "empty"){
				error += "<li>username field have empty value</li>";
			}
			else{
				error = "<li>Unaccepted input on username \n We only accept letters numbers and underscroe</li>";
			}
	}
	
	
	if(isEmpty(form.password)){
			if(errorType == "empty"){
				error += "<li>password field have empty value</li>";
			}
	}
	if(isEmpty(form.cPassword)){
			if(errorType == "empty"){
				error += "<li>confirm password field have empty value</li>";
			}
	}
	if(form.password.value != form.cPassword.value && form.password.value.length != 0 && form.cPassword.value.length != 0 ){
		error += "<li>password and confirm password doesn't match</li>";
	}

	if(!isEmail(form.email)){
		if(errorType == "empty"){
			error += "<li>Email field have empty value</li>";
		}
		else{
			error += "<li>Unaccepted input on email or Invalid email address</li>";
		}
	}
	if(!isAlphaNumeric(form.name)){
		if(errorType == "empty"){
			//clearError(form.name);
				error += "<li>Name field have empty value</li>";
		}
		else{
			error += "<li>Unaccepted character on first name</li>";
		}
	}
	
	/*if(!isAlphaNumeric(form.country)){
		if(errorType == "empty"){
				error += "<li>Country field have empty value. Select your country</li>";
		}
		else{
			error += "<li>Unaccepted country name</li>";
		}
	}*/

	if(!isAlphaNumeric(form.securityCode)){
		if(errorType == "empty"){
				error += "<li>Security code field have empty value</li>";
		}
		else{
			error += "<li>Unaccepted input on security Code</li>";
		}
	}
	
	
	if(error.length != 0){ 
		//document.getElementById("error").innerHTML = "";
		document.getElementById('error').style.display = "block";
		//document.getElementById('registerInfo').style.display = "none";
		document.getElementById("error").innerHTML = "<h3>Error occured</h3><ul>"+error+"</ul>";
		return false;
		
	}
return true;
}
/*Show register tips
-------------------------------------------------------------------------*/
function showNote(act,id){
	if(document.getElementById('error').style.display == "block"){
		document.getElementById('register-notes').style.display = "";
	}
	if (act){
		document.getElementById(id).style.display = 'block';
		document.getElementById('defaultNotes').style.display = "none";}
	if (!act){
		document.getElementById(id).style.display = 'none';
		document.getElementById('defaultNotes').style.display = "block";
	}
	//alert(id);
}

function validateLoginInput(form){
	//var error = new Array();
	error = "";
	if(!isUsername(form.username)){
			if(errorType == "empty"){
				error += "<li>username field have empty value</li>";
			}
			else{
				error = "<li>Unaccepted input on username \n We only accept letters numbers and underscroe</li>";
			}
	}
	if(isEmpty(form.password)){
			if(errorType == "empty"){
				error += "<li>password field have empty value</li>";
			}
	}
	
	if(!isAlphaNumeric(form.securityCode)){
		if(errorType == "empty"){
				error += "<li>Security code field have empty value</li>";
		}
		else{
			error += "<li>Unaccepted input on security Code</li>";
		}
	}
	
	if(error.length != 0){ 
		document.getElementById('loginFormError').style.display = "block";
		document.getElementById("loginFormError").innerHTML = "<ul>"+error+"</ul>";
		return false;
	}
return true;
}

function sendForm(formObj){
	url = "/ajaxRequest/cashout.php";
	postData = "r_money="+formObj.r_money.value+"&paymentOption="+formObj.paymentOption.value;
	output = "text";
	responseHandler = 'cashoutUpdate';
	ajaxPostRequest(url, postData);
	return false;
}

function cashoutUpdate(response){
	document.getElementById('myaccount-content').innerHTML = response;
}

function validateSettingsInput(form){
	error = "";
	if(isEmpty(form.currentPassword)){
			if(errorType == "empty"){
				error += "<li>password field have empty value</li>";
			}
	}
	
	if(!isEmail(form.email)){
		if(errorType == "empty"){
			error += "<li>Personal Email field have empty value</li>";
		}
		else{
			error += "<li>Unaccepted input on email or Invalid email address</li>";
		}
	}
	
	if(!isEmail(form.paypal)){
		if(errorType == "empty"){
			clearError(form.paypal);
			//error += "<li>Email field have empty value</li>";
		}
		else{
			error += "<li>Unaccepted input on paypal email or Invalid paypal email address</li>";
		}
	}
	
	if(!isEmail(form.alertpay)){
		if(errorType == "empty"){
			clearError(form.alertpay);
			//error += "<li>Email field have empty value</li>";
		}
		else{
			error += "<li>Unaccepted input on paypal email or Invalid paypal email address</li>";
		}
	}
	
	if(!isAlphaNumeric(form.liberty)){
		if(errorType == "empty"){
			clearError(form.liberty);
				//error += "<li>Name field have empty value</li>";
		}
		else{
			error += "<li>Unaccepted input on liberty reserve id field</li>";
		}
	}
	
	if(form.password.value != form.confirmPassword.value && (form.password.value.length != 0 || form.confirmPassword.value.length != 0) ){
		errorStyle(form.password);
		errorStyle(form.confirmPassword);
		error += "<li>password and confirm password doesn't match</li>";
	}
	else{
		clearError(form.password);
		clearError(form.confirmPassword);
	}
	
	if(error.length != 0){ 
		//document.getElementById("error").innerHTML = "";
		document.getElementById('error').style.display = "block";
		//document.getElementById('registerInfo').style.display = "none";
		document.getElementById("error").innerHTML = "<h4>Error occured</h4><div id=\"errorContent\" ><ul>"+error+"</ul></div>";
		return false;
		
	}
}

function validateContactInput(form){
	error = "";
	if(isEmpty(form.yourName)){
			if(errorType == "empty"){
				error += "<li>Name field have empty value</li>";
			}
	}
	if(isEmpty(form.yourEmail)){
			if(errorType == "empty"){
				error += "<li>Email field have empty value</li>";
			}
	}
	if(isEmpty(form.yourQuery)){
			if(errorType == "empty"){
				error += "<li>Query field have empty value</li>";
			}
	}
	
	if(error.length != 0){ 
		//document.getElementById("error").innerHTML = "";
		document.getElementById('error1').style.display = "block";
		//document.getElementById('registerInfo').style.display = "none";
		document.getElementById("error1").innerHTML = "<h4>Error occured</h4><ul>"+error+"</ul>";
		return false;
		
	}
	return true;
}


