// JavaScript Document

	stra = window.location.search.substr(1).split("&"); 	
	pwd_str = stra[0].split("=");			


var changeImageFlag;
var defImageID;	
function showDiscProd(){
	stra = window.location.search.substr(1).split("&"); 	
	pwd_str = stra[0].split("=");	
	if (pwd_str[0]=="discprodid")
	{			
		showLayers();
		var timeset=setTimeout("hideLayers()", 10000); 
		
	}	
}
var ie = 0;
var ns = 0;
if (window.navigator.userAgent.indexOf("MSIE") != -1) 
{
	var ua = window.navigator.userAgent;
	var msie = ua.indexOf ( "MSIE " );
	var version = parseInt(ua.substring (msie+5, ua.indexOf (".", msie )));
	if (version >= 5) 
	{ ie = 1;} 
	else
	{ ns = 1;} 
} 	
else if (navigator.appName.indexOf("Netscape") != -1)
{
	if (parseFloat(navigator.appVersion) >= 4.04) 
	{ 
		ns = 1;
	} 
} 

function hideLayers() { 
if (ie=1)
	{
	document.all.Layer1.style.visibility="hidden";
	document.all.Layer2.style.visibility="hidden";
	}
else if (ns=1)
	{
	document.Layer1.visibility="hide";
	document.Layer2.visibility="hide";
	}
else if (type=="MO" || type=="OP") 
	{
	document.getElementById("Layer1").style.visibility="hidden";
	document.getElementById("Layer2").style.visibility="hidden";
	}
}

function showLayers() { 
if (ie=1)
	{
	document.all.Layer1.style.visibility="visible";
	document.all.Layer2.style.visibility="visible";
	}
else if (ns=1)
	{
	document.Layer1.visibility="show";
	document.Layer2.visibility="show";
	}
else if (type=="MO" || type=="OP") 
	{
	document.getElementById("Layer1").style.visibility="visible";
	document.getElementById("Layer2").style.visibility="visible";
	}
}

	function SubscribeMe()
	{
		//Verify Email was entered
		if (document.frmQuote.EmailAddress.value == '' || ValidateEmail(document.frmQuote.EmailAddress.value) == false)
		{
			document.getElementById('ErrorMessage').style.display = '';
		}
		else
		{
			document.getElementById('ErrorMessage').style.display = 'none';
			document.frmQuote.email.value = document.frmQuote.EmailAddress.value;
			document.frmQuote.action = "tEmailSubs_Subscribe_Successful_lyr.asp?wherefrom=INTQSUBHP";
			document.frmQuote.submit();
		}
	}
	
	function ValidateEmail(Email)
	{
		var reg  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  		//check for valid email
  		return reg.test(Email);
	}

function AddToCart(sURL)
{
	window.location.href = sURL;
}
function UnCheckALL()
{
	for ( var index = 0; index < frmdigprodselect.elements.length; index++ )
	{
		var oElement = frmdigprodselect.elements[ index ];
		if ( oElement.type == "checkbox" && oElement.id.indexOf('_s') > -1)
		{
			oElement.checked = false;
		}
	}
}
function highlight(sobjRow,sobjChkBox){
	var objChkBox = document.getElementById(sobjChkBox);
	var objRow = document.getElementById(sobjRow);
	if (objChkBox.checked==true) {
  		objRow.style.background="#FFFFCC";
		}
	else {
		objRow.style.background="white";
		}
}

function chkhighlight(sobjRow,sobjChkBox){
	var objChkBox = document.getElementById(sobjChkBox);
	var objRow = document.getElementById(sobjRow);
	
	if (objChkBox.checked)
	{
		objChkBox.checked=false;
		objRow.style.background="#FFFFFF";
	}
	else
	{
		objChkBox.checked=true;
		objRow.style.background="#FFFFCC";
	}
}

function uncheck(sobjRow,sobjChkBox){
	var objChkBox = document.getElementById(sobjChkBox);
	var objRow = document.getElementById(sobjRow);
	objRow.style.background="white"
	objChkBox.checked=false
}

