
window.onerror = null;

var bName = navigator.appName;
var bVer = parseInt(navigator.appVersion);
var NS4 = (bName == "Netscape" && bVer >= 4);
var IE4 = (bName == "Microsoft Internet Explorer" && bVer >= 4);
var NS3 = (bName == "Netscape" && bVer < 4);
var IE3 = (bName == "Microsoft Internet Explorer" && bVer < 4);

function CartAddressAction(param){
    switch(param){
        case 'cmbCountry':
            var cmbCountry = document.getElementById("_ctl0_ContentPlaceHolder1_C_cart_address1_cmbCountry"); 
            param += '$'+cmbCountry.options(cmbCountry.selectedIndex).value; 
            
        case 'cmbShipCountry':
            var cmbShipCountry = document.getElementById("_ctl0_ContentPlaceHolder1_C_cart_address1_cmbShipCountry"); 
            param += '$'+cmbShipCountry.options(cmbShipCountry.selectedIndex).value;
            
       case 'chkSameShip':
            var chkShipToSame = document.getElementById("_ctl0_ContentPlaceHolder1_C_cart_address1_chkShipToSame"); 
            param += '$'+chkShipToSame.checked;            
    }
    
    _ctl0_ContentPlaceHolder1_C_cart_address1_cart_address_callback.Callback(param);
}

    

function OnPrintPage(id){
	var oWnd = parent;
	var oDoc = oWnd.document;
	var strLoc = 'printPage.aspx?id='+id;
	
	window.open(strLoc,'_blank','location=no,menubar=yes,scrollbars=yes,')
	
}

function OnPrintPageOld(id){
	var oWnd = parent;
	var oDoc = oWnd.document;
	var strLoc = 'printPage.aspx?id='+id;
	
	if (IE4){
		if( oWnd.printHiddenFrame == null){
			oDoc.body.insertAdjacentHTML("beforeEnd", "<iframe name='printHiddenFrame' width='0' height='0'></iframe>");
			framedoc = oWnd.printHiddenFrame.document;
			framedoc.open();
			framedoc.write(
				"<frameset name=test onload='printMe.focus();printMe.print();' rows=\"100%\">" +
				"<frame name=printMe src=\""+strLoc+"\">" +
				"</frameset>");
			framedoc.close();
		}
		else{
			oWnd.printHiddenFrame.printMe.focus();
			oWnd.printHiddenFrame.printMe.print();
		}
	}
	else{
		oWnd.location.href = strLoc;
	}
	
}


function S7ConfigObject()
{
	this.isVersion		= "2.8";
	this.isViewerRoot	= "http://s7ondemand1.scene7.com/is-viewers";
	this.isRoot		= "http://s7ondemand1.scene7.com/is/image/";

	this.codebase		= this.isViewerRoot + "http://s7ondemand1.scene7.com/applets/" + this.isVersion + "/";
	this.archiveSuffix	= "";
	this.buttonPath		= this.isRoot + "http://s7ondemand1.scene7.com/demo/buttons/";

	//used by js->flash communication.
	var ua        = navigator.userAgent.toLowerCase();
	this.isIeWin  = ua.indexOf('msie') != -1 && ua.indexOf('win') != -1 && ua.indexOf('opera') == -1 && ua.indexOf('webtv') == -1;
	this.isFsCommand = true;
}

S7ConfigObject.prototype.defaultInstanceName = function(img)
{
	var j = img.indexOf('?');
	var j1 = img.indexOf(',');
	if (j1 > 0 && (j < 0 || j > j1)) j = j1;
	j1 = img.indexOf(';');
	if (j1 > 0 && (j < 0 || j > j1)) j = j1;
	j1 = img.indexOf(':');
	if (j1 > 0 && (j < 0 || j > j1)) j = j1;
	j1 = img.indexOf('%3f');
	if (j1 > 0 && (j < 0 || j > j1)) j = j1;
	j1 = img.indexOf('%3F');
	if (j1 > 0 && (j < 0 || j > j1)) j = j1;
	if (j < 0) j = img.length;
	var i = img.lastIndexOf('/', j) + 1;
	return img.substring(i, j);
}

S7ConfigObject.prototype.setFlashParam = function(inId, inName, inVal) 
{
	if (this.isIeWin)
		document.getElementById(inId).SetVariable(inName, inVal);
	else 
	{
		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='../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;
	}
};

var flashOk = false;
S7ConfigObject.prototype.checkFlash = function()	//call this function and then test the flashOk variable
{
	if (S7Config.isIeWin)
	{
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('flashOk = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8")) \n');
		document.write('if flashOk = false then \n');
		document.write('    flashOk = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7")) \n');
		document.write('end if \n');
		document.write('if flashOk = false then \n');
		document.write('    flashOk = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")) \n');
		document.write('end if \n');
		document.write('</SCR' + 'IPT\> \n');
	}
	else if (navigator.plugins && navigator.plugins["Shockwave Flash"])
	{
		
		desc = navigator.plugins["Shockwave Flash"].description;
		flashOk = desc.indexOf(6.0) > 0 || desc.indexOf(7.0) > 0 || desc.indexOf(8.0) > 0 || desc.indexOf(9.0) > 0;
	}
}

S7ConfigObject.prototype.fsCommand = function(instance)
{
	if (this.fsCommand)
	{
		document.write('<SCR'+'IPT LANGUAGE="VBScript"> Sub ' + instance + '_FSCommand(ByVal command, ByVal args)  call doFSCommand(command, args) end sub </SCR'+'IPT>');
		this.fsCommand = false;
	}
	return this.isIeWin ? 'fscommand:' : 'javascript:';
}

var S7Config		= new S7ConfigObject();

//backwards compatibility
var root			= S7Config.isViewerRoot;
var imageServer		= S7Config.isRoot;
var codebase		= S7Config.codebase;
var archiveSuffix	= S7Config.archiveSuffix;
var buttonPath		= S7Config.buttonPath;
function checkFlash() { S7Config.checkFlash(); }

function getParam(p,d)
{
	var str = "" + unescape(document.location);
	var i = Math.max( str.indexOf('?'+p+'='), str.indexOf('&'+p+'=') );
	if ( i < 0 )
		return d;
	i+=2+p.length;
	var i2 = str.indexOf('&',i);
	var returnstr = str.substring(i,(i2<0?str.length:i2));
	return (returnstr.indexOf(',')>0?returnstr.split(','):returnstr);
};

function doFSCommand(inCommand, inArgs)
{
	eval(inArgs);
}
