function confirmation() {
	var answer = confirm("Really delete this listing?")
	if (answer){
		return true ; }
	else {
		return false ; }
}

function confirmationu() {
	var answer = confirm("Really unlock this listing?")
	if (answer){
		return true ; }
	else {
		return false ; }
}

function confirmationc() {
	var answer = confirm("Really cancel this listing?")
	if (answer){
		return true ; }
	else {
		return false ; }
}

function enableLogo(thaR) {
	var t = thaR;
	document.getElementById("logoh").innerHTML = "<input type='file' name='file' id='file' size='37' onblur=addInput(this) onfocus=clearInput(this) /><input type='checkbox' onclick=disableLogo('"+t+"')>Reset Logo";
}

function disableLogo(ehaR) {
	var e = ehaR;
	document.getElementById("logoh").innerHTML = "<input type='hidden' value='"+e+"' name='fileagain'><img src='/upload/"+e+"'><input type='checkbox' id='file' onclick=enableLogo('"+e+"')>Change Logo";
}


function textCounter(field,maxlimit) {
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	else
		document.getElementById("description_warning").innerHTML = maxlimit - field.value.length;
}

function clearInput(e){ 
	e.style.backgroundColor = "#ECE9D8";
	if(e.value==' What are you looking for?')e.value=""; 
} 

function addInput(e){ 
	e.style.backgroundColor = "#fff";
} 

function validateEmail(myform) {

	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myform.value)){
		document.getElementById("email_warning").innerHTML = "<span class=warning>&nbsp;</span>"
		myform.style.backgroundColor = "#FFF";
		return (true)
	}
	document.getElementById("email_warning").innerHTML = "<span class=warning>Email incorrect</span>";
	myform.style.backgroundColor = "#FFF";
	return (false)	
}

function validatePassword(e)
{
	e.style.backgroundColor = "#FFF";
	if (e.value.length < 8) {document.getElementById("password_warning").innerHTML = "<span class=warning>Password incorrect</span>"; }
	if (e.value.length >= 8) {document.getElementById("password_warning").innerHTML = "<span class=warning>&nbsp;</span>"; }
	if (e.value != document.getElementById("passwordagain").value) {document.getElementById("passwordagain_warning").innerHTML = "<span class=warning>Password doesn't match</span>"; }
	if (e.value == document.getElementById("passwordagain").value) {document.getElementById("passwordagain_warning").innerHTML = "<span class=warning>&nbsp;</span>"; }
	return true ;
}

function validatePasswordAgain(e)
{
	e.style.backgroundColor = "#FFF";
	if (e.value != document.getElementById("password").value) {document.getElementById("passwordagain_warning").innerHTML = "<span class=warning>Password doesn't match</span>"; }
	if (e.value == document.getElementById("password").value) {document.getElementById("passwordagain_warning").innerHTML = "<span class=warning>&nbsp;</span>"; }
	return true ;
}

function validateEmpty(e, y)
{
	e.style.backgroundColor = "#FFF";
	if (e.value.length < 1) {document.getElementById(y).innerHTML = "<span class=warning>This field is required</span>"; }
	if (e.value.length >= 1) {document.getElementById(y).innerHTML = "&nbsp;"; }
	return true ;
}
