
//makeRequest("../ecom/shopping_bag.asp?rnd="+Math.random(),'shopping_bag',0);
//alert(0);
function FlashDetector_Detect() {
    var pObj = null;
    var tokens, len, curr_tok;
    var hasVersion = -1;
	var playable;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
    alert(plugin);
	
	if(navigator.mimeTypes && navigator.mimeTypes['application/x-shockwave-flash'])
    {
        pObj = navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin;
    }	

    if(pObj != null)
    {
        tokens = navigator.plugins['Shockwave Flash'].description.split(' ');
        len = tokens.length;
        while(len--)
        {
            curr_tok = tokens[len];
            if(!isNaN(parseInt(curr_tok)))
            {
                hasVersion = curr_tok;
                FlashDetector_Version = curr_tok;
                break;
            }
        }
        if(hasVersion >= FlashDetector_TargetVersion)
        {
            playable = true;
        }
        else
        {
            playable = false;
        }
    }
	
    return playable;
}

function pause(millisecondi)
{
    var now = new Date();
    var exitTime = now.getTime() + millisecondi;

    while(true)
    {
        now = new Date();
        if(now.getTime() > exitTime) return;
    }
}

function getsegments(prdid, sizeid, colorid,obj)
{
   if(document.getElementById('product_variations')!= null)
      document.getElementById('product_variations').innerHTML=""; 
   
  if(document.getElementById('product_price')!= null)
      document.getElementById('product_price').innerHTML=""; 
               
   if(sizeid >0 && colorid >0) 
	makeRequest("../ecom/product_variations.asp?prdid="+prdid+"&size="+sizeid+"&color="+colorid+"&rnd="+Math.random(),obj,0);
}

function getproductImage(prdid, sizeid, colorid,obj)
{
   //if(sizeid >0 && colorid > 0 ) 
   //{
    	makeRequest("../ecom/product_image.asp?prdid="+prdid+"&size="+sizeid+"&color="+colorid+"&rnd="+Math.random(),obj,0);
   //}
}
function getproductincrement(prdid, sizeid, obj, pType)
{	
 if(sizeid >0) 
  {
	waitmessage(obj,0);
	makeRequest("../ecom/product_increment.asp?prdid="+prdid+"&size="+sizeid+"&rnd="+Math.random(),obj,pType);
  }
  else
  makeRequest("../ecom/product_image.asp?prdid="+prdid+"&size="+sizeid+"&color=0&rnd="+Math.random(),'product_image',0);
}

function getproductcolors(prdid, sizeid, obj,ptype)
{
    var selcolor = 0;
    if(document.getElementById('selcolor') != null)
    selcolor	= document.getElementById('selcolor').value;

	clear('product_price');
	if (sizeid==0) waitmessage('product_increment',1);
    if(document.getElementById('color')!=null)
	document.getElementById('color').focus();
	//if(sizeid == 0 )
    makeRequest("../ecom/product_colors.asp?prdid="+prdid+"&size="+sizeid+"&c="+selcolor+"&rnd="+Math.random(),obj,ptype);
}
function getproductcode(prdid, sizeid, colorid,obj)
{
	makeRequest("../ecom/product_code.asp?prdid="+prdid+"&size="+sizeid+"&color="+colorid+"&rnd="+Math.random(),obj,6);
}
function getproductprice(prdid, sizeid, colorid,pqty,full, obj)
{
    if(sizeid > 0 && colorid >0)
    {
        waitmessage(obj,0);
	    if (pqty == -1 )
	    {
    		
		    document.getElementById('quantity').count=0;
		    makeRequest("../ecom/product_increment.asp?prdid="+prdid+"&size="+sizeid+"&full=true&rnd="+Math.random(),'product_increment',6);
	    }
	    else
	    {
    	
		    makeRequest("../ecom/get_product_price.asp?prdid="+prdid+"&size="+sizeid+"&color="+colorid+"&qty="+pqty+"&full="+full+"&rnd="+Math.random(),obj,0);
	    }
   }
}
function addtocart(prdid,obj)
{ 
 var sizeid = 0;
 var colorid = 0 ;
 var pqty = 0;
 var pprice = 0;
   
   if(document.getElementById('size') != null)
   sizeid  = document.getElementById('size').value;
   
   if(document.getElementById('color') != null)
   colorid = document.getElementById('color').value;
   
   if(document.getElementById('quantity') != null)
   pqty    = document.getElementById('quantity').value;
   
   if(document.getElementById('prdPrice') != null)
   pprice = document.getElementById('prdPrice').value;
   
if(colorid==0)
	{
	alert("Please select a color to proceed with Shopping.");
	return false;
	}
else
	{
	makeRequest("../ecom/shopping_bag.asp?prdid="+prdid+"&size="+sizeid+"&color="+colorid+"&qty="+pqty+"&cprice="+pprice+"&rnd="+Math.random(),obj,7);
	document.getElementById('addtobag').src=siteUrl+'graphics/add_to_bag_pressed.gif';
	alert('This item has been added to your cart successfully.');

	return true;
	}
}
function addsamplereqeuestocart(prdid,sizeid,colorid,pqty,pprice,obj)
{
    if(colorid == 0 || sizeid==0)
        {alert("Please select color and size for sample");}
     else
    {
	    makeRequest("../ecom/shopping_bag.asp?prdid="+prdid+"&size="+sizeid+"&color="+colorid+"&qty="+pqty+"&cprice="+pprice+"&sample=1&rnd="+Math.random(),obj,7);
		  if (document.getElementById('SampleMax') != null)
	         {
                alert('Sorry, there is a limit of 5 free samples per order.');
	         }

		  if (document.getElementById('SampleMax') == null)
	         {
	         alert('This item has been added to your cart successfully.');
	         }
	}
}
function updatecartstatus(obj)
{
	makeRequest("../ecom/product_cart_status.asp?rnd="+Math.random(),obj,0);
}