function GetTotalPrice(sobjChkBox, sobjProdChkBox, UKProd)
{
	var objChkBox = document.getElementById(sobjChkBox);
	var objProdChkBox = document.getElementById(sobjProdChkBox);
	dPrice = 0;

	//If the Product Check Box is selected, then use the Prod Price
	if (objProdChkBox.checked == true)
	{
		//Strip out Price from HTML
		dPrice = FormatCurrency(document.getElementById('divPrice').innerText, UKProd);
	}
	else
	{
	//else determine price based on selected Issues
		for ( var index = 0; index < frmdigprodselect.elements.length; index++ )
  		{
    		var oElement = frmdigprodselect.elements[ index ];
			if ( oElement.type == "checkbox" )
    		{
      			if ( oElement.checked )
      			{
					//use element (aka Checkbox) id, to determine divPrice id
					sSplit = oElement.id.split("chk");
        			dPrice = parseFloat(dPrice) + parseFloat(FormatCurrency(document.getElementById('divPrice' + sSplit[1] + '').innerText, UKProd));
      			}
			}
		}
	}  			
	

	//Format Price as Currency
	dPrice = FormatCurrency(dPrice, UKProd);

	//If the total price is 0, hide the Buy Now Buttons
	if (dPrice == "0.00")
	{
		document.getElementById('spnBuyNow').style.display = "none";
		//Set Button InnerText to include price
		frmdigprodselect.btnBuyNow.innerText = "Buy Now";
		frmdigprodselect.btnBuyNow2.innerText = "Buy Now";
	}
	else
	{
		if (UKProd.toLowerCase() != 'true')
		{
			document.getElementById('spnBuyNow').style.display = "";
			//Set Button InnerText to include price
			frmdigprodselect.btnBuyNow.innerText = "Buy Now ($" + dPrice + ")";
			frmdigprodselect.btnBuyNow2.innerText = "Buy Now ($" + dPrice + ")";
		}
		else
		{
			document.getElementById('spnBuyNow').style.display = "";
			//Set Button InnerText to include price
			frmdigprodselect.btnBuyNow.innerText = "Buy Now (" + dPrice + ")";
			frmdigprodselect.btnBuyNow2.innerText = "Buy Now (" + dPrice + ")";
		}
	}
	
	document.all('DownloadMessage').innerText = "";
	
}

function FormatCurrency(sValue, UKProd)
{
	if (UKProd.toLowerCase() != 'true')
	{
		sValue= sValue.toString().replace(/\$|\,/g,'');
		dValue = parseFloat(sValue);
	
		bSign = (dValue == (dValue = Math.abs(dValue)));
		dValue = Math.floor(dValue*100+0.50000000001);
		iCents = dValue%100;
		sCents = iCents.toString();
		dValue = Math.floor(dValue/100).toString();
		if(iCents<10)
			sCents = "0" + sCents;
		for (var i = 0; i < Math.floor((dValue.length-(1+i))/3); i++)
			dValue = dValue.substring(0,dValue.length-(4*i+3))+','+
			dValue.substring(dValue.length-(4*i+3));
		return (((bSign)?'':'-') + dValue + '.' + sCents);
	}
	else
	{
		sValue= sValue.toString().replace(/\|\,/g,'');
		dValue = parseFloat(sValue);
	
		bSign = (dValue == (dValue = Math.abs(dValue)));
		dValue = Math.floor(dValue*100+0.50000000001);
		iCents = dValue%100;
		sCents = iCents.toString();
		dValue = Math.floor(dValue/100).toString();
		if(iCents<10)
			sCents = "0" + sCents;
		for (var i = 0; i < Math.floor((dValue.length-(1+i))/3); i++)
			dValue = dValue.substring(0,dValue.length-(4*i+3))+','+
			dValue.substring(dValue.length-(4*i+3));
		return (((bSign)?'':'-') + dValue + '.' + sCents);
	}
}

