function checkUpload(imgfile)
{ 
  if(imgfile.value=="")
   { alert("Please upload image");
     imgfile.focus();
     return false;
   }
}

function conf_remove_img()
{
  var ans=confirm("Are you sure, you want to remove this image?");
  if(ans)
    return true;
 else
   return false;	
}

function conf_remove_img1(im)
{
		if(im<0)
		{
			alert("Please upload image to use this option.");
			return false;
		}
		else
		{
			  var ans=confirm("Are you sure, you want to remove this image?");
			  if(ans)
				return true;
			 else
			   return false;	
		}
}


function conf_remove_text()
{
  var ans=confirm("Are you sure, you want to remove text?");
  if(ans)
    return true;
 else
   return false;	
}

function change_style(te)
{
	if(te=="0")
  {
	  alert("Please upload text to use this option.");
	  return false;
  }
  else
  {
	  document.fontfrm.submit();
	  
  }
}

function conf_remove_text1(te)
{
  if(te=="0")
  {
	  alert("Please upload text to use this option.");
	  return false;
  }
  else
  {
	  var ans=confirm("Are you sure, you want to remove text?");
	  if(ans)
		return true;
	 else
	   return false;	
  }
}

function setSide()
{
parent.imgiframe.side.value="back";
return
}
function checkqty()
{
	if(document.addtocart.quantity.value=="")
	{
		alert("Please insert Quantity");
		document.addtocart.quantity.focus();
		return false;
	}
	else 
	{
		if(isNaN(document.addtocart.quantity.value))
		{
			alert("Please insert Quantity in number");
			document.addtocart.quantity.focus();
			return false;
		}
		else
		{
			return true;
		}
	}

}

function checkqty1()
{
	if(document.frm.quantity.value=="")
	{
		alert("Please insert Quantity");
		document.frm.quantity.focus();
		return false;
	}
	else 
	{
		if(isNaN(document.frm.quantity.value))
		{
			alert("Please insert Quantity in number");
			document.frm.quantity.focus();
			return false;
		}
		else
		{
			return true;
		}
	}

}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function defineheight(hei){
window.parent.iframe_img.width=hei;
}

function submitForm(pid,pn,pr)
{ 
document.frm.subcat_id.value=pid;
document.frm.productname.value=pn;
document.frm.productprice.value=pr;
document.frm.submit();
}


function checkMail()
{
	if(document.frm_email.from_name.value=="")
	{
		alert("Please insert Friend's name");
		document.frm_email.from_name.focus();
		return false;
	}
	if(document.frm_email.to_email.value=="")
					{
					alert("Friend's Email ID is a compulsory field.");
					document.frm_email.to_email.focus();
					return false;						
					}							
  					else 
 					   {    var emailStr=document.frm_email.to_email.value;
                           // checks if the e-mail address is valid
    				        //var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
   					         //var matchArray = emailStr.match(emailPat);
 				           //if (matchArray == null) {
						   var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
							var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
							if (!(!reg1.test(emailStr) && reg2.test(emailStr))) 
							{
 				             alert("Please check Friend's Email ID.");
							document.frm_email.to_email.focus();
 				              return false;   
					          }				
			
  					  }	
					  
		if(document.frm_email.your_name.value=="")
	{
		alert("Please insert your name");
		document.frm_email.from_name.focus();
		return false;
	}
	if(document.frm_email.your_email.value=="")
					{
					alert("Email Address is a compulsory field.");
					document.frm_email.your_email.focus();
					return false;						
					}							
  					else 
 					   {    var emailStr=document.frm_email.your_email.value;
                           // checks if the e-mail address is valid
    				        //var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
   					         //var matchArray = emailStr.match(emailPat);
 				           //if (matchArray == null) {
						   var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
							var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
							if (!(!reg1.test(emailStr) && reg2.test(emailStr))) 
							{
 				             alert("Please check your Email Address.");
							document.frm_email.your_email.focus();
 				              return false;   
					          }				
			
  					  }	
}




function checkLines(obj,limit,limit1) {
	var k=false;
	
if(obj.value.length>limit1)
{
alert("You have reached the limit of characters");
k=true;
return false;
}
if(k==false){
var s = obj.value.split("\r\n") // split the string into an array based on the enter chars (ascii 13 and 10) linefeed carriage return
var a = new Array()
if (s.length > limit) { //if it is > than the limit, crop the the value
for (i=0;i<=limit;i++) { 
a[i] = s[i]
}
obj.value = a.join("\r\n") //join the array back to it's delimiter (crlf)
tempObj = obj
//obj.disabled = true //disable so that can't input while you warn them

setTimeout("reenable("+limit+")",5) //set a timer to re-enabled the object, also so it doesn't flood them with alerts if they are holding ENTER down

}
}
}
function reenable(n) { 
if (tempObj) { 
alert("You have reached the limit of lines which is: " + n)
tempObj.disabled = false
tempObj.focus()
tempObj = null

}
}
function textCounter(field, countfield, maxlimit,rowlimit) {a=field.value.split("\r\n");

if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
if(a.length>rowlimit)
{
	b=field.value.lastIndexOf("\r\n");
	field.value = field.value.substring(0, b);
}
}

function remove_product(c)
{
	var strurl='delete.php?id='+c;
 var ans=confirm("Are you sure, you want to remove product?");
  if(ans)
  window.location.href=strurl;

}
function remove_pad(c)
{
	var strurl='delete_pad.php?id='+c;
 var ans=confirm("Are you sure, you want to remove this letter head?");
  if(ans)
  window.location.href=strurl;

}

function remove_order(c)
{
	var strurl='delete_order.php?id='+c;
 var ans=confirm("Are you sure, you want to remove this order?");
  if(ans)
  window.location.href=strurl;

}
function sMail(orid,$da,$uname,$e)
{
	var strurl='delete_order.php?id='+orid;
	var t="<font face=tahoma size=2 style=FONT-SIZE: 11px;>Dear "+ $uname+",<br><br>";
	t +="Thank you for visiting our website on " + $da + "<BR>";
	t +="We have seen that,for some reasons, you did not  complete your order.";
	var u="http://www.digsam.com/approval/Imagine and Print /rdr.php?c="+$e;
	t +="If you are still interested in placing the order please " + "click here".anchor(u) +", this link will directly take you to the chek-out screen.<br><br>";
	t +="Warm Regards<br>";
	t +="Team Imagine and Print <br>";
	 var ans=confirm(t);
  if(ans)
  window.location.href=strurl;

}
function fBack(orid,seid)
{
	window.location.href="product_detail.php?oid="+orid+"&sid="+seid;
}

