var sDCSID;
var cc_slh;

function json_results(obj)
{    
  cc_slh = obj.ResultSet.UID;
}

function getCookie(Name) {
        var search = Name + "=" 
        var CookieString = document.cookie 
        var result = null 
        if (CookieString.length > 0) { 
			offset = CookieString.indexOf(search) 
			if (offset != -1) { 
					offset += search.length 
					end = CookieString.indexOf(";", offset) 
					if (end == -1) {
						end = CookieString.length }
						result = CookieString.substring(offset, end)
                } 
        }
        return result; 
}


function readSubCookie(name,subname)
{
	var tmpCookie=getCookie(name);//this is the values in the cookie
	if(tmpCookie)
	{
		uCookies=(tmpCookie.split("&"));
		var found=-1;
		for(i=0;i<uCookies.length;i++)
		{
			if (uCookies[i].indexOf(subname)!=-1) 	 
				{//extract the value
					var start =uCookies[i].indexOf("=");
					return uCookies[i].substring(start+1);
				}
		}	
	}		
}

// Flash Player Version Detection - Rev 1.6
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		str += '>';
  		for (var i in params)
  			str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '</object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "id":
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


// Copyright 2004 CrossMedia Services, Inc. All rights reserved. Unauthorized use prohibited.
var slg_itemPhrase = "";
var slg_itemPhrasePlural = "";
var slg_itemcaption = "";
var slg_vdr = "937491807893143244757892937594981432447682917694829376829398143244818886787778898893143244818886787778898893809482777892143244818886787778898893767493748588801432448376897887877898143244848674919314324485889678921432448879798276788674971432449278749192143244769592143244967485809178788792143244887979827678777889889314324492937489857892143244828478741432447688868994927414324484888185921432447674877477827487938291781432447674877477827487938291787279911432449388989291949214324486827681747885921432449576791432448674769892143244749279949187829394917814324488928114324492818889848814324489789376881432448678828378911432448885778774959814324475917487779286749193949274143244807487777891868894879374828714324489788975889892143244";

// adds a trim() method to strings
String.prototype.trim = function() {
 // skip leading and trailing whitespace
 // and return everything in between
  var x=this;
  x=x.replace(/^\s*(.*)/, "$1");
  x=x.replace(/(.*?)\s*$/, "$1");
  return x;
}





//Akamai Return Url from Listing
var dontSetSLHRedirect = false;
try{dontSetSLHRedirect = doNotSetSLHRedirect;}
catch(e){}

//back button and history functionality
try{
    ak_action = cms_getQueryString("action"," ");
    ak_actionFilter = "|browseavailableonline|browsebrand|browsecategoryall|browsecategoryl1|browsecategoryl2|browsepagelarge|browsepagesingle|browsepagespread|browseshoppinglist|browsepageflash|search|entry|";
    if(ak_actionFilter.indexOf(ak_action.toLowerCase())>-1 && dontSetSLHRedirect == false)    
        setSubCookie("Prefs","SLHListingRedirect", escape(document.location.href), null); 
    
    var ak_history = cms_getCookie("Prefs", "History", "");
    var ak_historyArr = ak_history.trim().split("|");
       
    if(ak_historyArr.length==1 && ak_historyArr[0] == "")
        ak_history = ak_action;
    else if(ak_historyArr.length==1)
        ak_history = ak_history + "|" + ak_action;
    else if(ak_historyArr.length==2){
        ak_history = ak_historyArr[1] + "|" + ak_action;
    }

    setSubCookie("Prefs","History", ak_history, null);            

}catch(e){}


	//add to favorites bookmark
	function bookmark(){
		var pgUrl = window.location.href;
		var pgTitle = document.title;

		if (window.sidebar) {

			window.sidebar.addPanel(pgTitle, pgUrl,"");

		} else if( document.all ) {

			window.external.AddFavorite( pgUrl, pgTitle);

		} else if( window.opera && window.print ) {

			var elem = document.createElement('a');

			elem.setAttribute('href',pgUrl);

			elem.setAttribute('title',pgTitle);

			elem.setAttribute('rel','sidebar');

			elem.click();

		}

	}
	
/* cms_submitDropdown
 * 
 * auto-submits a SELECT's form. Use as the SELECT's onchange event handler and pass a 
 * reference to the SELECT object, e.g.
 * <select name="promotioncode" onChange="javascript:cms_submitDropdown(this)">
 */
function cms_submitDropdown(o){
    var cookieViewMode = cms_getCookie ("DisplayMode", "preferred", null);  
    var pageName;

    if (cookieViewMode == "html")
        pageName = "browsepagespread";
    else
        pageName = "browsepageflash";

    o.form.elements["action"].value = pageName;
    
    if (o.options[o.selectedIndex].value!=''){
        o.form.submit();            
    }
}   

/* cms_getQueryString
 * 
 * defaultvalue is optional. If passed, then 
 * if "key" doesn't exist or is "", defaultvalue
 * is returned. Otherwise null is returned on a mismatch.
 *
 */
function cms_getQueryString(key, defaultvalue) 
{   
        if(key != null)
            key = key.toLowerCase();
    
        var retval;
        var defval = null;
        if (defaultvalue) defval = defaultvalue;
        
        var qs = document.location.search;
        if(qs != null)
            qs = qs.toLowerCase();
        
        var index = qs.indexOf(key + "=");
        
        if (index == -1) return defval;
        
        index = qs.indexOf("=", index) + 1;
        
        var endstr = qs.indexOf("&", index);
        
        if (endstr == -1) endstr = qs.length;
        
        retval = _trim(unescape(qs.substring(index, endstr)).replace(/\+/ig,' '));
        
        if (retval=='') return defval;  // empty string, return default
        
        return retval;
}   

function cms_getQueryString2(url, key, defaultvalue) {
    var retval;
    var defval = null;
    if (defaultvalue) defval = defaultvalue;
    
    var qs = url;
    var index = qs.toLowerCase().indexOf(key.toLowerCase() + "=");
    if (index == -1) return defval;
    index = qs.indexOf("=", index) + 1;
    var endstr = qs.indexOf("&", index);
    if (endstr == -1) endstr = qs.length;
    retval = unescape(qs.substring(index, endstr)).replace(/\+/ig,' ').trim();
    if (retval=='') return defval;  // empty string, return default
    
    return retval;
}

function cms_getQueryString3(key, defaultvalue) 
{   
        if(key != null)
            key = key.toLowerCase();
    
        var retval;
        var defval = null;
        if (defaultvalue) defval = defaultvalue;
        
        var qs = document.location.search;
        if(qs != null)
            qs = qs.toLowerCase();
        
        var index = qs.indexOf(key + "=");
                
        if(index > 0){
        	index = qs.indexOf("&" + key + "=");
        	if (index == -1){
        		index = qs.indexOf("?" + key + "=");
        	}
        }
        
        if (index == -1) return defval;
        
        index = qs.indexOf("=", index) + 1;
        
        var endstr = qs.indexOf("&", index);
        
        if (endstr == -1) endstr = qs.length;
        
        retval = _trim(unescape(qs.substring(index, endstr)).replace(/\+/ig,' '));
        
        if (retval=='') return defval;  // empty string, return default
        
        return retval;
} 

function ReplaceQS(url, name, value){
    var token = "?";
    var index1;
    var index2;         
    var fragment;
    
    index1 = url.indexOf("&" + name + "=");
    if(index1 == -1)
        index1 = url.indexOf("?" + name + "=");
    else
        token = "&";
                
    if(index1 == -1){
        //param not found
        token = (url.indexOf("?") == -1) ? "?" : "&";
        url = url + token + name + "=" + value;             
    }
    else{
        //param found                               
        index2 = url.indexOf(token, index1+1);      
        if(index2 > -1)
            fragment = url.substr(index2);
        else
            fragment = "";      
        url = url.substring(0, index1) + token + name + "=" + value + fragment;
    }           
    return url
}

// cms_getCookie
// defaultvalue is optional. If passed, then 
// if "key" doesn't exist or is "", defaultvalue
// is returned. Otherwise null is returned on a mismatch.
function cms_getCookie(key, subkey, defaultvalue, nounescape) {
    var retval;
    var defval = null;
    if (defaultvalue != null && defaultvalue != undefined) defval = defaultvalue;
    var strKey = key;
    var strSubKey = '';
    if(subkey) strSubKey = subkey;

    var cookiestr = " " + document.cookie + ';';
    var rx = new RegExp('[^&]' + strKey + '=([^;]+)', 'i');
    if(rx.test(cookiestr)) {
        rx.exec(cookiestr);
        if(strSubKey == '') {
            // no subkey, return the match
            retval = (nounescape) ? RegExp.$1 : unescape(RegExp.$1);
            retval = retval.replace(/\+/ig,' ').trim();
            if (retval == '')
                return defval;  // empty string, return default
            else
                return retval;
        }
        else {
            // get the subkey
            var val = (nounescape) ? RegExp.$1 + '&' : unescape(RegExp.$1 + '&');
            rx = new RegExp(strSubKey + '=([^&]+)', 'i');
            if(rx.test(val)) {
                // it's in there
                rx.exec(val);
                retval = (nounescape) ? RegExp.$1 : unescape(RegExp.$1);
                retval = retval.replace(/\+/ig,' ').trim();
                if (retval == '')
                    return defval;  // empty string, return default
                else
                    return retval;
            }
            else {
                // not in there
                return defval;
            }
        }
    }
    else {
        // no match on the key
        return defval;
    }    
}

