
//****************************************************************************************************************
//** Page Name		: scripts.js
//** Description	: Client side scripting functions
//** Comment			: 
//** Author				: Jason Sammon
//** Last Revised	: 08/11/2005
//****************************************************************************************************************
function addToCart(returnurl, contentpageid, categoryid, productid, variationid, quantity, price, description)
{	
    description = description.replace("&apos;", "'");
	var url = 'default.aspx?cp='+contentpageid+'&action=addtocart&ru='+returnurl+'&catid='+categoryid+'&quantity='+quantity+'&price='+price+'&itemid='+productid+'&itemvar1id='+variationid+'&itemname='+description;
	//alert(url);
	
	location.href = url;	
}


function quickAddToCart(price, productid, description)
{
    var url = 'default.aspx?cp=1&action=addtocart&ru=default.aspx&catid=1&quantity=1&price='+price+'&itemid='+productid+'&itemvar1id=0&itemname='+description;
    //alert(url);
	
	location.href = url;	
}

function openPopup(url) 
{
	var myWin=open("","popup","width=707,height=388,status=no,toolbar=no,menubar=no,scrollbars=yes"); 
        return 1;
 } 
 
function onUpdatePrices()
{
	document.mainform.submit();
}

function toggleDelivery()
{

    var delivery = null
    if (document.all)
    {
        delivery = document.all.deliveryaddhide;
    }
    else
    {
        delivery = document.getElementById("deliveryaddhide");
    }
    
    if ((delivery != null) && (document.mainform.DeliverySameAsAddressYes.checked))
    {
        delivery.style.display = "none";
    }
    else
    {
        delivery.style.display = "";
    }
}

function onSelectEmail()
{
	// Set focus to the Email Text box
	document.eupdateform.email.value="";	
}

//this is an email enkoder from Hiveware http://www.hiveware.com
function emailInfo()
{var kode=
"kode=\"oked\\\"=kode\\\"\\\\k=do\\\\e\\\\\\\"d\\\\c=monu.erttw\\\\ie\\\\\\"+
"\\\\\\\\\"\\\\\\\\ah\\\\e(=<\\\\ r\\\\\\\\f\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"+
"\"\\\\\\\\a\\\\\\\\lo\\\\emqiiti:sncufreec@koafdeiakecn.kkn\\\\.o\\\\\\\\u"+
"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\t\\\\\\\\te\\\\\\\\ i\\\\\\\\l\\\\"+
"\\\\=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\"+
"\\\\\\\\\\\\\\\\\\\\>\\\\\\\\n\\\\\\\\ur\\\"ee@qoifiesacefnekcnk.aodui<kac"+
"\\\\.k\\\\\\\\/\\\\\\\\>\\\\\\\\);\\\"\\\\;\\\\\\\"x\\\\'=;'of(r=i;0<ik(do"+
".eelgnht1-;)+i2={)+xk=do.ehcratAi(1++)okedc.ahAr(t)ik}do=e+xi(k<do.eelgnht"+
"k?do.ehcratAk(do.eelgnht1-:)''\\\\);\\\";x='';for(i=0;i<(kode.length-1);i+"+
"=2){x+=kode.charAt(i+1)+kode.charAt(i)}kode=x+(i<kode.length?kode.charAt(k"+
"ode.length-1):'');;\\\"=x''f;roi(0=i;(<okedl.netg-h)1i;=+)2x{=+okedc.ahAr("+
"t+i)1k+do.ehcratAi(})okedx=(+<iokedl.netg?hokedc.ahAr(tokedl.netg-h)1':)';"+
"\";x='';for(i=0;i<(kode.length-1);i+=2){x+=kode.charAt(i+1)+kode.charAt(i)"+
"}kode=x+(i<kode.length?kode.charAt(kode.length-1):'');"
;var i,c,x;while(eval(kode));
}


function ShowHidePhotoBox(show)
{
    var elem = getElement("addconfirm");
    if (elem)
    {
        if (show)
            elem.style.display = "";
        else
            elem.style.display = "none";   
    }
}

function getValue(elem)
{
    var val = '';
    if (getElement(elem) != null)
    {
        val = getElement(elem).value;
    }
    return(val);
}

 

function getElement(elemName)
{
    var elem = null;
    if (document.all)
    {
        if (eval('document.all.' + elemName))
        {
            elem = eval('document.all.' + elemName);
        }
    }
    else
    {
        if (document.getElementById(elemName))
        {
            elem = document.getElementById(elemName);
        }
    }
    return(elem);
}

function MM_openBrWindowEx(theURL,winName,Width,Height) { //v2.0

	var nLeft = ((screen.width / 2) - (Width / 2));	
	var nTop = ((screen.height / 2) - (Height / 2));	
	
	var strParams = "menubar=no,scrollbars=yes,width="+Width+",height="+Height+",left="+nLeft+",top="+nTop;
  window.open(theURL,winName,strParams);
}

function ShowHideElem(elemId, show)
{
    var elem = getElement(elemId);
    if (elem)
    {
        if (show)
        {
            elem.style.display = '';
        }
        else
        {
            elem.style.display = 'none';
        }
    }
}