function BuySessions()
{
	var bChecked = false;
	for ( var index = 0; index < frmdigprodselect.elements.length; index++ )
  	{
		var oElement = frmdigprodselect.elements[ index ];
		if ( oElement.type == "checkbox" )
		{
			if ( oElement.checked )
			{
				bChecked = true;
			}
		}
	}
	
	if (bChecked == true)
	{
		frmdigprodselect.submit();
	}
	else
	{
		document.all('DownloadMessage').innerText = 'Please select at least one session to download.';
		window.location.href = "#Downloads";
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
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_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 WriteOutFlashMP3Streamer(Title, FilePath)
{
    var FlashHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='350' height='150'>" +
            "<param name='movie' value='mediacontrols/mp3_flash_player.swf?Title=" + Title + "&FilePath=" + FilePath + "' />" +
            "<param name='quality' value='high' />" +
            "<embed src='mediacontrols/mp3_flash_player.swf?Title=" + Title + "&FilePath=" + FilePath + "' quality='high' pluginspage='https://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='350' height='150'></embed>" +
            "</object>";
   return FlashHTML;
}
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_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 TrackClick(NewURL, BannerFrom)
{
    BannerFrom = BannerFrom.replace('.swf', '');
    BannerFrom = BannerFrom.replace('.SWF', '');
    var url = 'TrackRotatingBanner.aspx?newurl=' + escape(NewURL)+ '&from=' + escape(BannerFrom);
    window.location.href = url;
}

function TrackElement(NewURL, Element,NewWindow)
{
    if (NewWindow == null || NewWindow == undefined || NewWindow != "true")
   { 
        var url = 'TrackElement.aspx?newurl=' + escape(NewURL)+ '&from=' + Element;
        window.location.href = url;
    }
   else
   {
        window.open('TrackElement.aspx?newurl=' + escape(NewURL)+ '&from=' + Element);
   } 
}
function GetQueryVariable(variable) 
{ 
    var query = window.location.search.substring(1);
    if (query == null || query == "")
    {
        //split out linkfreeze parms
        var s = window.location.href.toLowerCase().indexOf('~');
        var e = window.location.href.toLowerCase().indexOf('.aspx');
        var query = window.location.href.substring(s,e);
        var vars = query.split("~");
        for (var i=1;i<vars.length;i=i+2)
        {
            if (vars[i] == variable)
            {
                return vars[i+1];
            }
        }
    }
    else
    {
        var vars = query.split("&"); 
        for (var i=0;i<vars.length;i++)
        { 
            var pair = vars[i].split("=");
            if (pair[0] == variable) 
            { 
                return pair[1]; 
            } 
        } 
    }
}
//Logic To Check for tracked Anchor Links
var anchor = GetQueryVariable("anchor");
if (anchor != null && anchor != undefined)
{
    window.location.href = window.location.href + "#" + anchor;
}
//Used For Tracking RP URLs - Time on Page
var start = new Date();
function TrackTime()
{
    var end = new Date();
    var timeonpage = (end - start) / 1000;
    if (timeonpage < 900)
    {
        var url = "TrackURLTimer.aspx?timeonpage=" + timeonpage + "&track=" + window.location.href;
        document.getElementById("TrackURLTimer").src = url;
    }
}

// CODE FOR TABBED CONTENT PROMO BANNER
function ddtabcontent(tabinterfaceid){
	this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container
	this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container
	this.enabletabpersistence=true
	this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
	this.subcontentids=[] //Array to store ids of the sub contents ("rel" attr values)
	this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
	this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")
}

ddtabcontent.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

ddtabcontent.setCookie=function(name, value){
	document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
}

ddtabcontent.prototype={

	expandit:function(tabid_or_position){ //PUBLIC function to select a tab either by its ID or position(int) within its peers
		this.cancelautorun() //stop auto cycling of tabs (if running)
		var tabref=""
		try{
			if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=document.getElementById(tabid_or_position)
			else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=this.tabs[tabid_or_position]
		}
		catch(err){alert("Invalid Tab ID or position entered!")}
		if (tabref!="") //if a valid tab is found based on function parameter
			this.expandtab(tabref) //expand this tab
	},

	setpersist:function(bool){ //PUBLIC function to toggle persistence feature
			this.enabletabpersistence=bool
	},

	setselectedClassTarget:function(objstr){ //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")
		this.selectedClassTarget=objstr || "link"
	},

	getselectedClassTarget:function(tabref){ //Returns target element to assign "selected" CSS class to
		return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref
	},

	expandtab:function(tabref){
		var subcontentid=tabref.getAttribute("rel") //Get id of subcontent to expand
		//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easily search through
		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
		this.expandsubcontent(subcontentid)
		this.expandrevcontent(associatedrevids)
		for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : ""
		}
		if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
			ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition)
	},

	expandsubcontent:function(subcontentid){
		for (var i=0; i<this.subcontentids.length; i++){
			var subcontent=document.getElementById(this.subcontentids[i]) //cache current subcontent obj (in for loop)
			subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none" //"show" or hide sub content based on matching id attr value
		}
	},


	expandrevcontent:function(associatedrevids){
		var allrevids=this.revcontentids
		for (var i=0; i<allrevids.length; i++){ //Loop through rev attributes for all tabs in this tab interface
			//if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it
			document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"
		}
	},

	autorun:function(){ //function to auto cycle through and select tabs based on a set interval
		var currentTabIndex=this.automode_currentTabIndex //index within this.hottabspositions to begin
		var hottabspositions=this.hottabspositions //Array containing position numbers of "hot" tabs (those with a "rel" attr)
		this.expandtab(this.tabs[hottabspositions[currentTabIndex]])
		this.automode_currentTabIndex=(currentTabIndex<hottabspositions.length-1)? currentTabIndex+1 : 0 //increment currentTabIndex
	},

	cancelautorun:function(){
		if (typeof this.autoruntimer!="undefined")
			clearInterval(this.autoruntimer)
	},

	init:function(automodeperiod){
		var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
		var persisterror=true //Bool variable to check whether persisted tab position is valid (can become invalid if user has modified tab structure)
		this.automodeperiod=automodeperiod || 0
		for (var i=0; i<this.tabs.length; i++){
			this.tabs[i].tabposition=i //remember position of tab relative to its peers
			if (this.tabs[i].getAttribute("rel")){
				var tabinstance=this
				this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
				this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel") //store id of sub content ("rel" attr value)
				this.tabs[i].onclick=function(){
					tabinstance.expandtab(this)
					tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
					return false
				}
				if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element
					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
				}
				if (this.enabletabpersistence && parseInt(persistedtab)==i || !this.enabletabpersistence && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
					this.expandtab(this.tabs[i]) //expand current tab if it's the persisted tab, or if persist=off, carries the "selected" CSS class
					persisterror=false //Persisted tab (if applicable) was found, so set "persisterror" to false
					//If currently selected tab's index(i) is greater than 0, this means its not the 1st tab, so set the tab to begin in automode to 1st tab:
					this.automode_currentTabIndex=(i>0)? 0 : 1
				}
			}
		} //END for loop
		if (persisterror) //if an error has occured while trying to retrieve persisted tab (based on its position within its peers)
			this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr
		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
			this.automode_currentTabIndex=this.automode_currentTabIndex || 0
			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
		}
	} //END int() function

} //END Prototype assignment