// cms_setCookie
// sets a cookie value. daysexpire is optional. if missing, then
// the cookie expires with the browser session.
function cms_setCookie(key,value,daysexpire,noescape) {
    var value = (noescape) ? value : escape(value);
    if(daysexpire) {
        var today = new Date();
        var expires = new Date();
        expires.setTime(today.getTime() + 3600000*24*daysexpire);
        document.cookie = escape(key)+"="+value+";expires="+expires.toGMTString()+";path=/";
    }
    else {
        document.cookie = escape(key)+"="+value+";path=/";
    }
}

function openWindow(strPage, strName, strFeatures) {
    var x = window.open(strPage, strName, strFeatures);
}
function dopopup(strPage, lngWidth, lngHeight) {
    var x, y;
    var agt=navigator.userAgent.toLowerCase(); 
    var is_aol = (agt.indexOf("aol") != -1)
  
  // initially assume 640x480
    var screenWidth = 640;
    var screenHeight = 480;

  
  if (window.screen.availHeight) {
    screenWidth = window.screen.availWidth; 
    screenHeight = window.screen.availHeight;
  }
  else if (window.screen.height) {
    screenWidth = window.screen.width; 
    screenHeight = window.screen.height - 50;
  }
  else if (document.all) {
    screenWidth = document.body.offsetWidth + window.screenLeft - 15;
    screenHeight = document.body.offsetHeight + window.screenTop - 15;
  } 
  else if (document.layers) {
    screenWidth = window.outerWidth - 20;
    screenHeight = window.outerHeight - 50;
  }
  if(is_aol) {
    if(lngWidth > (screenWidth - 40)) lngWidth = screenWidth - 40;
    if(lngHeight > (screenHeight - 120)) lngHeight = screenHeight - 120;
    x = 0; 
    y = 0;
  }
  else {
    if(lngWidth > screenWidth) lngWidth = screenWidth;
    if(lngHeight > screenHeight) lngHeight = screenHeight;
    x = (screenWidth - lngWidth)/2;
    y = (screenHeight - lngHeight)/2;
    if(x<0) x=0;
    if(y<0) y=0;
  }
  window.open(strPage, 'x', 'height='+lngHeight+',width='+lngWidth+',left='+x+',top='+y+',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');

}
  
function printFrame(strPage, skipPrint){

    //create Iframe and within page
	var el = document.createElement("iframe");
	
	//set atttibutes of the Iframes
	el.setAttribute('id', '_print');
	el.setAttribute('name', '_print');
	
	//append iframe to page
	document.body.appendChild(el);
	
	//set width and height to 0
	el.style.width = 0 + "px";
	el.style.height = 0 + "px";
	
	//set src of the iframe
	el.setAttribute('src', strPage);
	

	// sc 4.x sites skip this part because the print page executes the print directly via execCommand()
	if(skipPrint==null || skipPrint==undefined){
		el.onload = delayPrint();
	}
 }

function delayPrint(){
	setTimeout(printframe, 1000);
}

function printframe(){	
	window.focus();
	window.print();
}

    var da = (document.all) ? 1 : 0;
    var pr = (window.print) ? 1 : 0;
    var mac = (navigator.userAgent.indexOf("Mac") != -1); 
    var noprint = false;

    if (!pr && (!da || mac)) noprint = true;

function printPage() {
    if (pr) // NS4, IE5
        window.print()
    else if (da && !mac) // IE4 (Windows)
        vbPrintPage()
    return false;
}

if (da && !pr && !mac) {
document.writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
document.writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
document.writeln('Sub window_onunload');
document.writeln('  On Error Resume Next');
document.writeln('  Set WB = nothing');
document.writeln('End Sub');
document.writeln('Sub vbPrintPage');
document.writeln('  OLECMDID_PRINT = 6');
document.writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
document.writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
document.writeln('  On Error Resume Next');
document.writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
document.writeln('End Sub');
document.writeln('<' + '/SCRIPT>');
}

function clearDefault(theobject) {
  if (theobject.defaultValue==theobject.value) theobject.value = ""
} 

function ChangeCookie ( )
{
    document.write("Welcome to my world!!!");
}

function URLDecode(urlString) 
{
  return unescape(urlString); 
}

function GeneratePTQS()
{                   
    var cookievals = document.cookie.split(";");
    var subcookievals = "";
    var qs = document.location.search;
    
    for(var i=0; i<cookievals.length; i++)
    {
        var name = _trim(cookievals[i].split("=")[0]);
        var value = _trim(cookievals[i].split("=")[1]);
        if( name.toLowerCase().indexOf("slhbanner") > -1 || 
            name.toLowerCase().indexOf("slhcookie") > -1 ||
            name.toLowerCase().indexOf("slhregcookie") > -1 ||
            name.toLowerCase().indexOf("slhtrackingsessionid") > -1 ||
            name.toLowerCase().indexOf("prefs") > -1)
        {
            if(cookievals[i].indexOf("&") > -1) 
            {   
                var parentName = name.toLowerCase();
                var values = cookievals[i].split("=");
                var prefsFilter = "|adref|detid|matchtype|dimexpand|keywordsearched|wt.srch|";
                values.shift();
                values = values.join("=").split("&");
                for(var x=0; x<values.length; x++)
                {
                    name = _trim(values[x].split("=")[0]);
                    value = _trim(values[x].split("=")[1]);
                    
                    if((name != "") && (parentName != "prefs" || (parentName == "prefs" && prefsFilter.indexOf("|" + name + "|") > -1)))
                        qs += "&" + name + "=" + value;                                         
                }
            }   
            else
                qs += "&" + name + "=" + escape(cookievals[i].split("=")[1]);
        }
    }
    return qs;          
}   

function GetPageCounter()
{
    return cms_getCookie("SLHPageCounter");
}

function _trim(str) {
    if(str != null)
    {
        var x = str;
        x=x.replace(/^\s*(.*)/, "$1");
        x=x.replace(/(.*?)\s*$/, "$1");
        return x;
    }
    return "";
}

function setSubCookie(uName, name, value, timeexpire)
{
    uValue = cms_getCookie(uName, null, null, true);
    if(uValue) {                    
        uCookies = uValue.split("&");
        var found = -1;
        for( c = 0; c < uCookies.length; c++ ){                       
            t = uCookies[c].split( '=' );
            if(t[0] == name) {
                found = 1;
                t[1] = escape(value);
                uCookies[c] = t.join( '=' );
                break;
            }
        }
        if( found == -1 )
            uCookies[uCookies.length] = name + '=' + value;
                                            
        uValue = uCookies.join( '&' );
    } else
        uValue = name + '=' + value;

    // update real cookie
    if(timeexpire)
        cms_setCookie(uName, uValue, timeexpire, true);
    else
        cms_setCookie(uName, uValue, null, true);
}

function ReturnFromListing()
{
    var url = cms_getQueryString("ref", null);

    if(url == null)
        url = unescape(unescape(cms_getCookie("Prefs","SLHListingRedirect","", true)));
        
    if(url == null || url == "")
    {
        document.location.href = "default.aspx?action=entry";
        return;
    }

	if(url.lastIndexOf("action=browsepageflash") > -1)
	{
		var temp = url.split("pagenumber")[0] + "startpage" + url.split("pagenumber")[1];
		url = temp;
	}
    document.location.href = url;
}

