
var _top=0
var _left=0
var _eventopen=false

var distancecursorX=0 //Customize x offset of tooltip
var distancecursorY=0 //Customize y offset of tooltip

var offsetdivfrompointerX=5 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=5 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).


var ie=document.all
var ns6=document.getElementById && !document.all

function _show(_object) {

if (document.getElementById){
subobj=document.getElementById(_object)
_eventopen=true
//subobj.style.width = 200
//subobj.style.height = 100

subobj.style.left=_left
subobj.style.top=_top

subobj.style.display="block"
return false
}
else { return true }

}

function _close(subobj){
document.getElementById(subobj).style.display="none"
_eventopen=false
}
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function mousepos(e) {

if (_eventopen){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-distancecursorX : winwidth-e.clientX-distancecursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-distancecursorY : winheight-e.clientY-distancecursorY

var leftedge=(distancecursorX<0)? distancecursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<subobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
subobj.style.left=curX-subobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
subobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
subobj.style.left=curX+distancecursorX-offsetdivfrompointerX+"px"

}

//same concept with the vertical position
if (bottomedge<subobj.offsetHeight){
subobj.style.top=curY-subobj.offsetHeight-distancecursorY+"px"
nondefaultpos=true
}
else{
subobj.style.top=curY+distancecursorY+offsetdivfrompointerY+"px"
}
subobj.style.visibility="visible"
}
// when _eventopen is false
else {

var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-distancecursorX : winwidth-e.clientX-distancecursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-distancecursorY : winheight-e.clientY-distancecursorY

var leftedge=(distancecursorX<0)? distancecursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<200){
//move the horizontal position of the menu to the left by it's width
_left=curX+"px"
nondefaultpos=true
}
else if (curX<leftedge)
_left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
_left=curX+distancecursorX-offsetdivfrompointerX+"px"

}

//same concept with the vertical position
if (bottomedge<100){
_top=curY-distancecursorY+"px"
nondefaultpos=true
}
else{
_top=curY+distancecursorY+offsetdivfrompointerY+"px"
}


// end of _eventopen == false
}


}
document.onmousemove=mousepos
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function showmenu(menuid)
{
document.getElementById(menuid).style.visibility="visible"
}
function hidemenu(menuid)
{
document.getElementById(menuid).style.visibility="hidden"
}

function ChangeBg(element)
{
	element.style.background = "#FFFFFF";
	element.style.cursor="hand";
	if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#CF2D78";
}
function RechangeBg(element)
{
	element.style.background = "#EEF6FB";
	if(element.getElementsByTagName("a")[0])element.getElementsByTagName("a")[0].style.color = "#007BC3";

}

if (document.images)
   {
     image2= new Image(0,0);
     image2.src="/store/skin1/images/new/baby1.jpg";
     image3= new Image(0,0);
     image3.src="/store/skin1/images/new/wedding11.jpg";
     image4= new Image(0,0);
     image4.src="/store/skin1/images/new/Canada.jpg";  
     image5= new Image(0,0);
     image5.src="/store/skin1/images/new/cookie.jpg";
     image6= new Image(0,0);
     image6.src="/store/skin1/images/new/military1.jpg";   
     image7= new Image(0,0);
     image7.src="/store/skin1/images/new/canada11.jpg"; 
     image8= new Image(0,0);
     image8.src="/store/skin1/images/new/wine1.jpg";  
     image9= new Image(0,0);
     image9.src="/store/skin1/images/new/movie1.jpg";  
     image10= new Image(0,0);
     image10.src="/store/skin1/images/new/gourmet1.jpg";  
     image11= new Image(0,0);
     image11.src="/store/skin1/images/new/tea1.jpg";
     image12= new Image(0,0);
     image12.src="/store/skin1/images/new/thanks1.jpg";  
     image13= new Image(0,0);
     image13.src="/store/skin1/images/new/relax1.jpg";  
 

   }

function change1(picName,imgName)
{
   if (document.images)
    {
      imgOn=eval(imgName + ".src");
      document[picName].src= imgOn;
    }
}

function copyBilling2Shipping(chk)
{
	if(chk.checked)
    {
		document.getElementById('s_firstname').value = document.getElementById('b_firstname').value;
		document.getElementById('s_lastname').value = document.getElementById('b_lastname').value;
		document.getElementById('s_address').value = document.getElementById('b_address').value;
		document.getElementById('s_address_2').value = document.getElementById('b_address_2').value;
		document.getElementById('s_city').value = document.getElementById('b_city').value;
		document.getElementById('s_state').selectedIndex = document.getElementById('b_state').selectedIndex;
		document.getElementById('s_country').value = document.getElementById('b_country').value;
		document.getElementById('s_zipcode').value = document.getElementById('b_zipcode').value;               
	}
	 else
	{
		document.getElementById('s_firstname').value = '';     
		document.getElementById('s_lastname').value = '';               
		document.getElementById('s_address').value = '';               
		document.getElementById('s_address_2').value = '';               
		document.getElementById('s_city').value = '';               
		document.getElementById('s_state').selectedIndex = -1;
		document.getElementById('s_country').value = '';               
		document.getElementById('s_zipcode').value = '';               
	}
}


        function isInnerHTMLGood()
        {
            var test = document.getElementById('GiftBasketContents');
            if (test && typeof test.innerHTML == 'string') {
                return true;
            }
            else
            {
                return false;
            }
        }


        function addShowContentsLink()
        {
            if(isInnerHTMLGood)
            { 
                //document.write('Hover over gift basket to display contents.');
            }
        }


