function del_listing(id, user_id)
{
	if(window.confirm('Are you sure you want to delete this painting'))
	{
		document.location.href="http://www.dstillz.com/profile/delete.php?id="+id+"&user_id="+user_id+"&mode=painting"
	}
}

function del_search(id, user_id)
{
	if(window.confirm('Are you sure you want to delete this search'))
	{
		document.location.href="http://www.dstillz.com/profile/delete.php?id="+id+"&user_id="+user_id+"&mode=search"
	}
}

function newsletter_form()
 {
	var e = document.frmnewsletter;
	var emailID=e.email
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}
	
	$.post('http://www.dstillz.com/profile/savenewsletter.php', { email: e.email.value},

	function(data){
		if(data=="Error")
		{
			document.getElementById("qnews").style.display = "block";
			document.getElementById("qthanku").style.display = "none";
			document.getElementById("qexists").style.display = "none";
		}
		else if(data=="done")
		{
			document.getElementById("qnews").style.display = "none";
			document.getElementById("qthanku").style.display = "block";
			document.getElementById("qexists").style.display = "none";
		}
		else if(data=="exists")
		{
			document.getElementById("qnews").style.display = "block";
			document.getElementById("qthanku").style.display = "none";
			document.getElementById("qexists").style.display = "block";
		}
	}
	);
 }
 
 function login_form()
 {
	var e = document.frmlogin;
	var username = e.username
	if ((username.value==null)||(username.value=="")){
		alert("Please Enter your Email ID");
		username.focus();
		return false;
	}
	if (echeck(username.value)==false){
		username.value="";
		username.focus();
		return false;
	}
	
	$.post('http://www.dstillz.com/login/do_login.php', { username: e.username.value , password: e.password.value , autologin: e.autologin.value },
		
	function(data){
		if(data=="ERROR")
		{
			document.getElementById("l_error").style.display = "block";
		}
		else if(data=="OK")
		{
			document.location.href="http://www.dstillz.com/profile/903/"
		}
	}
	);
 }
 
  function login_form_hide()
 {
	var e = document.frmlogin_hide;
	var username = e.username
	if ((username.value==null)||(username.value=="")){
		alert("Please Enter your Email ID");
		username.focus();
		return false;
	}
	if (echeck(username.value)==false){
		username.value="";
		username.focus();
		return false;
	}
	
	$.post('http://www.dstillz.com/login/do_login.php', { username: e.username.value , password: e.password.value , autologin: e.autologin.value },
		
	function(data){
		if(data=="ERROR")
		{
			document.getElementById("l_error_hide").style.display = "block";
		}
		else if(data=="OK")
		{
			document.location.href="http://www.dstillz.com/profile/903/"
		}
	}
	);
 }
 
 function echeck(str) {
  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)
  if (str.indexOf(at)==-1){
     alert("Invalid E-mail ID")
     return false
  }
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
     alert("Invalid E-mail ID")
     return false
  }
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
      alert("Invalid E-mail ID")
      return false
  }
   if (str.indexOf(at,(lat+1))!=-1){
      alert("Invalid E-mail ID")
      return false
   }
   if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
      alert("Invalid E-mail ID")
      return false
   }
   if (str.indexOf(dot,(lat+2))==-1){
      alert("Invalid E-mail ID")
      return false
   }
  
   if (str.indexOf(" ")!=-1){
      alert("Invalid E-mail ID")
      return false
   }
    return true     
 }
