    var fixUrl = true;
    function fixURL(product_url) {
        if(product_url.indexOf("http://") == -1 && product_url.indexOf("https://") == -1)
        product_url = "http://" + callBack + product_url;
        if(urlPassBack != "") {
            if(product_url.indexOf("?") == -1) {
                product_url += "?";
            } else {
                product_url += "&";
            }	
            product_url += urlPassBack;
        }
        return product_url;
    }

    function loadProduct(product_url) {
                    loadProductPW(product_url);
    }

    function loadProductPW(product_url) {
            product_url = fixURL(product_url);
            var theParent = parent.window.opener;
            if ((theParent != null) && (theParent.location != null) && !theParent.closed) {
                theParent.location = product_url;
                theParent.focus();
            } else {
                fixUrl = false;
                loadProductNW(product_url,false);
                fixUrl = true;
            }
    }

    function loadProductCW(product_url) {
            product_url = fixURL(product_url);
            document.location = product_url;
    }

    function loadProductNW(product_url) {
    if(fixUrl) {
        product_url = fixURL(product_url);
    }
    var new_window = window.open( product_url,
                                  windowName,
                                  windowFeatures);
    new_window.focus();
    }
        
    function launchFeedback(currentFrame) {
        alert("feedback for frame " + currentFrame);
    }

    function reload(enlargeState, currentFrame) {
        document.location = document.location.pathname + "?" + reloadParams + "&el=" + enlargeState;
    }
        
    function onProductIconClick() {
            loadProductPW(productIconURL);
    }

    function onLogoClick() {		
            if(logoClickURL != '')
                    loadProductPW(logoClickURL);
    }	

        	
    function openPrivacy() {
        var html = privacyCopy;
        newWin = window.open("","privacy","width=" + privacyWindowWidth + ",height=" + privacyWindowHeight);
        newWin.document.write(html);
        newWin.document.close();
    }

    function resizeStage(w, h) {
            var elementId = 'ZoomMX';		//match the id attribute of the OBJECT element
            var isSafari = ((navigator.appName=='Safari') || (navigator.userAgent.toLowerCase().indexOf('safari')>-1));
            var elm = null;
            if (!isSafari) {
                    elm = document.embeds[elementId];
            }
            var checkElm = false;
            if (elm) {
                    checkElm = true;
            } else {
                    checkElm = false;
            }
            if (!isSafari && checkElm) {
                    elm.width = w;
                    elm.height= h;
            } else {
                    v = getElement(elementId);
                    if (document.getElementById)
                    {
                            v.width = w;
                            v.height = h;
                    }
                    else if (v.all)
                    {
                            v.posWidth = w;
                            v.posHeight = h;
                    }
                    else if (v.clip)
                    {
                            v.clip.width = w;
                            v.clip.height = h;
                    }
            }	
    }

    function getElement(name) {
            if (document.getElementById) 
                    return document.getElementById(name).style;
            if (document.all) 
                    return document.all[name].style;
            if (document.layers) 
                    return document[name];
    }

function goToPage(page) {
setFlashParam(instance,"currentFrame",page);
}

function setFlashParam(inId, inName, inVal)
{  
        var ua        = navigator.userAgent.toLowerCase();
        
                var divcontainer = "flash_setvariables_" + inId;
                if (!document.getElementById(divcontainer))
                {
                        var divholder = document.createElement("div");
                        divholder.id = divcontainer;
                        document.body.appendChild(divholder);
                }
                document.getElementById(divcontainer).innerHTML = "";
                var divinfo = "<embed src='http://s7ondemand1.scene7.com/is-viewers/flash/gateway.swf' FlashVars='lc=" + inId + "&fq="+escape(inName + "=" + inVal)+"' width='0' height='0' type='application/x-shockwave-flash'></embed>";
                document.getElementById(divcontainer).innerHTML = divinfo;
 };


function  ParentOpener(url,parentname) {
    if(self.opener && !self.opener.closed)
        self.opener.location=url;
    else
        window.open(url,parentname);
}



function HomeDetails(sku) {

aurl='http://www.amazon.com/exec/obidos/tg/detail/-/'+sku.toUpperCase()+'?m=ATVPDKIKX0DER&s=merchant/ref=s7_ahe_2_s7';

if(self.opener&&!self.opener.closed)
{
self.opener.location=aurl;
}
else
{
window.open(aurl,'s7Amazon');
}
}


function ToolsDetail(sku) {

aurl='http://www.amazon.com/exec/obidos/tg/detail/-/'+sku.toUpperCase()+'?m=ATVPDKIKX0DER&s=merchant/ref=s7_tce_504_s7';

if(self.opener&&!self.opener.closed)
{
self.opener.location=aurl;
}
else
{
window.open(aurl,'s7Amazon');
}
}

function BobDetails(sku) {

aurl='http://www.amazon.com/exec/obidos/tg/detail/-/'+sku.toUpperCase()+'?m=ATVPDKIKX0DER&s=merchant/ref=s7_boe_551_s7';

if(self.opener&&!self.opener.closed)
{
self.opener.location=aurl;
}
else
{
window.open(aurl,'s7Amazon');
}
}


function AmazonDetail(ASIN,REF) {

aurl='http://www.amazon.com/exec/obidos/tg/detail/-/'+ASIN.toUpperCase()+'?m=ATVPDKIKX0DER&s=merchant/ref='+REF;

if(self.opener&&!self.opener.closed)
{
self.opener.location=aurl;
}
else
{
window.open(aurl,'s7Amazon');
}
}
