 
 
function getXMLHTTP() { //fuction to return the xml http object 
    var xmlhttp=false; 
    try{ 
        xmlhttp=new XMLHttpRequest(); 
    } 
    catch(e){ 
        try{ 
            xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
        catch(e){ 
            try{ 
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
            } 
            catch(e1){ 
                xmlhttp=false; 
            } 
        } 
    } 
 
    return xmlhttp; 
} 
                                                                                                                        
                                                                                                                                             
function checkAddress( add1,city,state,zip,country,formid  ) 
{ 
if( getCookie( "checkaddress" ) == 1 )
{
			    document.forms[formid].submit();
}
setCookie( "checkaddress", 1, 1000 )

	    strURL = "../upsav.php?city=" + escape( city ) + "&state="+escape( state ) + "&zip=" + escape( zip ) + "&add1=" + escape( add1 ) + "&country=" + escape( country ); 
    //    alert( strURL );
    var req = getXMLHTTP(); // fuction to get xmlhttp object 
    if (req) 
    { 
        req.onreadystatechange = function() 
        { 
            if (req.readyState == 4) { //data is retrieved from server 
                if (req.status == 200) { // which reprents ok status 
		    //		    alert( req.responseText );
                    if( req.responseText.trim() == "OK" )
			{
			    document.forms[formid].submit();
			}
		    else
			{
			    alert( "Our system is unable to verify your shipping address. Please double check your info!" );

			}
                } 
                else 
                { 
		    //                    alert("There was a problem while using XMLHTTP:\n"); 
		    document.forms[formid].submit();
                } 
            } 
        } 
        req.open("GET", strURL, true); //open url using get method 
        req.send(null); 
    } 
 
 
} 

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
}
function submitForm(formObj, formMode) { 
        if (!formObj) 
                return false; 
        if (formObj.tagName != "FORM") { 
                if (!formObj.form) 
                        return false; 
                formObj = formObj.form; 
        } 
        if (formObj.mode) 
                formObj.mode.value = formMode; 
        formObj.submit(); 
} 

function toggleDiv(element){ 
    var href = document.getElementById(element + "href"); 

    if(document.getElementById(element).style.display == 'none') 
	{ 
	    document.getElementById(element).style.display = 'block'; 
	    href.innerHTML = "v"; 
	} 
    else if(document.getElementById(element).style.display == 'block') 
	{ 
	    document.getElementById(element).style.display = 'none'; 
	    href.innerHTML = ">"; 
	} 
} 
function openProduct( name, price )
{
	window.open( "chooseproduct.php?id=" + name+ "&price=" + price );
}
function chooseProduct( id, val, displ )
{
  displ = unescape(displ).replace(/\+/g," ");
	document.getElementById( id ).value = val;
	document.getElementById( id + "display" ).innerHTML = displ + " <a href='#' onClick='clearChosen( \"" + id + "\" ); return false'>(d)</a>";
}

function clearChosen( id )
{
    document.getElementById( id ).value = "";
    document.getElementById( id + "display" ).innerHTML = "";
}
String.prototype.endsWith = function(str)
{
    var lastIndex = this.lastIndexOf(str);
    return (lastIndex != -1) && (lastIndex + str.length == this.length);
}

function hideshowgift( ele )
{
if( ele.style.display=="block" )
ele.style.display="none";
else
ele.style.display="block";
}

function openThisSocial( val )
{
if( val.indexOf( "ttp://www.fredflare.com" ) > 0 )
	document.location.href=val;
	else
	window.open( val, "_blank" );
}

function elistBlurFunc() {
	this.value = 'enter your email'; }

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function checkForAddress( ele )
{
res = confirm( "Click \"OK\" if your shipping address matches your billing address. \nClick \"Cancel\" to add a different shipping address." );
if( res )
{
document.location.href="/customer/checkout_shippingmethod.php?settobilling=1&shippingid=" + ele.value;
}
else
{
document.location.href="/customer/checkout_shippingaddress.php?shippingid=" + ele.value;
}

}

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_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) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

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 MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function OpenShipping( country )
{
if( country == "AU" ) 
	OpenmeIntl( '/intlshipping/australia.html', 216, 576 );
if( country == "JP" ) 
	OpenmeIntl( '/intlshipping/japan.html', 216, 575 );
if( country == "SE" ) 
	OpenmeIntl( '/intlshipping/sweden.html', 216, 575 );
if( country == "CA" ) 
	OpenmeIntl( '/intlshipping/canada.html', 223, 573 );
if( country == "NL" ) 
	OpenmeIntl( '/intlshipping/netherlands.html', 281, 444 );
if( country == "GB" ) 
	OpenmeIntl( '/intlshipping/greatbritian.html', 227, 582 );
if( country == "FR" ) 
	OpenmeIntl( '/intlshipping/france.html', 216, 573 );
if( country == "KP" ) 
	OpenmeIntl( '/intlshipping/southkorea.html', 288, 439 );
if( country == "DE" ) 
	OpenmeIntl( '/intlshipping/germany.html', 216, 618 );
if( country == "ES" ) 
	OpenmeIntl( '/intlshipping/spain.html', 279, 431 );
}
function OpenmeP(newin) {

        policies=window.open(newin,"policies","resizable=no,scrollbars=yes,width=400,height=350,top=150,left=350")
}
function OpenmeS(newin) {
        shipping=window.open(newin,"shipping","resizable=no,width=300,height=349,top=150,left=350")
}
function OpenmeWeight()
{
	window.open( "/customer/toolarge.php", "_blank", "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=328,height=208" );
}
function OpenmeIntl(newin, wid, hei) {
  window.open(newin,"shipping","resizable=no,scrollbars=no,width=" + (10+wid)+",height=" + (10+hei) + ",top=150,left=350")
}
function OpenmeB(newin) {

        boombox=window.open(newin,"boombox","resizable=no,scrollbars=no,width=425,height=640,top=0,left=0")
	boombox.opener = self;
}
function OpenmeD(newin) {

        giftwrap=window.open(newin,"giftwrap","resizable=no,scrollbars=no,width=316,height=302,top=100,left=150")

}
function OpenmeG(newin) {

        cali=window.open(newin,"cali","resizable=no,scrollbars=no,width=280,height=700,top=0,left=0")

}
function OpenmeSH(newin) {

        ship=window.open(newin,"ship","resizable=no,scrollbars=no,width=620,height=304,top=100,left=150")

}
function stat_write(yourtext)
{
window.status=yourtext;
}

function openURL(sURL) {
if( opener != null )
{
opener.location.href = sURL;
opener.focus();
}
else
{
window.open( sURL, '_blank' );
}
}
function days_between(date1, date2) {
  // The number of milliseconds in one day
  var ONE_DAY = 1000 * 60 * 60 * 24

  // Convert both dates to milliseconds
  var date1_ms = date1.getTime()
  var date2_ms = date2.getTime()

  // Calculate the difference in milliseconds
  var difference_ms = Math.abs(date1_ms - date2_ms)
  
  // Convert back to days and return
  return Math.round(difference_ms/ONE_DAY)
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function showhidestuff(boxid, ele){
    if( document.getElementById(boxid).style.display == "none" )
	{
	    document.getElementById(boxid).style.display="";
	    ele.innerHTML = "hide details";
	}
    else
	{
	document.getElementById(boxid).style.display="none";
	    ele.innerHTML = "show details";
	}
}