function testForObject(Id)
{
  var o = document.getElementById(Id);
  if (o)
  {    
	return true;
    
  }
	return false;
}


        function showGiftBasketContents()
        {
            if(testForObject('GiftBasketContents') && testForObject('dhtmltooltip'))
            {
                //GetContents
                //var contents = document.getElementById('GiftBasketContents').innerHTML;
                //ddrivetip(contents,'white', 300);        
            }

        }

        function hideGiftBasketContents()
        {
	    //alert(testForObject('dhtmltooltip'));	
            if(testForObject('dhtmltooltip'))
            {
		//hideddrivetip();
            }

        }


  function filterShipping()
  {
    try
    {
        var shippingid=document.getElementsByName('shippingid').item(0);
        var shippingArray=document.getElementsByTagName('div');
        var found = false;
        for(var i=0;i<shippingArray.length;i++) 
        {
            if (shippingArray[i].getAttribute("groupName") == "Shipping")
            {          
                var ids = shippingArray[i].innerHTML.split(',');          
                for(var j=0;j<ids.length;j++) 
                {  
                    for(var k=0;k<shippingid.options.length;k++) 
                    {
                        if(ids[j] == shippingid.options[k].value)
                        {
                            shippingid.options[k].text = shippingid.options[k].text + "~";
                            k=shippingid.options.length;  
                        }
                    }
                } 
            }
        }
        
        if (ids.length>0)
        {
            for(var l=shippingid.options.length-1;l>=0;l--) 
            {
                if (shippingid.options[l].text.indexOf("~")>-1)
                {
                    shippingid.options[l].text=shippingid.options[l].text.replace(/~/,"");
                }
                else
                {
                   shippingid.remove(l);
                }
            }
        }
        
    }
    catch(err)
    {
    //Handle errors here
    }
  }


    function isFreeShipping()
    {
        try
        {
            var product_price=document.getElementById('product_price').innerHTML.replace('\$','');
            var freeShipping = document.getElementById('freeShipping');
            if(product_price > 75)
            {
                freeShipping.innerHTML=' Free Shipping';
                freeShipping.style.color='Red';
                freeShipping.style.fontWeight='bold';
	    }
	     else			
	    {
                freeShipping.innerHTML='';		
            }
        }
        catch(err)
        {
            //Handle errors here
        }
    }

    function resizeImage(img)
    {
        img.src = img.src.indexOf('/P/') > -1 ? img.src.replace('/P/', '/P2/') : img.src.replace('/P2/', '/P/');     
    }


    function bookmarkPage()
    {
        try
        {
            var title = window.document.title;
            var url = window.document.location.href;

            if (window.sidebar) 
            {
                window.sidebar.addPanel(title, url, "");
            }
            else if(window.opera && window.print)
            {
                // opera
                var elem = document.createElement('a');
                elem.setAttribute('href',url);
                elem.setAttribute('title',title);
                elem.setAttribute('rel','sidebar');
                elem.click();
            }            
            else if(document.all)
            {
                // ie
                window.external.AddFavorite(url, title);
            }
        }
        catch(err)
        {
        //    aler(err);
        }    
    }



    var timerID = 0;
    var imgHeight;
    var imgWidth;
    var enlarged = false;
    
    function checkImageResize() {
       var img = document.getElementById("largeImage");
       if (img.height == imgHeight && img.width == imgWidth)
       {
           timerID = setTimeout("checkImageResize()", 100);
       }
       else
       {
           var imgDiv = document.getElementById("largerImageDiv");
           imgDiv.style.marginLeft = "-" + parseInt(imgDiv.offsetWidth / 2) + "px";
           imgDiv.style.marginTop = "-" + parseInt(imgDiv.offsetHeight / 2) + "px";
           clearTimeout(timerID);
           timerID = 0;  
	   enlarged = true;  
       }   
    }


    function enlargeImage()
    {
        var imgDiv = document.getElementById("largerImageDiv");
        if (enlarged)
        {
          imgDiv.style.display = "";  
        }
        else
        {            
            imgDiv.style.display = "";
            var img = document.getElementById("largeImage");
            imgHeight = img.height;        
            imgWidth = img.width;        
            img.src = document.getElementById("product_thumbnail").src.replace('/P/', '/P2/');
            img.alt = "Click to close";
            img.title = img.alt;
            timerID  = setTimeout("checkImageResize()", 100);          
        }
     }
    
    function closeEnlargedImage()
    {
       if (enlarged)
            document.getElementById("largerImageDiv").style.display = "none";
    }