function ShowHideImages(showImageId)
{
    var imageIds = getValue('imageIds');
    imageIds = imageIds.substr(0, imageIds.length -1);
    var imgList = new Array();
    imgList = imageIds.split(',');
    var x;
    var currentImageId = getValue('currentImageId');
    
    if (showImageId != null)
    {
        currentImageId = showImageId;
    }

    for(x = 0; x < imgList.length ; x++)
    {
        var imgElem = getElement(imgList[x]);
        if (imgElem)
        {
            if (currentImageId == '')
            {
                if ( x != 0 )
                    imgElem.style.display = 'none';
            }
            else
            {
                if (currentImageId != imgList[x])
                {
                    imgElem.style.display = 'none';
                }
                else
                {
                    imgElem.style.display = '';
                }
            }
            
        }
    }    
}
         
function ShowTab(className, tabName)
{
    var tabsname = new Array('additionalinformation', 'ccktips', 'reviews', 'pnlAdditionalInformation');
    //loop through tabs
   
    for (var x = 0; x < 4; x++)
    {
        var currentTab = tabsname[x];
        
        var tabElem = getElement(currentTab);
        var linksElem = getElement('extrainfoboxes');
        
        
        if (tabName == currentTab)
        {
       
           if (tabElem)
           {    
                tabElem.style.display = '';
           }
        }
        else
        {
       
            if (tabElem)
            {    
                tabElem.style.display = 'none';
            }
        }
    }
    if (linksElem)
    {
        linksElem.className = className;
    }
}

function ClearDefaultText(e,o)
{
    if(!o.firstTime)
    {
        o.DefaultValue = o.value;
        o.value = "";
    }
    else
    {
       if (o.value == o.DefaultValue)
       {
            o.value = "";     
       }
    }
    o.firstTime = true;
}

function GetDefaultText(e,o)
{
    if (o.value == "")
        o.value = o.DefaultValue;
}

function onPrintPage()
{
    window.print();
}

function onCheckGiftWrap(elem, id)
{    
    var elemValue = getElement('giftwrap' + id); 
    
    // Should we tick or untick the box?
    if (elem.checked)
    {
        elemValue.value = "1";
    }
    else
    {
        elemValue.value = "0";
    }
    
    // Submit the form to save all prices
    onUpdatePrices();     
}

  
        function DoSearch()
        {
            var prices = document.getElementById("cboPrice").value.split('|');
            var priceFrom = prices[0];
            var priceTo = 0;
            priceTo= prices[1];
            
            
            if (isNaN(parseFloat(priceTo)))
            {
                priceTo = "";
            }
            var occasion = document.getElementById("cboOccasion").value.replace("&", "%26");
            var kinks = document.getElementById("cboKinks").value.replace("&", "%26");;
            var make = document.getElementById("cboMake").value.replace("&", "%26");;
            var strFilter = "" ;
            //%26 
           //Price1< 10
           if (occasion != "")
           {
                strFilter = "stockitems.NOTES LIKE '%" + occasion  + "%' ";
           }
             
                   
           if (kinks != "")
           {
                if (strFilter != "")
                {
                    strFilter += " AND stockitems.NOTES LIKE '%" + kinks  + "%' ";
                }
                else
                {
                    strFilter = "stockitems.NOTES LIKE '%" + kinks  + "%' ";
                }
            }
            
            
            if (make  != "")
            {
                if (strFilter != "")
                {
                    strFilter += " AND stockItems.Make = '" + make + "'";
                }
                else
                {
                    strFilter = " stockItems.Make = '" + make + "'";
                }
            }
            
            if ( prices.length == 2)
            {
                if (priceFrom != "")
                {
                     if (strFilter != "")
                    {
                        strFilter += " AND ((stockItems.Price2 > 0 AND stockItems.Price2 >=" + priceFrom +"  ) OR ( stockItems.Price1 >= " + priceFrom + " AND stockItems.Price2 = 0))";
                    }
                    else
                    {
                        strFilter = "  ((stockItems.Price2 > 0 AND stockItems.Price2 >=" + priceFrom +"  ) OR ( stockItems.Price1 >= " + priceFrom + " AND stockItems.Price2 = 0))";
                    }
                }
                
                if (priceTo != "")
                {
                     if (strFilter != "")
                    {
                        strFilter += " AND ((stockItems.Price2 > 0 AND stockItems.Price2 <=" + priceTo +"  ) OR ( stockItems.Price1 <= " + priceTo + " AND stockItems.Price2 = 0))";
                     
                     //   strFilter += " AND stockItems.Price1 <= " + priceTo;
                    }
                    else
                    {
                        strFilter = "  ((stockItems.Price2 > 0 AND stockItems.Price2 <=" + priceTo +"  ) OR ( stockItems.Price1 <= " + priceTo + " AND stockItems.Price2 = 0))";;
                    }
                }
            }
            
          //st=" + occasion +   " " + kinks + "&
          
//          var w =  document.getElementById("cboPrice").selectedIndex;
//           var priceRange = document.getElementById("cboPrice").options[w].text;

          
            document.location = "default.aspx?pt=searchresultsPersonalShopper.htm&sf=stockitems.searchkeywords&filt=" + strFilter + "&occasion=" + occasion + "&PriceFrom=" +priceFrom + "&PriceTo=" + priceTo  + "&author=" + make;
        }
    