function AddShoppingListUI(storeId, listingId, offerId, addtext, removetext, onclick, style, target, originalLink){
    var result = AddShoppingListListing(storeId, listingId, offerId);
    if(result){
        DrawShoppingListLink(listingId, originalLink, addtext, removetext, onclick, style, target, offerId, "innerhtml")
        DrawShoppingListCount(null, null, "innerhtml");
        if(slg_itemcaption!="")
            DrawListingCaption(listingId, slg_itemcaption, offerId, "innerhtml");
        
        //tracking    
        var finalPrice = cms_getQueryString2(originalLink, 'finalprice', '0.0')
        var url = [];
    
        url[0] = "http://ptsc.shoplocal.com/pt" + document.location.pathname + ReplaceQS(GeneratePTQS(),"action","addshoppinglist") + "&pagecounter=" + GetPageCounter() + "&slhlogon=" + cms_getCookie("SLHUID", "UID") + "&siteid=" + cms_getCookie("Prefs", "SiteID") + "&referrer=" + escape(document.location) + "&random=" + escape(Math.random());       
        DrawTracker(url, "pt", "pixelTrackerContainer", true);
        
        url[0] = "http://it.shoplocal.com/it.ashx?" + uid + "|~|" + cms_getCookie("Prefs", "SiteID") + "|~|8|~||~|" + storeId + "|~|" + listingId + "|~|" + escape(Math.random()).replace(".","");
        DrawTracker(url, "et", "eventTrackerContainer", true);
                     
        dcsMultiTrack('DCS.sl_ffunc','addshoppinglist','DCSext.sl_zip','','DCSext.sl_zipcnt','','DCSext.sl_circ','','DCSext.sl_circ_p','','DCSext.sl_tx_s', finalPrice ,'WT.oss','','WT.oss_r','','WT.tx_u','1','WT.pn_sku', listingId ,'WT.si_n','','WT.si_p','','WT.tx_e','lp');
    }       
}

function RemoveShoppingListUI(storeId, listingId, offerId, addtext, removetext, onclick, style, target, originalLink){
    var result = RemoveShoppingListListing(storeId, listingId, offerId);
    if(result){
        DrawShoppingListLink(listingId, originalLink, addtext, removetext, onclick, style, target, offerId, "innerhtml")
        DrawShoppingListCount(null, null, "innerhtml");
        if(slg_itemcaption!="")
            DrawListingCaption(listingId, slg_itemcaption, offerId, "innerhtml");
        
        //tracking    
        var url = [];
        url[0] = "http://ptsc.shoplocal.com/pt" + document.location.pathname + ReplaceQS(GeneratePTQS(),"action","removeshoppinglist") + "&pagecounter=" + GetPageCounter() + "&slhlogon=" + cms_getCookie("SLHUID", "UID") + "&siteid=" + cms_getCookie("Prefs", "SiteID") + "&referrer=" + escape(document.location) + "&random=" + escape(Math.random());
        DrawTracker(url, "pt", "pixelTrackerContainer", true);
                
        dcsMultiTrack('DCS.sl_ffunc','removeshoppinglist','DCSext.sl_zip','','DCSext.sl_zipcnt','','DCSext.sl_circ','','DCSext.sl_circ_p','','DCSext.sl_tx_s','','WT.oss','','WT.oss_r','','WT.tx_u','1','WT.pn_sku', listingId ,'WT.si_n','','WT.si_p','','WT.tx_e','lp');            
    }       
}

