// JavaScript Document

function updateQtyTextBox(strPlusMinus,intCursor)
{

// alert('strPlusMinus='&strPlusMinus)
 //alert('intCursor='&intCursor)

	 var eleName;
	 var qtyValue;
	 var txtObj;

	 eleName = "txtQty" + intCursor;
	 
	 //alert("eleName="+eleName)
	 		
	 txtObj = eval('document.frmCreateBasket.'+eleName);
	 qtyValue = eval('document.frmCreateBasket.'+eleName+'.value');

	 //alert("qtyValue="+qtyValue)
	
	
	 
	 if(strPlusMinus == "+")
	 {
		if (isANumber(qtyValue)) 
		{
			if(parseInt(qtyValue) < 99)
			{	 
				txtObj.value = parseInt(qtyValue) + 1;
			}
		}
		else
		{
			txtObj.value = "0";
		}
	 }
	 if(strPlusMinus == "-")
	 {
	 	if(isANumber(qtyValue))
		{
			if(parseInt(qtyValue) > 0)
			{
				txtObj.value = parseInt(qtyValue) - 1 ;
			}
		}
		else
		{
			txtObj.value = "0";
		}
	 }
}

function writeQtyTextBox(txtObj)
{
	 var arrEle;
	 var eleName;

	if (isANumber(txtObj.value)) 
	{
		if(parseInt(txtObj.value) < 0)
		{
			txtObj.value = "0";
		}
		if(parseInt(txtObj.value) > 100)
		{
			txtObj.value = "100";
		}
	}
	else
	{
		txtObj.value = "0";  
	}			
}

function MM_openBrWindow(theURL,winName,features) 
{ 
 tt = document.getElementById("cur_img");
   var str = tt.src;
   var arr = str.split("_");
       str = arr[0] + "_large.jpg"
   var temp = str.split('images');
  theURL = "/pop/product-largeimage.asp?strLargeImgUrl=/images" + temp[1];
  window.open(theURL,winName,features);
}

function View_Next_Image(theURL,ImageCount) 
{ 
	if([ImageCount]>0)
	{
	
	var mycars = new Array();
	mycars[1] = "a";
	mycars[2] = "b";
	mycars[3] = "c";
	mycars[4] = "d";
	

   tt = document.getElementById("zoom_"+ImageCount);
   th = document.getElementById("zoom_hidden_"+ImageCount);
   var str = tt.src;
   var pos = ((str.indexOf("_"))-1);
	  
	  theURLh=theURL;
	  if(mycars[ImageCount]==str.charAt(pos))
	   {
		  theURL = '/images/product/' + theURL + "_200.jpg"; 
		  theURLh = '/images/product/' + theURLh + "_large.jpg"; 
	   }
	   else
	   {
		   if((str.charAt(pos)=='a')&&(ImageCount >=2))
		   {
			   theURL = '/images/product/' + theURL + "b_200.jpg";
			   theURLh = '/images/product/' + theURLh + "b_large.jpg";
		   }
		   else
			  {
				  if((str.charAt(pos)=='b')&&(ImageCount >=3))
				   {
					   theURL = '/images/product/' + theURL + "c_200.jpg";
 				       theURLh = '/images/product/' + theURLh + "c_large.jpg";
				   }
				   else {
					   
						   if((str.charAt(pos)=='c')&&(ImageCount >=4))
							   {
								   theURL = '/images/product/' + theURL + "d_200.jpg";
								   theURLh = '/images/product/' + theURLh + "d_large.jpg";
							   }
							   else
							   {
								   theURL = '/images/product/' + theURL + "a_200.jpg";
								    theURLh = '/images/product/' + theURLh + "a_large.jpg";
							   }
					   } 
						  
				  }
	   }
     tt.src = theURL;
    th.value = theURLh;
	
	}
}


function isANumber(strCheck)
{
	var iChars = "0123456789";
	
 	for (var i = 0; i < strCheck.length; i++) 
 	{
      	if (iChars.indexOf(strCheck.charAt(i)) == -1)
        	 return false;
   	}
	return true;
}


function updateQtyTextBox1(strPlusMinus,intCursor)
{

// alert('strPlusMinus='&strPlusMinus)
 //alert('intCursor='&intCursor)

	 var eleName;
	 var qtyValue;
	 var txtObj;

	 eleName = "qty" + intCursor;
	 
	 //alert("eleName="+eleName)
	 		
	 txtObj = eval('document.frmCreateBasket.'+eleName);
	 qtyValue = eval('document.frmCreateBasket.'+eleName+'.value');

	 //alert("qtyValue="+qtyValue)
	
	
	 
	 if(strPlusMinus == "+")
	 {
		if (isANumber(qtyValue)) 
		{
			if(parseInt(qtyValue) < 99)
			{	 
				txtObj.value = parseInt(qtyValue) + 1;
			}
		}
		else
		{
			txtObj.value = "0";
		}
	 }
	 if(strPlusMinus == "-")
	 {
	 	if(isANumber(qtyValue))
		{
			if(parseInt(qtyValue) > 0)
			{
				txtObj.value = parseInt(qtyValue) - 1 ;
			}
		}
		else
		{
			txtObj.value = "0";
		}
	 }
}
