function redirectAuctionPage(auctionId,variantId)
{
   window.location = 'productAuctionDetail.php?vrId='+variantId+'&auId='+auctionId+'';	
}
function swapImageProducts(id)
{
   var filename = id.src.substr(id.src.indexOf('filename='));
   var filename1 = document.getElementById('primaryImage').src.substr(document.getElementById('primaryImage').src.indexOf('filename='));
   id.src = id.src.replace(filename,filename1);
   var anchorId = document.getElementById('aid');
   document.getElementById('primaryImage').src = document.getElementById('primaryImage').src.replace(filename1,filename);
   anchorId.href = 'Admin/' + filename.substr(filename.toLowerCase().indexOf('filename=')+9);
}
/*function swapImageProducts(id)
{
   var filename = id.src.substr(id.src.indexOf('filename='));
   var filename1 = document.getElementById('primaryImage').src.substr(document.getElementById('primaryImage').src.indexOf('filename='));
   id.src = id.src.replace(filename,filename1);
   document.getElementById('primaryImage').src = document.getElementById('primaryImage').src.replace(filename1,filename);
}*/
function fbs_click() 
{
	var u='http://www.facebook.com/dishonestapparel';
	var t=document.title; 
	window.open('http://www.facebook.com/sharer.php?u=' +encodeURIComponent(u)+'&t='+ encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436'); 
	return false; 
}


function twitter_click() 
{
	var u='http://www.twitter.com/dishonestees';
	var t=document.title; 
	window.open('http://twitter.com/home?status=' + encodeURIComponent(u));              
	return false; 
}  
function validateCharLimit(charLimit,textVal)
{
	var charCount = textVal;

	if(charCount > charLimit)
	{
		alert("Only "+charLimit+" characters are allowed");
		return true;
	}
	else
	{
		return false;
	}
}
function validateVideos()
{
  	var textVal = document.getElementById('vdeDescrptn').value.length;
	if(isEmpty(document.getElementById('videoTitle').value))
	{
		alert('Please enter video title.');
		document.frmUpldVideo.videoTitle.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('vdeDescrptn').value))
	{
		alert('Please enter video description.');
		document.frmUpldVideo.vdeDescrptn.focus();
		return false ;
	}
	else if(validateCharLimit(250,textVal))
	 {
		
		document.getElementById('frmUpldVideo').focus();
		return false;
	 }
	if(isEmpty(document.getElementById('video').value))
	{
		alert('Please browse video.');
		document.frmUpldVideo.video.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('pic').value))
	{
		alert('Please browse image.');
		document.frmUpldVideo.pic.focus();
		return false ;
	}
	if(document.getElementById('terms').checked == false)
	{
	    alert('Please check terms and conditions first.');
		return false;
	}
}
function new_win(orgnlReprtId,reprtedById,baseUrl)
	{
		//alert(reprtedById);
		//alert(baseUrl);
		if(reprtedById == "")
		{
		   window.location="index.php?msg=ntlogin";
		}
		else
		{
		window.open(''+baseUrl+'/reportAbuse.php?orgnlReprtId='+orgnlReprtId+'&reprtedById='+reprtedById,'mywin','width=400,height=200,left=500,top=200,scrollbars=yes, resizable=yes, toolbar=no');
	    return false;	
		}
	}
function new_winForTerms(orgnlReprtId,reprtedById,baseUrl)
	{
		window.open(''+baseUrl+'/staticText.php?orgnlReprtId='+orgnlReprtId+'&reprtedById='+reprtedById,'mywin','width=300,height=300,left=200,top=150,scrollbars=yes, resizable=yes, toolbar=no');
	    return false;	
	}	
function validateFanDesign()
{
	var textVal = document.getElementById('designDescription').value.length;
	if(isEmpty(document.getElementById('title').value))
	{
		alert('Please enter a title.');
		document.frmUpldFanDesign.title.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('pic1').value))
	{
		alert('Please browse Your Design On T-shirt.');
		document.frmUpldFanDesign.pic1.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('pic2').value))
	{
		alert('Please browse Actual Image Of Your Design.');
		document.frmUpldFanDesign.pic2.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('pic3').value))
	{
		alert('Please browse Your Design Placed On Model.');
		document.frmUpldFanDesign.pic3.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('designDescription').value))
	{
		alert('Please enter description.');
		document.frmUpldFanDesign.designDescription.focus();
		return false ;
	}
	else if(validateCharLimit(250,textVal))
	 {
		
		document.getElementById('frmUpldFanDesign').focus();
		return false;
	 }
	if(document.getElementById('terms').checked == false)
	{
	    alert('Please check terms and conditions first.');
		return false;
	}
}
function validateSearchfield()
{
    if(isEmpty(document.getElementById('search1').value))
	{
		alert('Please enter product name or description.');
		document.frmSearch.search1.focus();
		return false ;
	}	
}
function validateReportAbuse()
{
	if(isEmpty(document.getElementById('message').value))
	{
		alert('Please enter your message.');
		document.frmReportAbuse.message.focus();
		return false ;
	}
}
/////////function for contact us////////////
function validateContactUs()
{
    var textVal = document.getElementById('message').value.length;
	
	if(isEmpty(document.getElementById('name').value))
	{
		alert('Please enter your name.');
		document.frmContactUs.name.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('email').value))
	{
		alert('Please enter your email.');
		document.frmContactUs.email.focus();
		return false ;
	}
	if(!IsValidEMail(document.getElementById('email').value))
	 {
		alert('Email address not valid.');
		document.frmContactUs.email.focus();
		return false ;
	 }
	if(isEmpty(document.getElementById('message').value))
	{
		alert('Please enter your message.');
		document.frmContactUs.message.focus();
		return false ;
	}
	else if(validateCharLimit(1000,textVal))
	 {
		
		document.getElementById('frmContactUs').focus();
		return false;
	 }
}