function DrawShoppingListLink(listingId, link, addtext, removetext, onclick, style, target, offerId, mode)
{   
    //backward compatibility
    var vdir = "";
    var action = cms_getQueryString("action"," ").toLowerCase();
    try{vdir = window.location.href.split('/')[3];}catch(e){}
    if(action == "browseshoppinglist" || action == "printshoppinglist" || num_to_str(slg_vdr).indexOf("|" + vdir + "|")==-1){
        DrawShoppingListLink2(listingId, link, addtext, removetext, onclick, style, target, offerId)
        return;
    }
   
    // clean up parameters
    offerId = (offerId==undefined || offerId==null) ? "" : offerId;
    target = (target==undefined || target==null) ? "" : target;    
    style = (style==undefined || style==null) ? "" : style        

    onclick = (onclick==undefined || onclick==null) ? "" : onclick.replace(/`/g,"'");       
    addtext = addtext.replace(/`/g,"'").replace(/\"/g, "'");    
    removetext = removetext.replace(/`/g,"'").replace(/\"/g, "'");    
    
    var onclickparam = onclick.replace(/\'/g,"`")
    var addtextparam = addtext.replace(/\'/g,"`");
    var removetextparam = removetext.replace(/\'/g,"`")
                    
    var storeId = cms_getQueryString("storeid", null, "null");       
    var inList = GetShoppingListListing(storeId, listingId, offerId);
    var spanId = "sl|" + storeId + "|" + listingId + "|" + offerId;
    var renderedLink = "";
              
    if(inList)
        renderedLink = '<a target="' + target + '" onclick="' + onclick + '" style="' + style + '" href="javascript:RemoveShoppingListUI(\'' + storeId + '\',\'' + listingId + '\',\'' + offerId + '\',\'' + addtextparam + '\',\'' + removetextparam + '\',\'' + onclickparam + '\',\'' + style + '\',\'' + target + '\',\'' + link + '\')"><nobr>' + removetext + '</nobr></a>';
    else
        renderedLink = '<a target="' + target + '" onclick="' + onclick + '" style="' + style + '" href="javascript:AddShoppingListUI(\'' + storeId + '\',\'' + listingId + '\',\'' + offerId + '\',\'' + addtextparam + '\',\'' + removetextparam + '\',\'' + onclickparam + '\',\'' + style + '\',\'' + target + '\',\'' + link + '\')"><nobr>' + addtext + '</nobr></a>';

    if(mode == "innerhtml")       
        document.getElementById(spanId).innerHTML = renderedLink;       
    else
        document.write("<span style='' id='" + spanId + "'>" + renderedLink + "</span>");                
}

function DrawShoppingListCount(itemPhrase, itemPhrasePlural, mode)
{
    if(itemPhrase==null)
        itemPhrase = slg_itemPhrase;
    else
        slg_itemPhrase = itemPhrase;
    
    if(itemPhrasePlural==null)
        itemPhrasePlural = slg_itemPhrasePlural;
    else
        slg_itemPhrasePlural = itemPhrasePlural;

    var itemCount = cms_getCookie("ShoppingListCount",null,"0");
    var itemPhrase = (itemCount == "1") ? " " + itemPhrase : " " + itemPhrasePlural;
    if(itemPhrase.trim() == "")
        itemPhrase = "";
    
    if(mode == "innerhtml"){
        if(document.getElementById("spnShoppingListCount")!=null)
            document.getElementById("spnShoppingListCount").innerHTML = itemCount + itemPhrase;
    }
    else
        document.write("<span id='spnShoppingListCount' style=''>" + itemCount + itemPhrase + "</span>");

}

function DrawShoppingListLink2(listingId, link, addtext, removetext, onclick, style, target, offerId)
{
    var storeId = cms_getQueryString("storeid", null, "null");
    var ids = cms_getCookie("shoppinglist", null, "");
    var tempShopLink = link;
    var match;
    var inList;
    var tempLinkbegin;
    var tempLinkend;
    var searchfor;
    style = (style==null || style=="") ? " " : " style=\"" + style + "\" ";
    onclick = (onclick==null || onclick=="") ? " " : " onclick=\"" + onclick + "\" ";
    target = (target==null || onclick=="") ? " " : " target=\"" + target + "\" ";

    //try to find the action in the URL; if found replace action with correct action
    
    //searchfor = "action%3daddshoppinglist%26";
    searchfor = "action=addshoppinglist&";
    match = tempShopLink.indexOf (searchfor);
    if (match != -1){
        tempLinkbegin = tempShopLink.substring (0, match);
        tempLinkend = tempShopLink.substring (match+searchfor.length, tempShopLink.length);
    } else {
        //searchfor = "action%3dremoveshoppinglist%26";
        searchfor = "action=removeshoppinglist&";
        match = tempShopLink.indexOf (searchfor);
        if (match != -1){
            tempLinkbegin = tempShopLink.substring (0, match);
            tempLinkend = tempShopLink.substring (match+searchfor.length, tempShopLink.length);
        } else {
            searchfor = "Default.aspx%3f";
            match = tempShopLink.indexOf (searchfor);
            if (match != -1){
                tempLinkbegin = tempShopLink.substring (0, match+searchfor.length);
                tempLinkend = tempShopLink.substring (match+searchfor.length, tempShopLink.length); 
            }       
        }
    }
        
    //try to get catid from the qs
    var catId = cms_getQueryString("CatId", null, "null");
    catId = (catId != null) ? "|" + catId : "";
    
    //try to get catid from cookie
    if(catId == "")
    {
        catId = cms_getQueryString2(unescape(cms_getCookie("SLHListingRedirect", null, "")), "CatId", "");
        catId = (catId != null) ? "|" + catId : "";
    }
    
    //append offerid
    listingId += (offerId != null) ? ":" + offerId : "";

    //try to find in list without catid         
    inList = (ids.indexOf(listingId + "," + storeId) > -1); 

    //try to find in list with catid            
    if(!inList)
        inList = (ids.indexOf(listingId + catId + "," + storeId) > -1);

    if(inList){
        document.write("<a" + target + style + "href=\"" + tempLinkbegin + "action=removeshoppinglist&" + tempLinkend + "\">" + removetext + '</a>');
    } else {
        document.write("<a" + target + onclick + style + "href=\"" + tempLinkbegin + "action=addshoppinglist&" + tempLinkend + "\">" + addtext + '</a>');
    }
}

function DrawListingCaption (listingId, caption, offerId, mode)
{
    slg_itemcaption = caption;
    
    storeId = cms_getQueryString("storeid", null, "null");
    offerId = (offerId==undefined || offerId==null) ? "" : offerId;

    //try to find in list without catid         
    inList = GetShoppingListListing(storeId, listingId, offerId)    
    
    //try to find in list with catid            
    var captionId = "slci|" + listingId + "|" + offerId + "|";
    if(inList){     
        if(mode == "innerhtml"){
            if(document.getElementById(captionId)!=null)
                document.getElementById(captionId).innerHTML = caption;
        }
        else
            document.write ("<span style='' id='" + captionId + "'>" + caption + "</span>");
    }
    else{
        if(mode == "innerhtml"){
            if(document.getElementById(captionId)!=null)
                document.getElementById(captionId).innerHTML = "";
        }
        else{
            document.write ("<span style='' id='" + captionId + "'></span>");
        }
    }
}

function deleteCookie(name, path, domain) 
{
    if ( cms_getCookie( name ) ) document.cookie = name + "=" +
    ( ( path ) ? ";path=" + path : "") +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function DrawViewAllItems(url, itemphrase, circularphrase)
{
    var displayMode = (cms_getCookie("DisplayMode", "preferred", "html"));
    var action = (displayMode == "html") ? "browsepagesingle" : "browsepageflash";
    var ignoreFlashStateParam = "ignore=true&"
    if(action != "browsepageflash"){
	ignoreFlashStateParam = "";
    }
    
    try{
        //TODO: this could be done more efficient with regular expressions - gj
        var qs = url.substring(url.indexOf("?")+1, url.length);
        var qsArray = qs.split("&");
        
        qs = "";    
        for(var i=0; i<qsArray.length; i++){        
            if(qsArray[i].split("=")[0].toLowerCase() == "action")
                qsArray[i] = "action=" + action;
            qs += qsArray[i] + "&";         
        }
        
        url = url.split("?")[0] + "?" + qs; 
    }
    catch(e){}
            
	if(url.lastIndexOf("action=browsepageflash") > -1)
	{
		var temp = url.split("pagenumber")[0] + "startpage" + url.split("pagenumber")[1];
		url = temp;
	}
    document.location.href = url + ignoreFlashStateParam;
}


function WishListListingExists(sid, lid, cid)
{   
    var ids = cms_getCookie("wishlist", null, " ");
        
    //try to find in list without catid         
    var pos = ids.indexOf(lid + "," + sid);
    
    //try to find in list with catid            
    if(pos > -1)
    {
        document.catalog.SetVariable('itemInWishListCookie', "true");
        return;
    }
        
    pos = ids.indexOf(lid + cid + "," + sid);   
    if(pos > -1)
    {
        document.catalog.SetVariable('itemInWishListCookie', "true");
        return;
    }
    else
    {
        document.catalog.SetVariable('itemInWishListCookie', "false");
        return;
    }
}

function GetWishListListing(sid, lid, cid)
{       
    var ids = cms_getCookie("wishlist", null, " ");
        
    //try to find in list without catid         
    var pos = ids.indexOf(lid + "," + sid);
    
    //try to find in list with catid            
    if(pos > -1)
        return ((pos>0) ? "," : "") + lid + "," + sid;
    else
        pos = ids.indexOf(lid + cid + "," + sid);
        
    if(pos > -1)
        return ((pos>0) ? "," : "") + lid + cid + "," + sid;
    else
        return "";          
}

function RemoveWishListListing(sid, lid, cid)
{
    //get wishlist cookie
    var ids = new String(cms_getCookie("wishlist", null, " "));
    if(ids == "")
        return false;
    
    var wishlistvalue = GetWishListListing(sid, lid, cid);
            
    if(wishlistvalue != ""){    
        var regEx = new RegExp (wishlistvalue, 'gi') ;
        ids = ids.replace(regEx, '');
        if(ids.indexOf(',') == 0)
            ids = ids.substring(1, ids.length-1);
            
        cms_setCookie("WishList",ids);
        
        var idcount = 0;    
        try{idcount = parseInt(cms_getCookie("wishlistcount", null, " "));}
        catch(e){}
        
        if(idcount>0)
        {
            SetListCount();
            --idcount;          
            cms_setCookie("WishListCount",idcount);         
        }
        return;
    }
    else{
        return;
    }           
}

function AddWishListListing(sid, lid, cid)
{
    lid = (cid!=null&&cid!="") ? lid + cid : lid;   
    var ids = new String(cms_getCookie("wishlist", null, " ")).trim();  
    var wishlistvalue = GetWishListListing(sid, lid, cid);  
    try{
        idcount = parseInt(cms_getCookie("wishlistcount", null, " "));
        if(idcount == 20)
        {
            SetListCount();
            return;
        }
    }
    catch(e){}
    
    if(wishlistvalue == ""){    
        ids = (ids == "") ? lid+","+sid : ids+","+lid+","+sid;
        cms_setCookie("WishList",ids,360);          
        var idcount = 0;    
        try{idcount = parseInt(cms_getCookie("wishlistcount", null, "0"));}
        catch(e){}
        
        SetListCount();
        idcount++;      
        cms_setCookie("WishListCount", idcount,360);        
        return;
    }
    else{
    
        return;
    }           
}

function SetListCount()
{   
    var idcount = parseInt(cms_getCookie("wishlistcount", null, " "));
    //alert(idcount);
    if(isNaN(idcount))
    {
        idcount = 0;
        fc.setVariable("/flashMoreInfo:wishListCount", idcount);        
    }
    else
    {
        fc.setVariable("/flashMoreInfo:wishListCount", idcount);
    }
}

//Either HTML or Flash link shows
function DrawToggleLink (modePhrase, HTMLmode, Flashmode, strRetailerAdPageID, strPromotionCode, strSID, linkID, toggleStyle)
{    
    var currentStoreID = cms_getQueryString("storeid","-1");
    if(currentStoreID == "-1"){currentStoreID = cms_getCookie ("Prefs","StoreID",null,"0");}    
    else{setSubCookie("Prefs","StoreID",currentStoreID,1000);}
    
    var modePref = cms_getCookie ("DisplayMode", "preferred", null);
    var HTMLLink;
    var FlashLink;

    linkIDvalue = (linkID==null || linkID=="") ? " " : " id=\"" + linkID + "\" ";

    if (strRetailerAdPageID != ""){
        if (modePref == "flash"){
            HTMLLink = "\Default.aspx?action=" + HTMLmode + "&storeid=" + currentStoreID + "&rapid=" + strRetailerAdPageID;
            document.write ("<div class=\"modeLink\"><a" + linkIDvalue + "href=\"javascript:GoToPromotion('" + HTMLLink + "')\">" + modePhrase + "</a></div>");
        } else {
            FlashLink = "\Default.aspx?action=" + Flashmode + "&storeid=" + currentStoreID + "&rapid=" + strRetailerAdPageID;
            document.write ("<div class=\"modeLink\"><a" + linkIDvalue + "href=\"javascript:GoToPromotion('" + FlashLink + "')\">" + modePhrase + "</a></div>");
        }
    } else if (strPromotionCode != "") {
        if (modePref=="flash"){
            HTMLLink = "\Default.aspx?action=" + HTMLmode + "&storeid=" + currentStoreID + "&promotioncode=" + strPromotionCode;
            document.write ("<div class=\"modeLink\"><a" + linkIDvalue + "href=\"javascript:GoToPromotion('" + HTMLLink + "')\">" + modePhrase + "</a></div>");
        } else {
            FlashLink = "\Default.aspx?action=" + Flashmode + "&storeid=" + currentStoreID + "&promotioncode=" + strPromotionCode;
            document.write ("<div class=\"modeLink\"><a" + linkIDvalue + "href=\"javascript:GoToPromotion('" + FlashLink + "')\">" + modePhrase + "</a></div>");
        }
    }
}

//Both HTML/Flash links show
function DrawToggleLink2 (htmlPhrase, flashPhrase, strAction, strRetailerAdPageID, strPromotionCode, strSID, linkID, toggleStyle)
{
    var currentStoreID = cms_getQueryString("storeid","-1");
    if(currentStoreID == "-1"){currentStoreID = cms_getCookie ("Prefs","StoreID",null,"0");}
    else{setSubCookie("Prefs","StoreID",currentStoreID,1000);}
    
    linkIDvalue = (linkID==null || linkID=="") ? " " : " id=\"" + linkID + "\" ";

    if (strRetailerAdPageID != ""){
        HTMLLink = "\Default.aspx?action=" + strAction + "&storeid=" + currentStoreID + "&rapid=" + strRetailerAdPageID + "&pagenumber=1";
        FlashLink = "\Default.aspx?action=browsepageflash" + "&storeid=" + currentStoreID + "&rapid=" + strRetailerAdPageID + "&pagenumber=1";
        document.write ("<div class=\"HTMLmodelink\"><a" + linkIDvalue + "href=\"javascript:GoToPromotion('" + HTMLLink + "')\">" + htmlPhrase + "</a></div>");
        document.write ("<div class=\"Flashmodelink\"><a" + linkIDvalue + "href=\"javascript:GoToPromotion('" + FlashLink + "')\">" + flashPhrase + "</a></div>");  
    } else if (strPromotionCode != "") {
        HTMLLink = "\Default.aspx?action=" + strAction + "&storeid=" + currentStoreID + "&promotioncode=" + strPromotionCode + "&pagenumber=1";
        FlashLink = "\Default.aspx?action=browsepageflash" + "&storeid=" + currentStoreID + "&promotioncode=" + strPromotionCode + "&pagenumber=1";
        document.write ("<div class=\"HTMLmodelink\"><a" + linkIDvalue + "href=\"javascript:GoToPromotion('" + HTMLLink + "')\">" + htmlPhrase + "</a></div>");
        document.write ("<div class=\"HTMLmodelink\"><a" + linkIDvalue + "href=\"javascript:GoToPromotion('" + FlashLink + "')\">" + flashPhrase + "</a></div>");
    }
}

//HTML/Flash radio buttons
function DrawToggleLink3 (HTMLAction, FlashAction, HTMLmode, Flashmode, strRetailerAdPageID, strPromotionCode, strSID, linkID, toggleStyle)
{
    var currentStoreID = cms_getQueryString("storeid","-1");
    if(currentStoreID == "-1"){currentStoreID = cms_getCookie ("Prefs","StoreID",null,"0");}    
    else{setSubCookie("Prefs","StoreID", currentStoreID,1000);}

    var modePref = cms_getCookie ("DisplayMode", "preferred", null);

    linkIDvalue = (linkID==null || linkID=="") ? " " : " id=\"" + linkID + "\" ";

    var RetailerHTMLLink = "\Default.aspx?action=" + HTMLAction + "&storeid=" + currentStoreID + "&rapid=" + strRetailerAdPageID + "&pagenumber=1";
    var RetailerFlashLink = "\Default.aspx?action=" + FlashAction + "&storeid=" + currentStoreID + "&rapid=" + strRetailerAdPageID + "&pagenumber=1";
    var PromoHTMLLink = "\Default.aspx?action=" + HTMLAction + "&storeid=" + currentStoreID + "&promotioncode=" + strPromotionCode + "&pagenumber=1";
    var PromoFlashLink = "\Default.aspx?action=" + FlashAction + "&storeid=" + currentStoreID + "&promotioncode=" + strPromotionCode + "&pagenumber=1";

    if (strPromotionCode != "") {
        if (modePref=="flash"){
            setSubCookie("DisplayMode","preferred","html",1000);
            window.location = PromoHTMLLink;
        } else {
            setSubCookie("DisplayMode","preferred","flash",1000);
            window.location = PromoFlashLink;
        }
    }else if (strRetailerAdPageID != ""){
        if (modePref == "flash"){
            setSubCookie("DisplayMode","preferred","html",1000);        
            window.location = RetailerHTMLLink;     
        } else {
            setSubCookie("DisplayMode","preferred","flash",1000);
            window.location = RetailerFlashLink;
        }
    } 
}

//The toggle link above/below the circular cover image and the link for the circular cover itself
function DrawEntryToggle (CircAction, StoreID, RapID, PromoCode, DefaultView, prefMode, fsid)
{
    var displayMode = (cms_getCookie("DisplayMode","preferred", null));

    if ((prefMode != null && prefMode != "")&& displayMode!= null){
        if (prefMode == "html"){
            setSubCookie("DisplayMode","preferred","html",1000);
            displayMode = "html";
        } else {
            setSubCookie("DisplayMode","preferred","flash",1000);       
            displayMode = "flash";
        }
    }
    
    if (displayMode == null){
        if (prefMode == null || prefMode == "")
            displayMode = (DefaultView=="1" || DefaultView=="2" || DefaultView=="10") ? "html" : "flash";
        else 
            displayMode = prefMode;
        
        setSubCookie("DisplayMode","preferred",displayMode,1000);
    } 

    if (displayMode == "html")
        window.location = "Default.aspx?action=" + CircAction + "&storeid=" + StoreID + "&rapid=" + RapID.trim() + "&pagenumber=1&prvid=" + PromoCode + "&promotioncode=" + PromoCode;  
    else
        window.location = "Default.aspx?action=browsepageflash" + "&storeid=" + StoreID + "&rapid=" + RapID.trim() + "&pagenumber=1&prvid=" + PromoCode + "&promotioncode=" + PromoCode;
}

//Toggle link - current mode text, toggle a link or both are links
function DrawEntryDualToggle (HTMLtxt, Flashtxt, CircAction, StoreID, RapID, PromoCode, DefaultView, LinkStat, LinkPos)
{
    var displayMode = (cms_getCookie("DisplayMode", "preferred", null));
    var ToggleLink;
    var CurrentLink;
    var CurrentPhrase;
    var TogglePhrase;

    if (displayMode == null)
        displayMode = (DefaultView=="1" || DefaultView=="2" || DefaultView=="10") ? "html" : "flash";

    if (displayMode == "html"){
        setSubCookie("DisplayMode","preferred", "html",1000);
        CurrentLink = "Default.aspx?action=" + CircAction + "&storeid=" + StoreID + "&rapid=" + RapID + "&pagenumber=1&prvid=" + PromoCode + "&promotioncode=" + PromoCode;
        CurrentPhrase = HTMLtxt;
        ToggleLink = "Default.aspx?action=browsepageflash" + "&storeid=" + StoreID + "&rapid=" + RapID + "&pagenumber=1&prvid=" + PromoCode + "&promotioncode=" + PromoCode;
        TogglePhrase = Flashtxt;    
    } else {
        setSubCookie("DisplayMode","preferred", "flash",1000);
        CurrentLink = "Default.aspx?action=browsepageflash" + "&storeid=" + StoreID + "&rapid=" + RapID + "&pagenumber=1&prvid=" + PromoCode + "&promotioncode=" + PromoCode;
        CurrentPhrase = Flashtxt;
        ToggleLink = "Default.aspx?action=" + CircAction + "&storeid=" + StoreID + "&rapid=" + RapID + "&pagenumber=1&prvid=" + PromoCode + "&promotioncode=" + PromoCode;
        TogglePhrase = HTMLtxt;
    }
    if ((LinkStat == "bothLinks" || LinkStat == "bothlinks" || LinkStat == "BothLinks" )&& CurrentLink != null && CurrentLink != ""){
        if (LinkPos == "stack" || LinkPos == "Stack"){
            document.write ("<div id=\"toggleleft\"><a href=\"javascript:GoToPromotion('" + CurrentLink + "')\">" + CurrentPhrase + "</a></div>");
            document.write ("<div id=\"toggleright\"><a href=\"javascript:GoToPromotion('" + ToggleLink + "')\">" + TogglePhrase + "</a></div>");
        } else {
            document.write ("<span id=\"toggleleft\"><a href=\"javascript:GoToPromotion('" + CurrentLink + "')\">" + CurrentPhrase + "</a></span>");
            document.write ("<span id=\"toggledivider\">&nbsp;|&nbsp;</span>");
            document.write ("<span id=\"toggleright\"><a href=\"javascript:GoToPromotion('" + ToggleLink + "')\">" + TogglePhrase + "</a></span>");
        }
    } else {
        if (LinkPos == "stack" || LinkPos == "Stack"){
            document.write ("<div id=\"notLink\">" + CurrentPhrase + "</div>");
            document.write ("<div id=\"toggleright\"><a href=\"javascript:GoToPromotion('" + ToggleLink + "')\">" + TogglePhrase + "</a></div>");
        } else {
            document.write ("<span id=\"notLink\">" + CurrentPhrase + "</span>" + "<span id=\"toggledivider\">&nbsp;|&nbsp;</span><span id=\"toggleright\"><a href=\"javascript:GoToPromotion('" + ToggleLink + "')\">" + TogglePhrase + "</a></span>");
        }
    }

}

function GoToPromotion (ToggleURL){
    if (ToggleURL.indexOf ("browsepageflash")>0)
        setSubCookie("DisplayMode","preferred", "flash",1000);
    else 
        setSubCookie("DisplayMode","preferred", "html",1000);
        
    document.location.href = ToggleURL;
}

function DrawDetailViewAllItems (url)
{
    displayMode = (cms_getCookie("DisplayMode", "preferred", "html"));
    var action = (displayMode == "html") ? "browsepagesingle" : "browsepageflash";
    searchfor = "browsepagesingle";
    
    match = url.indexOf (searchfor);
    if (match != -1){
        tempLinkbegin = url.substring (0, match);
        tempLinkend = url.substring (match+searchfor.length, url.length);   
    } else {
        searchfor = "browsepageflash";
        match = url.indexOf (searchfor);
        if (match != -1){
            tempLinkbegin = url.substring (0, match);
            tempLinkend = url.substring (match+searchfor.length, url.length);   
        } else {
            var ViewAllLink = url;
        }
    }
        
    ViewAllLink = tempLinkbegin + action + tempLinkend; 
    window.location = ViewAllLink;  

}

function findShopLink (gridURL){
    searchfor = "addshoppinglist";
    match = gridURL.indexOf (searchfor);
    var gridListingID;
    
    if (match != -1){
        searchfor = "listingid";
        match = gridURL.indexOf (searchfor);
        gridListingID = gridURL.substring(match+10, match+21);
        return (gridListingID);
    } else {
        searchfor = "removeshoppinglist";
        match = gridURL.indexOf (searchfor);
        if (match != -1){
            searchfor = "listingid";
            match = gridURL.indexOf (searchfor);
            gridListingID = gridURL.substring(match+10, match+21);
            return (gridListingID);
        } else {
            return (0);     
        }
    }
}

var MM_PreviousVersion;
var MM_contentVersion = 7;
var MM_FlashCanPlay = false;
var bolHybridMode = false;

var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;    
if ( plugin ) {
        var words = navigator.plugins["Shockwave Flash"].description.split(" ");
        for (var i = 0; i < words.length; ++i){
            if (isNaN(parseInt(words[i])))
            continue;
            var MM_PluginVersion = words[i]; 
        }
        MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
&& (navigator.appVersion.indexOf("Win") != -1)) {
    document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
    document.write('on error resume next \n');
    document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
    document.write('MM_PreviousVersion = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion-1)))\n');
    document.write('</SCR' + 'IPT\> \n');
}

function DrawFlashMovie(id, url, width, height, flashvars)
{       
    if(flashvars==null)
        flashvars = "";

    if(MM_FlashCanPlay){
        document.write('<OBJECT style="border:0px solid Red" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" id="' + id + '" width="' + width + '" height="' + height + '" ALIGN="" VIEWASTEXT>');
        document.write('<param name="FlashVars" VALUE="' + flashvars + '">');   
        document.write('<param name="wmode" value="opaque">');
        document.write('<param name="allowScriptAccess" value="always">');
        document.write('<param name="movie" value="' + url + '" />');
        document.write('<param name="quality" value="high" />');
        document.write('<param name="scale" value="exactfit" />');
        document.write('<param name="bgcolor" value="#ffffff" />');
        document.write('<EMBED src="' + url + '" quality="high" scale="exactfit" bgcolor="#ffffff" width="' + width + '" height="' + height + '" swLiveConnect="true" ID="catalogN" NAME="' + id + '" ALIGN="" wmode="opaque" allowScriptAccess="always" FlashVars="' + flashvars + '" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>');
        document.write('</OBJECT>');
    }
    else{
        document.write('<table border="1" width="' + width + '" height="' + height + '" style="text-align:center;vertical-align:center;"><tr><td><a href="http://www.macromedia.com/go/getflashplayer" target="_new">Flash Required<br>Download Here</a></td></tr></table>');
    }
    
}

function DrawEmailAddress (){
    var emailAddress = cms_getCookie("QuickHoundEmailAlerts", "NotificationAddress242", null, null);
    if (emailAddress != "" && emailAddress != null)
        document.write (emailAddress);
}



//------------------------------------------------------------


function GetShoppingListListing(sid, lid, oid, mode)
{   
    //-2094570364:1965916,2398236 - with offerid
    //-2094570364,2398236 - without offerid
    var ids = cms_getCookie("shoppinglist", null, " ");
    var result = "";
        
    //empty list
    if(ids == " "){
        result = (mode==1) ? "<result></result>" : "";
        return result;
    }

    if(oid==null || oid==""){
        pos = ids.indexOf(lid + "," + sid);                 
        if(pos > -1){        
            // returns either 1965916,2398236 or ,1965916,2398236
            result = ((pos>0) ? "," : "") + lid + "," + sid;
            return ((mode==1) ? "<result>" + result + "<result>" : result);
        }
    }
    else{
        pos = ids.indexOf(lid + ":" + oid + "," + sid);
        if(pos > -1){
            // returns either -2094570364:1965916,2398236 or ,-2094570364:1965916,2398236
            result = ((pos>0) ? "," : "") + lid + ":" + oid + "," + sid;
            return ((mode==1) ? "<result>" + result + "<result>" : result);     
        }        
    }
    
    result = ((mode==1) ? "<result></result>" : "");
    return result;                
}

function RemoveShoppingListListing(sid, lid, oid, mode)
{
    var ids = new String(cms_getCookie("shoppinglist", null, " "));
    if(ids == "" || ids == " ")
        return (mode==1) ? "<result>false</result>" : false;
    
    var shoppinglistvalue = GetShoppingListListing(sid, lid, oid);
            
    if(shoppinglistvalue != ""){    
        var regEx = new RegExp (shoppinglistvalue, 'gi') ;
        ids = ids.replace(regEx, '');
        if(ids.substring(0,1) == ",")
            ids = ids.substring(1,ids.length);
        
        cms_setCookie("ShoppingList",ids, 360);
        
        var idcount = 0;    
        try{idcount = parseInt(cms_getCookie("ShoppingListCount", null, " "));}
        catch(e){}
        
        if(idcount>0){
            --idcount;
            cms_setCookie("ShoppingListCount",idcount, 360);
        }
        return (mode==1) ? "<result>true</result>" : true;
    }
    else{
        return (mode==1) ? "<result>false</result>" : false;
    }           
}

function AddShoppingListListing(sid, lid, oid, mode)
{
    try{
        if(sid==null || sid==undefined || sid.trim()=="" || isNaN(sid))
            return (mode==1) ? "<result>false</result>" : false;
        if(lid==null || lid==undefined || lid.trim()=="" || isNaN(lid))
            return (mode==1) ? "<result>false</result>" : false;
        if(oid!=null && oid.trim()!="" && isNaN(oid)) 
            return (mode==1) ? "<result>false</result>" : false;
            
        var ids = new String(cms_getCookie("shoppinglist", null, " ")).trim();  
        var shoppinglistvalue = GetShoppingListListing(sid, lid, oid);
                    
        if(shoppinglistvalue == ""){
            lid = (oid!=null&&oid.trim()!="") ? lid + ":" + oid : lid;  
            ids = (ids == "") ? lid+","+sid : ids+","+lid+","+sid;
            cms_setCookie("ShoppingList",ids, 360);

            var idcount = 0;    
            try{idcount = parseInt(cms_getCookie("ShoppingListCount", null, "0"));}
            catch(e){}
            
            idcount++;      
            cms_setCookie("ShoppingListCount", idcount, 360);       
            return (mode==1) ? "<result>true</result>" : true;
        }
        else{
            return (mode==1) ? "<result>false</result>" : false;
        }   
    }
    catch(e){
        return (mode==1) ? "<result>false</result>" : false;
    }       
}

function GetShoppingListCount(mode)
{      
    var count = 0;  
    try{count = parseInt(cms_getCookie("ShoppingListCount", null, "0"));}
    catch(e){}
    
    return (mode==1) ? "<result>" + count + "</result>" : count;        
}

function GetShoppingList()
{   
    var count = 0;  
    try{count = parseInt(cms_getCookie("ShoppingListCount", null, "0"));}
    catch(e){}
    
    var list = new String(cms_getCookie("shoppinglist", null, " "));        
    var xml = "<result><list>" + list.trim() + "</list><count>" + count + "</count></result>";
    return list.trim();
}

function GetShoppingListFlash(){
    fc.callFunction("_global.HTMLConduit","cbGetShoppingList", GetShoppingList());
}

function GetShoppingListCountFlash(mode){
    fc.callFunction ("_global.DATA.shoppingListData","updateListingCount", [GetShoppingListCount(mode), GetShoppingList()]);    
}

function AddShoppingListListingFlash(input){
	
    var arrinput = new Array(); 
    arrinput = input.split(','); 
    fc.callFunction ("_global.DATA.shoppingListData","shoppingListUpdated", [AddShoppingListListing(arrinput[0], arrinput[1], arrinput[2], 1), GetShoppingList()]);        
    GetShoppingListFlash();    
}

function RemoveShoppingListListingFlash(input){
	
    var arrinput = new Array(); 
    arrinput = input.split(',');    
    
    fc.callFunction("_global.DATA.shoppingListData","shoppingListUpdated", [RemoveShoppingListListing(arrinput[0], arrinput[1], arrinput[2], 1), GetShoppingList()]);
    GetShoppingListFlash();    
}

function UpdateShoppingListFlex(input){
    var arrinput = new Array(); 
    arrinput = input.split(','); 

    var result;
    if (arrinput[0]==0) { 
      result= RemoveShoppingListListing(arrinput[1], arrinput[2], arrinput[3], 0);
    }else {
      result= AddShoppingListListing(arrinput[1], arrinput[2], arrinput[3], 0);
    }
    return result;
}

function str_to_num(text) {
    
    var num_out = "";        
    var str_in = escape(text);
    
    for(i = 0; i < str_in.length; i++) 
        num_out += str_in.charCodeAt(i) - 23;
            
    return num_out;
}

function num_to_str(text) {
    var num_in;    
    var str_out = "";
    var num_out = text;  
   
    for(i = 0; i < num_out.length; i += 2) {
        num_in = parseInt(num_out.substr(i,[2])) + 23;
        num_in = unescape('%' + num_in.toString(16));
        str_out += num_in;
    }
    return unescape(str_out);
   
}

//------------------------------------------------------------



//START OF SDC Advanced Tracking Code
//Copyright (c) 1996-2005 WebTrends Inc.  All rights reserved.
//V7.5
// $DateTime: 2005/08/25 15:58:46 $

var gService = true;
var gTimeZone = -6;
var sDCSID =  "dcskey9gz00000slf8bxjryss_7v5p";

// Code section for Enable First-Party Cookie Tracking
function dcsCookie(){
	if (typeof(dcsOther)=="function"){
		dcsOther();
	}
	else if (typeof(dcsPlugin)=="function"){
		dcsPlugin();
	}
	else if (typeof(dcsFPC)=="function"){
		dcsFPC(gTimeZone);
	}
}
function dcsGetCookie(name){
	var pos=document.cookie.indexOf(name+"=");
	if (pos!=-1){
		var start=pos+name.length+1;
		var end=document.cookie.indexOf(";",start);
		if (end==-1){
			end=document.cookie.length;
		}
		return unescape(document.cookie.substring(start,end));
	}
	return null;
}
function dcsGetCrumb(name,crumb){
	var aCookie=dcsGetCookie(name).split(":");
	for (var i=0;i<aCookie.length;i++){
		var aCrumb=aCookie[i].split("=");
		if (crumb==aCrumb[0]){
			return aCrumb[1];
		}
	}
	return null;
}
function dcsGetIdCrumb(name,crumb){
	var cookie=dcsGetCookie(name);
	var id=cookie.substring(0,cookie.indexOf(":lv="));
	var aCrumb=id.split("=");
	for (var i=0;i<aCrumb.length;i++){
		if (crumb==aCrumb[0]){
			return aCrumb[1];
		}
	}
	return null;
}
function dcsFPC(offset){
	if (typeof(offset)=="undefined"){
		return;
	}
	var name=gFpc;
	var dCur=new Date();
	dCur.setTime(dCur.getTime()+(dCur.getTimezoneOffset()*60000)+(offset*3600000));
	var dExp=new Date(dCur.getTime()+315360000000);
	var dSes=new Date(dCur.getTime());
	if (document.cookie.indexOf(name+"=")!=-1){
		var id=dcsGetIdCrumb(name,"id");
		var lv=parseInt(dcsGetCrumb(name,"lv"));
		var ss=parseInt(dcsGetCrumb(name,"ss"));
		if ((id==null)||(id=="null")||isNaN(lv)||isNaN(ss)){
			return;
		}
		WT.co_f=id;
		var dLst=new Date(lv);
		dSes.setTime(ss);
		if ((dCur.getTime()>(dLst.getTime()+1800000))||(dCur.getTime()>(dSes.getTime()+28800000))){
			dSes.setTime(dCur.getTime());
			WT.vt_f_s="1";
		}
		if ((dCur.getDay()!=dLst.getDay())||(dCur.getMonth()!=dLst.getMonth())||(dCur.getYear()!=dLst.getYear())){
			WT.vt_f_d="1";
		}
	}
	else{
		var tmpname=name+"_TMP=";
		document.cookie=tmpname+"1";
		if (document.cookie.indexOf(tmpname)!=-1){
			document.cookie=tmpname+"; expires=Thu, 01-Jan-1970 00:00:01 GMT";
			if ((typeof(gWtId)!="undefined")&&(gWtId!="")){
				WT.co_f=gWtId;
			}
			else if ((typeof(gTempWtId)!="undefined")&&(gTempWtId!="")){
				WT.co_f=gTempWtId;
				WT.vt_f="1";
			}
			else{
				WT.co_f="2";
				var cur=dCur.getTime().toString();
				for (var i=2;i<=(32-cur.length);i++){
					WT.co_f+=Math.floor(Math.random()*16.0).toString(16);
				}
				WT.co_f+=cur;
				WT.vt_f="1";
			}
			if (typeof(gWtAccountRollup)=="undefined"){
				WT.vt_f_a="1";
			}
			WT.vt_f_s="1";
			WT.vt_f_d="1";
		}
		else{
			WT.vt_f="2";
			WT.vt_f_a="2";
			return;
		}
	}
	WT.co_f=escape(WT.co_f);
	WT.vt_sid=WT.co_f+"."+dSes.getTime();
	var expiry="; expires="+dExp.toGMTString();
	document.cookie=name+"="+"id="+WT.co_f+":lv="+dCur.getTime().toString()+":ss="+dSes.getTime().toString()+expiry+"; path=/"+(((typeof(gFpcDom)!="undefined")&&(gFpcDom!=""))?("; domain="+gFpcDom):(""));
}

// Code section for Use the new first-party cookie generated with this tag.
var gFpc="WT_FPC";
var gWtId="";
var gTempWtId="";
var gConvert=true;

function dcsAdv(){
	dcsFunc("dcsET");
	dcsFunc("dcsCookie");
	dcsFunc("dcsAdSearch");
}



var gImages=new Array;
var gIndex=0;
var DCS=new Object();
var WT=new Object();
var DCSext=new Object();
var gQP=new Array();

var gDomain="statse.webtrendslive.com";
var gDcsId= sDCSID;


if ((typeof(gConvert)!="undefined")&&gConvert&&(document.cookie.indexOf(gFpc+"=")==-1))
{
	document.write("<SCR"+"IPT Language='JavaScript' SRC='"+"http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+"/"+gDcsId+"/wtid.js"+"'></SCR"+"IPT>");
}


function dcsVar(){
	var dCurrent=new Date();
	WT.tz=dCurrent.getTimezoneOffset()/60*-1;
	if (WT.tz==0){
		WT.tz="0";
	}
	WT.bh=dCurrent.getHours();
	WT.ul=navigator.appName=="Netscape"?navigator.language:navigator.userLanguage;
	if (typeof(screen)=="object"){
		WT.cd=navigator.appName=="Netscape"?screen.pixelDepth:screen.colorDepth;
		WT.sr=screen.width+"x"+screen.height;
	}
	if (typeof(navigator.javaEnabled())=="boolean"){
		WT.jo=navigator.javaEnabled()?"Yes":"No";
	}
	if (document.title){
		WT.ti=document.title;
	}
	WT.js="Yes";
	if (typeof(gVersion)!="undefined"){
		WT.jv=gVersion;
	}
	if (document.body&&document.body.addBehavior){
		document.body.addBehavior("#default#clientCaps");
		if (document.body.connectionType){
			WT.ct=document.body.connectionType;
		}
		document.body.addBehavior("#default#homePage");
		WT.hp=document.body.isHomePage(location.href)?"1":"0";
	}
	if (parseInt(navigator.appVersion)>3){
		if ((navigator.appName=="Microsoft Internet Explorer")&&document.body){
			WT.bs=document.body.offsetWidth+"x"+document.body.offsetHeight;
		}
		else if (navigator.appName=="Netscape"){
			WT.bs=window.innerWidth+"x"+window.innerHeight;
		}
	}
	WT.fi="No";
	if (window.ActiveXObject){
		if ((typeof(gFV)!="undefined")&&(gFV.length>0)){
			WT.fi="Yes";
			WT.fv=gFV;
		}
	}
	else if (navigator.plugins&&navigator.plugins.length){
		for (var i=0;i<navigator.plugins.length;i++){
			if (navigator.plugins[i].name.indexOf('Shockwave Flash')!=-1){
				WT.fi="Yes";
				WT.fv=navigator.plugins[i].description.split(" ")[2];
				break;
			}
		}
	}
	WT.sp="@@SPLITVALUE@@";
	DCS.dcsdat=dCurrent.getTime();
	DCS.dcssip=window.location.hostname;
	DCS.dcsuri=window.location.pathname;
	if (window.location.search){
		DCS.dcsqry=window.location.search;
		if (gQP.length>0){
			for (var i=0;i<gQP.length;i++){
				var pos=DCS.dcsqry.indexOf(gQP[i]);
				if (pos!=-1){
					var front=DCS.dcsqry.substring(0,pos);
					var end=DCS.dcsqry.substring(pos+gQP[i].length,DCS.dcsqry.length);
					DCS.dcsqry=front+end;
				}
			}
		}
	}
	if ((window.document.referrer!="")&&(window.document.referrer!="-")){
		if (!(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)<4)){
			DCS.dcsref=window.document.referrer;
		}
	}
}

function A(N,V){
	return "&"+N+"="+dcsEscape(V);
}

function dcsEscape(S){
	if (typeof(RE)!="undefined"){
		var retStr = new String(S);
		for (R in RE){
			retStr = retStr.replace(RE[R],R);
		}
		return retStr;
	}
	else{
		return escape(S);
	}
}

function dcsLoadHref(evt){
	if ((typeof(gHref)!="undefined")&&(gHref.length>0)){
		window.location=gHref;
		gHref="";
	}
}

function dcsCreateImage(dcsSrc){
	if (document.images){
		gImages[gIndex]=new Image;
		if ((typeof(gHref)!="undefined")&&(gHref.length>0)){
			gImages[gIndex].onload=gImages[gIndex].onerror=dcsLoadHref;
		}
		gImages[gIndex].src=dcsSrc;
		gIndex++;
	}
	else{
		document.write('<IMG BORDER="0" NAME="DCSIMG" WIDTH="1" HEIGHT="1" SRC="'+dcsSrc+'">');
	}
}

function dcsMeta(){
	var elems;
	if (document.all){
		elems=document.all.tags("meta");
	}
	else if (document.documentElement){
		elems=document.getElementsByTagName("meta");
	}
	if (typeof(elems)!="undefined"){
		for (var i=1;i<=elems.length;i++){
			var meta=elems.item(i-1);
			if (meta.name){
				if (meta.name.indexOf('WT.')==0){
					WT[meta.name.substring(3)]=meta.content;
				}
				else if (meta.name.indexOf('DCSext.')==0){
					DCSext[meta.name.substring(7)]=meta.content;
				}
				else if (meta.name.indexOf('DCS.')==0){
					DCS[meta.name.substring(4)]=meta.content;
				}
			}
		}
	}
}

function dcsTag(){
	var P="http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+(gDcsId==""?'':'/'+gDcsId)+"/dcs.gif?";
	for (N in DCS){
		if (DCS[N]) {
			P+=A(N,DCS[N]);
		}
	}
	for (N in WT){
		if (WT[N]) {
			P+=A("WT."+N,WT[N]);
		}
	}
	for (N in DCSext){
		if (DCSext[N]) {
			P+=A(N,DCSext[N]);
		}
	}
	if (P.length>2048&&navigator.userAgent.indexOf('MSIE')>=0)
	{
		P=P.substring(0,2040)+"&WT.tu=1";
	}
	dcsCreateImage(P);
}

function dcsFunc(func){
	if (typeof(window[func])=="function"){
		window[func]();
	}
}

function dcsMultiTrack(){

	for (var i=0;i<arguments.length;i++)
	{	
	if(arguments[i]!=null)
	{	
		if (arguments[i].indexOf('WT.')==0)
		{						
			WT[arguments[i].substring(3)]=arguments[i+1];
			if (i < (arguments.length - 1))
			{
				i++;
			}
		}
		if (arguments[i].indexOf('DCS.')==0){
			DCS[arguments[i].substring(4)]=arguments[i+1];
			if (i < (arguments.length - 1))
			{
				i++;
			}
		}		
		if (arguments[i].indexOf('DCSext.')==0){
			DCSext[arguments[i].substring(7)]=arguments[i+1];
			if (i < (arguments.length - 1))
			{
				i++;
			}
		}
	}
	}
	var dCurrent=new Date();
	DCS.dcsdat=dCurrent.getTime();
	dcsTag();
}

dcsVar();
dcsMeta();
dcsFunc("dcsAdv");
dcsTag();

/*
 * These scripts are used to fix a bug where IE limits any string passed from 
 * a Flash object to 508 characters.
 */
var sFlashToJS = "";
function buildFlashToJSString (sUpdate) 
{
	var stepper = 0;
	var argCnt = arguments.length;		
	for (i = 0; i < arguments.length; i++) 
	{		
		sFlashToJS += arguments[i] + ',';		
	}		
	sFlashToJS = sFlashToJS.substring(0,sFlashToJS.length - 1);		
}

function sendFlashToJSString () 
{
	dcsMultiTrack(sFlashToJS);
}

function clearFlashToJSString () {
	sFlashToJS = "";
}


function outputFlashToJSString () 
{	
	if(sFlashToJS.length > 1020)
	{
		var sStart = '';
		var sEnd = '';
		var pn_sku = '';
		var tx_u = '';
		var sReplace = '';
		var i, j, m, n;
		
		sStart = sFlashToJS.substring(0,sFlashToJS.indexOf('WT.tx_u'));
		sEnd = sFlashToJS.substring(sFlashToJS.indexOf('WT.si_n'));
		
		var P1 = sFlashToJS.substring(sFlashToJS.indexOf('WT.pn_sku,'),sFlashToJS.indexOf(',WT.si_n'));
		P1 = P1.substring(10,P1.length);
		var P1Array = P1.split(";");
		
		var loopLen = P1Array.length/2;		
		for(i = 0; i < loopLen; i++)
		{
			pn_sku += P1Array[i] + ';';
		}
		
		pn_sku = pn_sku.substring(0,pn_sku.length - 1);
		pn_sku = ',WT.pn_sku,' + pn_sku + ',';
		
		for(j = 0; j < loopLen; j++)
		{
			tx_u += '1;';
		}
		
		tx_u = tx_u.substring(0,tx_u.length - 1);
		tx_u = 'WT.tx_u,' + tx_u ;				
		
		sReplace = sStart + tx_u + pn_sku + sEnd;
		var aCall = sReplace.split(",");
		
		dcsMultiTrack(aCall[0], aCall[1], aCall[2], aCall[3], aCall[4], aCall[5], aCall[6], aCall[7], aCall[8], aCall[9], aCall[10], aCall[11], aCall[12], aCall[13], aCall[14], aCall[15]);
		
		pn_sku = '';
		tx_u = '';
		
		//If listingID count is odd subtract one from main counter
		if(P1Array.length%2 == 1)
		{
			loopLen = loopLen + i - 1;
		}
		else
		{
			loopLen = loopLen + i;
		}
		
		for(m = i; m < loopLen; m++)
		{
			pn_sku += P1Array[m] + ';';
		}
		
		pn_sku = pn_sku.substring(0,pn_sku.length - 1);
		pn_sku = ',WT.pn_sku,' + pn_sku + ',';
		
		for(n = j; n < loopLen; n++)
		{
			tx_u += '1;';
		}
		tx_u = tx_u.substring(0,tx_u.length - 1);
		tx_u = 'WT.tx_u,' + tx_u ;				
		
		sReplace = sStart + tx_u + pn_sku + sEnd;
		var aCall = sReplace.split(",");
		
		dcsMultiTrack(aCall[0], aCall[1], aCall[2], aCall[3], aCall[4], aCall[5], aCall[6], aCall[7], aCall[8], aCall[9], aCall[10], aCall[11], aCall[12], aCall[13], aCall[14], aCall[15]);
		clearFlashToJSString();	
	}
	else
	{
		var aCall = sFlashToJS.split(",");
		dcsMultiTrack(aCall[0], aCall[1], aCall[2], aCall[3], aCall[4], aCall[5], aCall[6], aCall[7], aCall[8], aCall[9], aCall[10], aCall[11], aCall[12], aCall[13], aCall[14], aCall[15]);
		clearFlashToJSString();	
	}
	
	
}