function getShippingOptions(toaddress1, toaddress2,tozip, tocountry, weight,ordrid,city,tostate,bups,bfedex,bupsno,obj)
{

waitmessage('shipping_info',2);
	makeRequest("../ecom/get_shipping_options.asp?id="+ordrid+"&address1="+toaddress1+"&upsnumber="+bupsno+"&address2="+toaddress2+"&zip="+tozip+"&country="+tocountry+"&weight="+weight+"&city="+city+"&state="+tostate+"&bups="+bups+"&bfedEx="+bfedex+"&rnd="+Math.random(),obj,0);
}

function cart_order_summary(orderid,pstate,pcountry, pshipping,thirdparty,taxid,bups,bfedex, obj)
{

	makeRequest(securesiteUrl+"ecom/order_summary.asp?oid="+orderid+"&state="+pstate+"&shipping="+pshipping+"&country="+pcountry+"&party="+thirdparty+"&taxid="+taxid+"&bups="+bups+"&bfedEx="+bfedex+"&rnd="+Math.random(),obj,0);
}

function waitmessage(obj,typ)
{
	
	var mobj =document.getElementById(obj);
	var msg;
	msg="Please wait.... "
	if (typ==1) msg="Please select a size from the above pulldown to proceed with Shopping."
	if (typ==2) msg="Please wait while we calculate your shipping options. if you doesn't get the Shipping option in 30 seconds.  <a href='javascript:checkJAMShipping();'>Click</a> here to retry.";

	if (typ==3) msg="Please select a color to proceed with Shopping."
	if (mobj !=null)
	
	{
		document.getElementById(obj).innerHTML="<span class='text_heading_red'><br><strong>" +msg +"</strong></span>";
	}
}
function clear(obj)
{
	var mobj =document.getElementById(obj);
	if (mobj =='object')
	{
		document.getElementById(obj).innerHTML="";
	}
}

function changeswatchimage(idx)
{
sclr = document.getElementById("selcolor").value;
sidx = document.getElementById("swatchindex").value;
if (sidx == 0 &&  sclr==0)
sidx =-1
var cnt=0;
tbls= document.getElementsByTagName("table");
for (i=0;i<tbls.length;i++)
		{
	objname = tbls[i].id
	if(objname.indexOf('swatch') != -1 )
		{
			if (cnt == idx || cnt == sidx )
				tbls[i].className='tbl_border'
			else 
				tbls[i].className='tbl_noborder'
		
			cnt++;
		}
	}
}
function swapimage(obj,path,img1,img2)
{

	if (document.getElementById(obj).src == path+img1)
		document.getElementById(obj).src=path+img2;
	else
		document.getElementById(obj).src=path+img1;
}

