// 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 TrackElement(NewURL, Element)
{
    var url = '../TrackElement.aspx?newurl=' + escape(NewURL)+ '&from=' + Element;
    window.location.href = url;
}
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;
}

function ValidateForm() {
    var bIsValid = true;
    if (document.getElementById('ContactUs_TechSupport_txtCustomerName').value.length == 0) {
        document.getElementById('lblCustomerName').style.display = "";
        bIsValid = false;
    }

    if (document.getElementById('ContactUs_TechSupport_txtCustEmail').value.length == 0) {
        document.getElementById('lblCustEmail').style.display = "";
        bIsValid = false;
    }

    if (document.getElementById('ContactUs_TechSupport_txtMessage').value.length == 0) {
        document.getElementById('lblMessage').style.display = "";
        bIsValid = false;
    }

    if (bIsValid) {
        document.getElementById('lblConfirmation').style.display = "";
        }
    else  {
        document.getElementById('lblConfirmation').style.display = "none";
    }
    return bIsValid;
}