function isNumericforUpdate(elem)
{
  var numericExpression = /^[0-9]+$/;
  if(elem.value.match(/^[0-9]+$/))
  {
     return true ;
  }
  else
  {
   return false;
   }
}
function validateCoupanCode(secName,catId)
{
    document.getElementById('frmcheckOut1').action = "checkOutStep2.php?scName="+secName+"&ctId="+catId+"";
	document.getElementById('frmcheckOut1').submit();	
}
function validateOrderInfoInformationOutStock()
{
   	if(document.getElementById('shipiingMethod1').checked==true)
	{
		var i=1;
		while(true)
		{
			var chk = document.getElementById('a'+i);
			if(chk == null || chk == "undefined")
			{
				alert('Please choose a shipping method');
				return false;
			}
			else
			{
				if(chk.checked)
				{
					break;
				}
			}
			i++;
		}
	}
	else
	{
		var i=1;
		while(true)
		{
			var chk = document.getElementById('b'+i);
			if(chk == null || chk == "undefined")
			{
				alert('Please choose a shipping method');
				return false;
			}
			else
			{
				if(chk.checked)
				{
					break;
				}
			}
			i++;
		}
	}
	if(isEmpty(document.getElementById('shippingFirstName').value))
	{
		alert('Please enter shipping first name.');
		document.frmCheckout2.shippingFirstName.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('shippingLastName').value))
	{
		alert('Please enter shipping last name.');
		document.frmCheckout2.shippingLastName.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('shippingAddress').value))
	{
		alert('Please enter shipping address.');
		document.frmCheckout2.shippingAddress.focus();
		return false ;
	}
	/*if(isEmpty(document.getElementById('shippingAddress2').value))
	{
		alert('Please enter shipping address line 2/apartment .');
		document.frmCheckout2.shippingAddress2.focus();
		return false ;
	}*/
	if(isEmpty(document.getElementById('shippingPostCode').value))
	{
		alert('Please enter shipping post code.');
		document.frmCheckout2.shippingPostCode.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('shippingCity').value))
	{
		alert('Please enter shipping city.');
		document.frmCheckout2.shippingCity.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('shippingState').value))
	{
		alert('Please enter shipping state.');
		document.frmCheckout2.shippingState.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('shippingCountry').value))
	{
		alert('Please enter shipping country.');
		document.frmCheckout2.shippingCountry.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('shippingContactNumber').value))
	{
		alert('Please enter shipping contact number.');
		document.frmCheckout2.shippingContactNumber.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingFirstName').value))
	{
		alert('Please enter billing first number.');
		document.frmCheckout2.billingFirstName.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingLastName').value))
	{
		alert('Please enter billing last name.');
		document.frmCheckout2.billingLastName.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingEmailAddress').value))
	{
		alert('Please enter billing email address.');
		document.frmCheckout2.billingEmailAddress.focus();
		return false ;
	}
	if(!IsValidEMail(document.getElementById('billingEmailAddress').value))
	 {
		alert('Billing email address not valid.');
		document.frmCheckout2.billingEmailAddress.focus();
		return false ;
	 }
	if(isEmpty(document.getElementById('billingAddress').value))
	{
		alert('Please enter billing address.');
		document.frmCheckout2.billingAddress.focus();
		return false ;
	}
	/*if(isEmpty(document.getElementById('billingAddress2').value))
	{
		alert('Please enter address line 2/apartment .');
		document.frmCheckout2.billingAddress2.focus();
		return false ;
	}*/
	if(isEmpty(document.getElementById('billingPostCode').value))
	{
		alert('Please enter billing post code.');
		document.frmCheckout2.billingPostCode.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingCity').value))
	{
		alert('Please enter billing city.');
		document.frmCheckout2.billingCity.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingState').value))
	{
		alert('Please enter billing state.');
		document.frmCheckout2.billingState.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingCountry').value))
	{
		alert('Please enter billing country.');
		document.frmCheckout2.billingCountry.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingContactNumber').value))
	{
		alert('Please enter billing contact number.');
		document.frmCheckout2.billingContactNumber.focus();
		return false ;
	}
	
		document.getElementById('frmCheckout2').action = "outOfStockPaymentInfo.php";
	    document.getElementById('frmCheckout2').submit();
}
function validateShillingInformation(secName,catId)
{
	if(document.getElementById('shipiingMethod1').checked==true)
	{
		var i=1;
		while(true)
		{
			var chk = document.getElementById('a'+i);
			if(chk == null || chk == "undefined")
			{
				alert('Please choose a shipping method');
				return false;
			}
			else
			{
				if(chk.checked)
				{
					break;
				}
			}
			i++;
		}
	}
	else
	{
		var i=1;
		while(true)
		{
			var chk = document.getElementById('b'+i);
			if(chk == null || chk == "undefined")
			{
				alert('Please choose a shipping method');
				return false;
			}
			else
			{
				if(chk.checked)
				{
					break;
				}
			}
			i++;
		}
	}
	if(isEmpty(document.getElementById('shippingFirstName').value))
	{
		alert('Please enter shipping first name.');
		document.frmCheckout2.shippingFirstName.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('shippingLastName').value))
	{
		alert('Please enter shipping last name.');
		document.frmCheckout2.shippingLastName.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('shippingAddress').value))
	{
		alert('Please enter shipping address.');
		document.frmCheckout2.shippingAddress.focus();
		return false ;
	}
	/*if(isEmpty(document.getElementById('shippingAddress2').value))
	{
		alert('Please enter shipping Address Line 2/Apartment ');
		document.frmCheckout2.shippingAddress2.focus();
		return false ;
	}*/
	if(isEmpty(document.getElementById('shippingPostCode').value))
	{
		alert('Please enter shipping post code.');
		document.frmCheckout2.shippingPostCode.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('shippingCity').value))
	{
		alert('Please enter shipping city.');
		document.frmCheckout2.shippingCity.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('shippingState').value))
	{
		alert('Please enter shipping state.');
		document.frmCheckout2.shippingState.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('shippingCountry').value))
	{
		alert('Please enter shipping country.');
		document.frmCheckout2.shippingCountry.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('shippingContactNumber').value))
	{
		alert('Please enter shipping contact number.');
		document.frmCheckout2.shippingContactNumber.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingFirstName').value))
	{
		alert('Please enter billing first number.');
		document.frmCheckout2.billingFirstName.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingLastName').value))
	{
		alert('Please enter billing last name.');
		document.frmCheckout2.billingLastName.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingEmailAddress').value))
	{
		alert('Please enter billing email address.');
		document.frmCheckout2.billingEmailAddress.focus();
		return false ;
	}
	if(!IsValidEMail(document.getElementById('billingEmailAddress').value))
	 {
		alert('Billing email address not valid.');
		document.frmCheckout2.billingEmailAddress.focus();
		return false ;
	 }
	if(isEmpty(document.getElementById('billingAddress').value))
	{
		alert('Please enter billing address.');
		document.frmCheckout2.billingAddress.focus();
		return false ;
	}
	/*if(isEmpty(document.getElementById('billingAddress2').value))
	{
		alert('Please enter billing Address Line 2/Apartment.');
		document.frmCheckout2.billingAddress2.focus();
		return false ;
	}*/
	if(isEmpty(document.getElementById('billingPostCode').value))
	{
		alert('Please enter billing post code.');
		document.frmCheckout2.billingPostCode.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingCity').value))
	{
		alert('Please enter billing city.');
		document.frmCheckout2.billingCity.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingState').value))
	{
		alert('Please enter billing state.');
		document.frmCheckout2.billingState.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingCountry').value))
	{
		alert('Please enter billing country.');
		document.frmCheckout2.billingCountry.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('billingContactNumber').value))
	{
		alert('Please enter billing contact number.');
		document.frmCheckout2.billingContactNumber.focus();
		return false ;
	}
		document.getElementById('frmCheckout2').action = "creditCardInfo.php";
	    document.getElementById('frmCheckout2').submit();
}
function copyShippingInfo()
{
	if(document.getElementById('check').checked == true)
	{
		document.getElementById('billingFirstName').value = document.getElementById('shippingFirstName').value;
		document.getElementById('billingLastName').value = document.getElementById('shippingLastName').value;
		document.getElementById('billingAddress').value = document.getElementById('shippingAddress').value;
		document.getElementById('billingAddress2').value = document.getElementById('shippingAddress2').value;
		document.getElementById('billingPostCode').value = document.getElementById('shippingPostCode').value;
		document.getElementById('billingCity').value = document.getElementById('shippingCity').value;
		document.getElementById('billingState').value = document.getElementById('shippingState').value;
		document.getElementById('billingCountry').value = document.getElementById('shippingCountry').value;
		document.getElementById('billingContactNumber').value = document.getElementById('shippingContactNumber').value;
	}
	else
	{
		document.getElementById('billingFirstName').value = "";
		document.getElementById('billingLastName').value = "";
		document.getElementById('billingAddress').value = "";
		document.getElementById('billingAddress2').value = "";
		document.getElementById('billingPostCode').value = "";
		document.getElementById('billingCity').value = "";
		document.getElementById('billingState').value = "";
		document.getElementById('billingCountry').value = "";
		document.getElementById('billingContactNumber').value = "";
	}
}
function validatePlaceBid()
{
   	    var numericExpression = /^[0-9]+$/;
	    if(isEmpty(document.getElementById('bidAmount').value))
		{
			alert('Please enter your bid.');
			document.frmPlaceBid.bidAmount.focus();
			return false;
		}
		
		//alert('document.getElementById('yourBid').value');
		if((document.getElementById('bidAmount').value) == 0)
		{
		   alert('Your bid should be more than zero.');
		   document.frmPlaceBid.bidAmount.focus();
		   return false;
		}
	    if(document.getElementById('bidAmount').value.match(/^[0-9]+$/))
	    {
		   document.getElementById('frmPlaceBid').action = "browseProductsHandler.php?msg=plcBd";
		   document.getElementById('frmPlaceBid').submit();
	    }
	    else
	    {
	       alert('Please enter only numeric values');
	    }
}

function validateWishList()
{
   	if(checkFunction("Adding this product to cart will remove it from wish list.Are you sure you want to continue?"))
	{
	document.getElementById('orderQuantity').action = "orderHandler.php?msg=updtCrt&act=wshLst";
	document.getElementById('orderQuantity').submit();
	}
}
function validateUpdateCart(varientId)
{
	if(checkFunction("Do you want to update quantity of this product?"))
	{
	document.getElementById('orderQuantity').action = "orderHandler.php?msg=updtCrt";
	document.getElementById('orderQuantity').submit();
	}
}
function validatePlaceOrder()
{
   	document.getElementById('frmCheckOut3').action = "placeOrder.php";
	document.getElementById('frmCheckOut3').submit();
}
function addToWishList()
{
   if(isEmpty(document.getElementById('selectStyle').value))
   {
	  alert('Please choose a style.');
	  document.frmAddCart.selectStyle.focus();
	  return false ; 
   }
   if(isEmpty(document.getElementById('selectSize').value))
   {
	  alert('Please choose a size.');
	  document.frmAddCart.selectSize.focus();
	  return false ; 
   }
   if(isEmpty(document.getElementById('selectColor').value))
   {
	  alert('Please choose a color.');
	  document.frmAddCart.selectColor.focus();
	  return false ; 
   }
   document.getElementById('frmAddCart').action = "orderHandler.php?act=wl";
   document.getElementById('frmAddCart').submit();

}
function addToCart()
{
   if(isEmpty(document.getElementById('selectStyle').value))
   {
	  alert('Please choose a style.');
	  document.frmAddCart.selectStyle.focus();
	  return false ; 
   }
   if(isEmpty(document.getElementById('selectSize').value))
   {
	  alert('Please choose a size.');
	  document.frmAddCart.selectSize.focus();
	  return false ; 
   }
   if(isEmpty(document.getElementById('selectColor').value))
   {
	  alert('Please choose a color.');
	  document.frmAddCart.selectColor.focus();
	  return false ; 
   }
   document.getElementById('frmAddCart').action = "orderHandler.php?act=ct";
   document.getElementById('frmAddCart').submit();
}
function addToOutOfStockCart()
{
   document.getElementById('frmAddCart').action = "outOfStockHandler.php?act=outStock";
   document.getElementById('frmAddCart').submit();
}

function validateHighestBidder()
{
   document.getElementById('frmHghstBder').action = "highestBidder.php?msg=pay";
   document.getElementById('frmHghstBder').submit();	
}
function validateCommentWholesale()
{
	var argvalue = document.getElementById('cmpnyWbstUrl').value;
	if(isEmpty(document.getElementById('contactFullName').value))
	{
		alert('Please enter contact/representative name.');
		document.frmSendWholesaleComment.contactFullName.focus();
		return false;
	}
	if(isEmpty(document.getElementById('title').value))
	{
		alert('Please enter title/position.');
		document.frmSendWholesaleComment.title.focus();
		return false;
	}
	if(isEmpty(document.getElementById('businessName').value))
	{
		alert('Please enter business/dba name.');
		document.frmSendWholesaleComment.businessName.focus();
		return false;
	}
	if(isEmpty(document.getElementById('businessAdress').value))
	{
		alert('Please enter business address.');
		document.frmSendWholesaleComment.businessAdress.focus();
		return false;
	}
	if(isEmpty(document.getElementById('businessCity').value))
	{
		alert('Please enter business city.');
		document.frmSendWholesaleComment.businessCity.focus();
		return false;
	}
	if(isEmpty(document.getElementById('businessState').value))
	{
		alert('Please select a business state.');
		document.frmSendWholesaleComment.businessState.focus();
		return false;
	}
	if(isEmpty(document.getElementById('businessZipCode').value))
	{
		alert('Please enter business zip code.');
		document.frmSendWholesaleComment.businessZipCode.focus();
		return false;
	}
	if(isEmpty(document.getElementById('billingAdress').value))
	{
		alert('Please enter billing address.');
		document.frmSendWholesaleComment.billingAdress.focus();
		return false;
	}
	if(isEmpty(document.getElementById('billingCity').value))
	{
		alert('Please enter billing city.');
		document.frmSendWholesaleComment.billingCity.focus();
		return false;
	}
	if(isEmpty(document.getElementById('billingState').value))
	{
		alert('Please select billing state.');
		document.frmSendWholesaleComment.billingState.focus();
		return false;
	}
	if(isEmpty(document.getElementById('billingZipCode').value))
	{
		alert('Please enter billing zip code.');
		document.frmSendWholesaleComment.billingZipCode.focus();
		return false;
	}
	if(isEmpty(document.getElementById('phoneNumber').value))
	{
		alert('Please enter phone number.');
		document.frmSendWholesaleComment.phoneNumber.focus();
		return false;
	}
	if(isEmpty(document.getElementById('mobileNumber').value))
	{
		alert('Please enter mobile number.');
		document.frmSendWholesaleComment.mobileNumber.focus();
		return false;
	}
	if(isEmpty(document.getElementById('faxNumber').value))
	{
		alert('Please enter fax number.');
		document.frmSendWholesaleComment.faxNumber.focus();
		return false;
	}
	if(isEmpty(document.getElementById('emailAddress').value))
	{
		alert('Please enter email address.');
		document.frmSendWholesaleComment.emailAddress.focus();
		return false;
	}
	if(!IsValidEMail(document.getElementById('emailAddress').value))
	 {
		alert('Email address not valid.');
		document.frmSendWholesaleComment.emailAddress.focus();
		return false;
	 }
	if(isEmpty(document.getElementById('cmpnyWbstUrl').value))
	{
		alert('Please enter company website url.');
		document.frmSendWholesaleComment.cmpnyWbstUrl.focus();
		return false;
	}
	if(!validateURL(argvalue))
	{
		return false;
	}
	if(isEmpty(document.getElementById('taxIdNum').value))
	{
		alert('Please enter federal tax id number.');
		document.frmSendWholesaleComment.taxIdNum.focus();
		return false;
	}
	if(isEmpty(document.getElementById('resaleNum').value))
	{
		alert('Please enter state resale number.');
		document.frmSendWholesaleComment.resaleNum.focus();
		return false;
	}
	if(isEmpty(document.getElementById('code').value))
	{
		alert('Please enter security Code as shown the image above.');
		document.frmSendWholesaleComment.code.focus();
		return false;
	}
}
function validateCommentRating()
{
   var textVal = document.getElementById('comment').value.length;
   //alert
   if(isEmpty(document.getElementById('comment').value))
	{
		alert('Please enter comment.');
		document.frmAddComment.comment.focus();
		return false ;
	}
	else if(validateCharLimit(200,textVal))
	 {
		
		document.getElementById('frmAddComment').focus();
		return false;
	 }
	
}


function setPrimaryImage(imagePath,largeImageId)
{
   if(navigator.appName=="Microsoft Internet Explorer")
   {
   document.getElementById('primaryImage').src = "Admin/imageResizeFunction.php?filename="+imagePath+"&width=333&heigth=333";
   }
   else
   {
   document.primaryImage.src = "Admin/imageResizeFunction.php?filename="+imagePath+"&width=333&heigth=333";
   }
  
}


function mouseOver(hoverimage)
{
    var test = document.image1.src ="Admin/imageResizeFunction.php?filename="+hoverimage+"&width=800&heigth=800";
    
}
function mouseOut(image)
{
	document.image1.src ="Admin/imageResizeFunction.php?filename="+image+"&width=800&heigth=800";
	
}
function conformAvailiability()
{
	var r=confirm('You will be redirected to list of "out of stock" items.');
	if (r==true)
	{
	 return true;
	}
    else
    {
	  return false;
    }
}
function checkFunction(alerts)
{
	var r=confirm(alerts);
	if (r==true)
	{
	 return true;
	}
    else
    {
	  return false;
    }

}
function removeText()
{
	if(document.getElementById('username').value == "Email")
	{
		document.getElementById('username').value ="";
		document.frmLogin.username.focus();
		return false ;
	}
}
function removeTextPassword()
{
	if(document.getElementById('password').value == "Password")
	{
		document.getElementById('password').value ="";
		document.frmLogin.password.focus();
		return false ;
	}
}
function validateUserLogin()
	{
		if(isEmpty(document.getElementById('username').value))
		{
			alert('Please enter your email.');
			document.frmLogin.username.focus();
			return false ;
		}
		if(!IsValidEMail(document.getElementById('username').value))
		 {
			alert('Email address is not valid.');
			document.frmLogin.username.focus();
			return false ;
		 }
		if(isEmpty(document.getElementById('password').value))
		{
			alert('Please enter your password.');
			document.frmLogin.password.focus();
			return false ;
		}
	}
	
 function validateUserRegistration()
	 {
		 if(isEmpty(document.getElementById('email').value))
		 {
			alert('Please enter your email.');
			document.frmRegister.email.focus();
			return false ;
		 }
		 if(!IsValidEMail(document.getElementById('email').value))
		 {
			alert('Email address not valid.');
			document.frmRegister.email.focus();
			return false ;
		 }
		 if(isEmpty(document.getElementById('passwrd').value))
		 {
			alert('Please enter your password.');
			document.frmRegister.passwrd.focus();
			return false ;
		 }
		 if(document.getElementById('passwrd').value!=document.getElementById('passwrdConfirm').value)
		 {
			alert("Please verify your password.");
			document.frmRegister.passwrdConfirm.focus();
			return false;
		 }
		 if(isEmpty(document.getElementById('firstName').value))
		 {
			alert('Please enter your first name.');
			document.frmRegister.firstName.focus();
			return false ;
		 }
		 if(isEmpty(document.getElementById('city').value))
		 {
			alert('Please enter your city.');
			document.frmRegister.city.focus();
			return false ;
		 }
		 if(isEmpty(document.getElementById('dateOfBirth').value))
		 {
			alert('Please enter your birth date.');
			document.frmRegister.dateOfBirth.focus();
			return false ;
		 }
		 if(isEmpty(document.getElementById('code').value))
		 {
			alert('Please enter security Code as shown the image above.');
			document.frmRegister.code.focus();
			return false ;
		 }
	 }
	 
  function validateForgotPassword()	 
     {
	     if(isEmpty(document.getElementById('email').value))
		 {
			alert('Please enter your email.');
			document.frmForgotPassword.email.focus();
			return false ;
		 }
		 if(!IsValidEMail(document.getElementById('email').value))
		 {
			alert('Email address not valid.');
			document.frmForgotPassword.email.focus();
			return false ;
		 }
	 }
	 
   function validateChangePassword()
     {
	      if(isEmpty(document.getElementById('currentPasswrd').value))
		  {
			alert('Please enter your current password.');
			document.frmEditProfile.currentPasswrd.focus();
			return false ;
		  }
		  if(isEmpty(document.getElementById('newPasswrd').value))
		  {
			alert('Please enter your new password.');
			document.frmEditProfile.newPasswrd.focus();
			return false ;
		  }
		  if(document.getElementById('newPasswrd').value!=document.getElementById('confirmPaaswrd').value)
		  {
			alert("Please verify your password.");
			document.frmEditProfile.confirmPaaswrd.focus();
			return false;
		  }
	 }
	 
  function validateManageUsersDetails()
	 {
	    
		 if(isEmpty(document.getElementById('userEmailId').value))
		 {
			alert('Please enter your email.');
			document.frmEditProfile.userEmailId.focus();
			return false ;
		 }
		 if(!IsValidEMail(document.getElementById('userEmailId').value))
		 {
			alert('Email address not valid.');
			document.frmEditProfile.userEmailId.focus();
			return false ;
		 }
		 if(isEmpty(document.getElementById('firstName').value))
		 {
			alert('Please enter your first name.');
			document.frmEditProfile.firstName.focus();
			return false ;
		 }
		 /*if(isEmpty(document.getElementById('userCountry').value))
		 {
			alert('Please enter your country.');
			document.frmEditProfile.userCountry.focus();
			return false ;
		 }*/
		 if(isEmpty(document.getElementById('userCity').value))
		 {
			alert('Please enter your city.');
			document.frmEditProfile.userCity.focus();
			return false ;
		 }
		 if(isEmpty(document.getElementById('dateOfBirth').value))
		 {
			alert('Please enter your birth date.');
			document.frmEditProfile.dateOfBirth.focus();
			return false ;
		 }
		 if(!isEmpty(document.getElementById('billingEmailAddress').value))
		 {
			 if(!IsValidEMail(document.getElementById('billingEmailAddress').value))
			 {
				alert('Billing email address not valid.');
				document.frmEditProfile.billingEmailAddress.focus();
				return false ;
			 }
		 }
	 }
	
	/*
 +-------------------------------------------------------------------+
 |	PURPOSE : 	Checks if the provided field value is empty
 |	ARGUMENTS : value of the field
 |	RETURN VALUE : true or false
 +-------------------------------------------------------------------+
*/
/*function isNumericforUpdate(elem, helperMsg)
{
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression))
	{
		return true ;
	}
	else
	{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}*/
function isEmpty(elementValue)
{
	if( (elementValue=="") || (elementValue==null) )
	{
		return true;	//if empty
	}
	else
	{
		return false;	//if not empty
	}
}
function IsValidEMail(strValue)
{
	nNoOfArguments = IsValidEMail.arguments.length;
	//if no parameter is supplied
	if(nNoOfArguments < 1)
	{
		return false;
	}	
	
	var strVal	= new String(strValue);
	var bReturn1 = false;
	var bReturn2 = false;
	var bReturn3 = false;
	var bReturn4 = false;
	var bReturn5 = false;
	var bReturn5 = false;
	
	//if '@' comes after first character then true
	bReturn1	=	(strValue.indexOf("@") > 0);							
	
	//if '.' comes after first character then true
	bReturn2	=	(strValue.indexOf(".") > 0);							
	
	//if single '@' exist in string then true
	bReturn3	=	(strValue.indexOf("@") == strValue.lastIndexOf("@"));	
	
	//if '.' exist after @ in string then true
	bReturn4	=	(strValue.indexOf(".",strValue.indexOf("@")) > (strValue.indexOf("@")));		
	
	//if '.' does not comes immediatly after @ then true
	bReturn5	=	(strValue.indexOf(".",strValue.indexOf("@")) != (strValue.indexOf("@")+1));		
	
	//if '.' does not comes immediatly before @ then true
	bReturn6	=	(strValue.lastIndexOf(".",strValue.indexOf("@")) != (strValue.indexOf("@")-1)); 
	
	//if all values are true return true else false.
	return(bReturn1 && bReturn2 && bReturn3 && bReturn4 && bReturn5 && bReturn6);
}


///////////to get date difference////////////
function DateDiffrence(timediff) 
{
		/*months = Math.floor(timediff / (60 * 60 * 24 * 31));
		timediff -= months * (60 * 60 * 24 * 31);
		
		weeks = Math.floor(timediff / (60 * 60 * 24 * 7));
		timediff -= weeks * (60 * 60 * 24 * 7);*/
		
		days = Math.floor(timediff / (60 * 60 * 24)); 
		timediff -= days * (60 * 60 * 24);
		
		hours = Math.floor(timediff / (60 * 60)); 
		timediff -= hours * (60 * 60);
		
		mins = Math.floor(timediff / (60)); 
		timediff -= mins * (60);
		
		//alert(months);
		
		/*if(months > 0)
		{
		var difference = months + " months";
		}*/
		/*else if(weeks > 0)
		{
		var difference = weeks + " weeks";
		}*/
		if(days > 0)
		{
		var difference = days + " Days, " + hours + " Hrs, " + mins + " Mins";
		}
		else if(hours > 0)
		{
		var difference =hours + " Hrs, " + mins + " Mins";
		}
		else if(mins == 0)
		{
		var difference =1 + " Mins";
		}
		else
		{
		var difference =mins + " Mins";
		}
		return difference;
}


//code to print page
function beforeprint()
    { 
    
		document.getElementById('printOrders').style.display ='none'  ;
	   // document.getElementById('Refresh1').style.display ='none'  ;
    
    }
    function aftreprint()
    {
      document.getElementById('printOrders').style.display ='block'  ;
      //document.getElementById('Button1').style.display ='block'  ;
      //document.getElementById('Refresh1').style.display ='block'  ;
      //document.getElementById('btn_Print1').style.display ='block'  ;
  
    }
    window.onbeforeprint=beforeprint
    window.onafterprint=aftreprint

   function fnPrint()
    {
		try
		{
			 window.print(); 
			   return false;
		}
		catch(err)
		{
		 return false;
		alert(err)
		}
    }
	
	
  function validateURL(argvalue) 
	{
	 //var argvalue=document.getElementById('txt').value;
	 
	  if (argvalue.indexOf(" ") != -1)
		{
		 alert("Enter the valid url");
		 return false;
		} 
	  else if (argvalue.indexOf("http://") == -1)
	   {
		 alert("Enter the valid url");
		 return false;
		} 
	  else if (argvalue == "http://")
		{
		 alert("Enter the valid url");
		 return false;
		} 
	  else if (argvalue.indexOf("http://") > 0)
	   {
		 alert("Enter the valid url");
		 return false;
		} 
	
	  argvalue = argvalue.substring(7, argvalue.length);
	  if (argvalue.indexOf(".") == -1)
		{
		 alert("Enter the valid url");
		 return false;
		} 
	  else if (argvalue.indexOf(".") == 0)
		{
		 alert("Enter the valid url");
		 return false;
		} 
	  else if (argvalue.charAt(argvalue.length - 1) == ".")
		{
		 alert("Enter the valid url");
		 return false;
		} 
	
	  if (argvalue.indexOf("/") != -1) {
		argvalue = argvalue.substring(0, argvalue.indexOf("/"));
		if (argvalue.charAt(argvalue.length - 1) == ".")
		  {
		 alert("Enter the valid url");
		 return false;
		} 
	  }
	
	  if (argvalue.indexOf(":") != -1) 
	  {
		if (argvalue.indexOf(":") == (argvalue.length - 1))
		  {
		 alert("Enter the valid url");
		 return false;
		} 
		else if (argvalue.charAt(argvalue.indexOf(":") + 1) == ".")
		  {
		 alert("Enter the valid url");
		 return false;
		} 
		argvalue = argvalue.substring(0, argvalue.indexOf(":"));
		if (argvalue.charAt(argvalue.length - 1) == ".")
		  {
		 alert("Enter the valid url");
		 return false;
		} 
	  }
	
	  return true;
	
	}

function setLargeImage(imagePath,largeImageId)
{
   var xmlHttp = getXMLHttp();
   
   document.getElementById('largeImage').innerHTML = '<img src="images/ajax-loader.gif" height="20" width="20" style="vertical-align:top;" />&nbsp;&nbsp;Loading Image...';
   xmlHttp.onreadystatechange = function()
   {
	if(xmlHttp.readyState == 4)
	{
	  document.getElementById('largeImage').innerHTML = xmlHttp.responseText;
	}
   }
  xmlHttp.open("GET", "ajax.php?path="+imagePath+"&msg=showLargeImage", true);
  xmlHttp.send(null);
  
   /*if(navigator.appName=="Microsoft Internet Explorer")
   {
   document.getElementById('largeImage').src = "Admin/imageResizeFunction.php?filename="+imagePath+"&width=400&heigth=400";
   }
   else
   {
   document.largeImage.src = "Admin/imageResizeFunction.php?filename="+imagePath+"&width=400&heigth=400";
   }*/
  
}

function getXMLHttp()
{
  var xmlHttp

  try
  {
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    //Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}


function MakeRequestForColors(productId,colorId)
{
 document.getElementById('hideSingleColorDiv').style.display='none';
  var xmlHttp = getXMLHttp();
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
	  document.getElementById('ResponseDivSizeBars').innerHTML = xmlHttp.responseText;
    }
  }
  xmlHttp.open("GET", "ajax.php?id="+colorId+"&productId="+productId+"&msg=forSizeBars", true); 
  xmlHttp.send(null);
}
function MakeRequestForSingleColors(productId,colorId)
{
  var xmlHttp = getXMLHttp();
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
	  document.getElementById('ResponseDivSizeBars').innerHTML = xmlHttp.responseText;
    }
  }
  xmlHttp.open("GET", "ajax.php?id="+colorId+"&productId="+productId+"&msg=forSizeBars", true); 
  xmlHttp.send(null);
}
/*============================================================================*/


/*************************************************************************\
boolean luhnCheck([String CardNumber])
return true if CardNumber pass the luhn check else return false.
Reference: http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl
\*************************************************************************/
function luhnCheck(card_number) 
{
    var CardNumber = card_number;
	var no_digit = CardNumber.length;
	var oddoeven = no_digit & 1;
	var sum = 0;
    

	for (var count = 0; count < no_digit; count++) 
	{
		var digit = parseInt(CardNumber.charAt(count));
		if (!((count & 1) ^ oddoeven)) 
		{
			digit *= 2;
			if (digit > 9)
				digit -= 9;
		}
			sum += digit;
	}
	if (sum % 10 == 0)
		return true;
	else
		return false;
}
function goToNextPage()
{
	document.getElementById('frmOutOfStock1').action = "outOfStockCart2.php";
	document.getElementById('frmOutOfStock1').submit();
}

function validateCreditCard()
{
	var creditNumber = document.getElementById('creditCardNum').value;
	var dateExpiredOn = document.getElementById('creditCardExpiaryDate').value;
	var currentTime = new Date()
	var month = currentTime.getMonth() + 1
	if(month <= '9')
	{
		var month1 = currentTime.getMonth() + 1
		var month = "0"+month1;
	}
	var day = currentTime.getDate()
	if(day <= '9')
	{
		var day1 = currentTime.getDate()
		var day = "0"+day1;
	}
	var year = currentTime.getFullYear()
	var todayDate = month + "/" + day + "/" + year;
   
	if(isEmpty(document.getElementById('creditCardType').value))
	{
		alert('Please select a credit card type.');
		document.frmPaymentInfo.creditCardType.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('creditCardNum').value))
	{
		alert('Please enter a credit card number.');
		document.frmPaymentInfo.creditCardNum.focus();
		return false ;
	}
	else if (!luhnCheck(creditNumber))
	{
		alert('Please enter a valid credit card number.');
		document.frmPaymentInfo.creditCardNum.focus();
		return false ;	
	}
	if(isEmpty(document.getElementById('creditCardHolder').value))
	{
		alert('Please enter card holder name.');
		document.frmPaymentInfo.creditCardHolder.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('creditCardExpiaryDate').value))
	{
		alert('Please choose expiry date.');
		document.frmPaymentInfo.creditCardExpiaryDate.focus();
		return false ;
	}
	else if(dateExpiredOn < todayDate)
	{
		alert('Expiry date should be greater or equal to current date.');
		document.frmPaymentInfo.creditCardExpiaryDate.focus();
		return false ;
	}
	//document.getElementById('frmPaymentInfo').action = "orderPlacedOutStock.php";
	document.getElementById('frmPaymentInfo').action = "outOfStockCart3.php";
	document.getElementById('frmPaymentInfo').submit();
	
}

function validateCreditCardForOrder()
{
	var cvv = document.getElementById('cvvNumber');
	var creditNumber = document.getElementById('creditCardNum').value;
	if(isEmpty(document.getElementById('creditCardType').value))
	{
		alert('Please select a credit card type.');
		document.frmPaymentInfo.creditCardType.focus();
		return false ;
	}
	if(isEmpty(document.getElementById('creditCardNum').value))
	{
		alert('Please enter a credit card number.');
		document.frmPaymentInfo.creditCardNum.focus();
		return false ;
	}
	else if (!luhnCheck(creditNumber))
	{
		alert('Please enter a valid credit card number.');
		document.frmPaymentInfo.creditCardNum.focus();
		return false ;	
	}
	if(isEmpty(document.getElementById('creditCardHolder').value))
	{
		alert('Please enter card holder name.');
		document.frmPaymentInfo.creditCardHolder.focus();
		return false ;
	}
	if(!isEmpty(document.getElementById('cvvNumber').value))
	{
	 if(!isNumericforUpdate(cvv))
	 {
		alert('Please enter a valid cvv number.');
		document.frmPaymentInfo.cvvNumber.focus();
		return false ;
	 }
	}
	/*if(isEmpty(document.getElementById('creditCardExpiaryDate').value))
	{
		alert('Please choose expiry date.');
		document.frmPaymentInfo.creditCardExpiaryDate.focus();
		return false ;
	}
	else if(dateExpiredOn < todayDate)
	{
		alert('Expiry date should be greater or equal to current date.');
		document.frmPaymentInfo.creditCardExpiaryDate.focus();
		return false ;
	}*/
	document.getElementById('frmPaymentInfo').action = "checkOutStep3.php";
	document.getElementById('frmPaymentInfo').submit();
	
}