function nextfunction(pType)
{
if (pType ==8)
{
    //alert("i am here 6")
    updateprice();	
return true;
}

if (pType == 9)
{
    //alert("i am here 2")
    pidx = document.getElementById("cid").value;
    if (trim(document.getElementById('errtext').value) != "") {
        alert(document.getElementById('errtext').value)
        document.getElementById('UpdateCart').disabled = true;
        document.getElementById("qty" + pidx).focus();
        return false;
    }
    else {
        //alert("i am here 4")
        document.getElementById('UpdateCart').disabled = false;
        document.getElementById('txtmaxqty').value = '';
       // return true;
    }
    pqty = document.getElementById("qty" + pidx).value;
    obj = "divprice" + pidx;
    //makeRequest("cart_price_update.asp?id="+pidx+"&qty="+pqty+"&rnd="+Math.random(),obj,8);
    makeRequest("cart_price_update.asp?id=" + pidx + "&qty=" + pqty + "&rnd=" + Math.random(), obj, 11);
    return true;
}


if (pType == 11)
{
    //alert("i am here 5")

 pidx = document.getElementById("cid").value;
 iProductid   =  document.getElementById('productid'+pidx).value; 
 iColorId     = document.getElementById('color'+pidx).value;  
 pqty = document.getElementById("qty"+pidx).value;
 psize = document.getElementById("size"+pidx).value;
  
obj = "divsegprice"+pidx;

//makeRequest("cart_seg_price_update.asp/color/" + iColorId + "/qty/" + pqty + "/prd/" + iProductid + "/size/" + psize + "/rnd/" + Math.random(), obj, 8);
makeRequest("cart_seg_price_update.asp?color=" + iColorId + "&qty=" + pqty + "&prd=" + iProductid + "&size=" + psize + "&rnd=" + Math.random(), obj, 8);
//  makeRequest("cart_seg__price_update.asp?id="+pidx+"&qty="+pqty+"&rnd="+Math.random(),obj,8);
return true;
}

colorid = 0;
prdid		= document.getElementById('prdId').value;
sizeid		= document.getElementById('size').value;
selcolor = 0;
if(document.getElementById('color') != null)
colorid	= document.getElementById('color').value;

if(document.getElementById('selcolor') != null)
selcolor	= document.getElementById('selcolor').value;

//alert(pType)
if (sizeid==0) waitmessage('product_increment',1);

switch (pType)
	{
	case 1: //Get product colors
		makeRequest("../ecom/product_colors.asp?prdid="+prdid+"&size="+sizeid+"&c="+selcolor+"&rnd="+Math.random(),'product_colors',2);
		break;
	case 2: //get product code
      if(document.getElementById('color') != null)
	   {
	    if(document.getElementById('color').value != 0)
	    {
	      if(document.getElementById('color').length > 1)
	        lessindex = 1;
	      else
	         lessindex = 0;
	      
	      document.getElementById('swatchindex').value = document.getElementById('color').selectedIndex - lessindex;   
	      changeswatchimage(document.getElementById('color').selectedIndex - lessindex);   
	      document.getElementById('color').focus();   
	     }
	   }
		makeRequest("../ecom/product_code.asp?prdid="+prdid+"&size="+sizeid+"&color="+colorid+"&rnd="+Math.random(),'product_code',3);
		break;
	case 3: //get product image

	    if(sizeid >0 &&  colorid > 0)
	    {
    		makeRequest("../ecom/product_image.asp?prdid="+prdid+"&size="+sizeid+"&color="+colorid+"&rnd="+Math.random(),'product_image',4);
        }
        if( sizeid > 0 && colorid == 0)
        {
          //  makeRequest("../ecom/product_variations.asp?prdid="+prdid+"&size="+sizeid+"&color="+colorid+"&rnd="+Math.random(),'product_variations',6);
            makeRequest("../ecom/product_image.asp?prdid="+prdid+"&size="+sizeid+"&color="+colorid+"&rnd="+Math.random(),'product_image',0);
		}
		if(sizeid != 0 && colorid==0)
	      waitmessage('product_price',3);
		break;

	case 4: //get product variations./setments
            if(document.getElementById('product_variations')!= null)
               document.getElementById('product_variations').innerHTML="";    

            if(sizeid >0 &&  colorid > 0)
	                makeRequest("../ecom/product_variations.asp?prdid="+prdid+"&size="+sizeid+"&color="+colorid+"&rnd="+Math.random(),'product_variations',6);
	    
	      
		break;
	case 5: //get product Increment
		//makeRequest("../ecom/product_increment.asp?prdid="+prdid+"&size="+sizeid+"&rnd="+Math.random(),'product_increment',6);
		break;
	case 6: //get Product Price
	    if(sizeid != 0 && colorid!=0)
	    {
         if (document.getElementById('quantity')!=null)
	       {
	         qty		= document.getElementById('quantity').value;
		     makeRequest("../ecom/get_product_price.asp?prdid="+prdid+"&size="+sizeid+"&color="+colorid+"&qty="+qty+"&rnd="+Math.random(),'product_price',0);
	       }
	    }
	     if(sizeid != 0 && colorid==0)
	        waitmessage('product_price',3);
		break;
	case 7:
		//updatecartstatus('cart_status');
		makeRequest("../ecom/product_cart_status.asp?&rnd="+Math.random(),'cart_status',0);
    break;
    case 10:
        getproductcolors(prdid,sizeid,'product_colors',2);
        break;
	}
	return true;
}



/*********Start  Cart Function *********************/

function cart_continue()
{
    if (trim(document.getElementById('errtext').value) == "") {
        location.href = "/ecom/index.asp/show/list/cat/52";
    }
}

function cart_empty()
{
	document.getElementById('action').value='empty';
	document.getElementById('frmcart').submit();
}


function cart_checkout()
{
	document.getElementById('action').value='checkout';
	document.getElementById('frmcart').submit();
}

function cart_update()
{
	document.getElementById('action').value='update';
	document.getElementById('frmcart').submit();
	
}

function cart_delete(pid)
{
	document.getElementById('action').value='delete';
	document.getElementById('sid').value=pid;
	document.getElementById('frmcart').submit();
	
}


/*********End  Cart Function *********************/




