var embUrl="http://retreatcollections.com.au/";
function isValidEmailId(obj, name)
{
   obj.value=trim(obj.value);
   if (obj.value=='')
   {
	   alert('"'  + name + '" can not be blank. Please enter it.' );
	   obj.focus();
	   return false;
   }
   
   if (! isValidEmail(obj.value))
   {
      alert("Invalid e-Mail-Id entered.");
	  obj.focus();
	  return false;
   }
   return true;
}

function isValidEmail(elm)
{
 if(elm.indexOf('@',1) ==-1)
 	return (false);
 
 if(elm.indexOf('.',1) ==-1)
 	return (false);
 
 return true;
}

function trim(p_str)
{
   var i=0;
   while(1)
   {
     if ( p_str.charAt(0)==" " || p_str.charAt(0)=="\n" || p_str.charAt(0)=="\r") 
       p_str = p_str.substr(i+1);
     else
       break;
    } 
   
   while(1)
   {
     i=p_str.length;
     if ( p_str.charAt(i-1)==" " || p_str.charAt(i-1)=="\n" || p_str.charAt(i-1)=="\r") 
       p_str=p_str.substr(0,i-1);
     else
       break;
   }
  return p_str; 
}

function isEmpty(obj, str)
{
  if ( (obj.type=="text") || (obj.type=="password") || (obj.type=="textarea") )
  {
     obj.value=trim(obj.value)
     if(obj.value=="")
     {
	   alert('"' + str + '" can not be blank. Please enter it.');
	   obj.focus();
	   return true;
     }
  }

  if (obj.type=="select-one")
  {
	  if (obj.selectedIndex==0)
	  {
		  alert('"' + str + '" is mandatory field. Please select it.');
		  obj.focus();
		  obj.select;
		  return true;
	  }
  }
  return false;
}


function validnewsletter()
{
	obj=document.myform.txtnewsletter;
	if(!isValidEmailId(obj, " Email "))
	{
			return false;
	} 
	return true;
	 
}

function popupmail(id) 
{
 window.open(embUrl+"popupmail.php?Pid="+id,"","resizable=yes,width=300,height=275,scrollbars=yes,status=no,top=150,screenY=800,left=450,screenX=800");
}
function validmail()
 {
 		obj=document.myform.txtuser;
    	if(isEmpty(obj,"User Name"))
        return false;
 
	obj=document.myform.mail; 
	if(!isValidEmailId(obj, "Email ID"))
	{
		return false;
	} 
	return true;
 
 }
 
function popupprint(id) 
{
window.open(embUrl+"product_print.php?Pid="+id,"","resizable=yes,width=400,height=300,scrollbars=yes,status=no,top=150,screenY=800,left=450,screenX=800");
}

function popuplimage(id) 
{
window.open(embUrl+"popuplimage.php?Pid="+id,"","resizable=yes,width=500,height=400,scrollbars=yes,status=no,top=150,screenY=800,left=450,screenX=800");
}
function popuplmoreimage(id,iid) 
{
window.open(embUrl+"popupmorelimage.php?Pid="+id+"&iid="+iid,"","resizable=yes,width=500,height=400,scrollbars=yes,status=no,top=150,screenY=800,left=450,screenX=800");
}

function popupmorimage(id) 
{
window.open(embUrl+"popupmoreimg.php?Pid="+id,"","resizable=yes,width=400,height=400,scrollbars=yes,status=no,top=150,screenY=800,left=450,screenX=800");
}


function validenquiry()
{

	
	obj=document.frmenquiry.txtname;
	
    	if(isEmpty(obj,"Your Name"))
        return false;
 
	obj=document.frmenquiry.txtemail; 
	if(!isValidEmailId(obj, "Email ID"))
	{
		return false;
	} 

	obj=document.frmenquiry.txtdetail;
    	if(isEmpty(obj,"Contact Details"))
        return false;


	return true;
}