/* function to instantiate an XMLHttp object */
function NewXMLHttpInstance(p_Handler) { 
	var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; 
	var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0; 
	var is_opera = ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0; 
	//netscape, safari, mozilla behave the same??? 
	var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0; 					
    var objXmlHttp = null;    //Holds the local xmlHTTP object instance 
   //Depending on the browser, try to create the xmlHttp object 
	if (is_ie){ 
		//The object to create depends on version of IE 
		//If it isn't ie5, then default to the Msxml2.XMLHTTP object 
		var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP'; 
		    
		//Attempt to create the object 
		try{ 
			objXmlHttp = new ActiveXObject(strObjName); 
			objXmlHttp.onreadystatechange = p_Handler; 
		} 
		catch(e){ 
		//Object creation errored 
			alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled'); 
			return; 
		} 
	} 
	else if (is_opera){ 
		//Opera has some issues with xmlHttp object functionality 
		alert('Opera detected. The page may not behave as expected.'); 
		return; 
	} 
	else{ 
		// Mozilla | Netscape | Safari 
		objXmlHttp = new XMLHttpRequest(); 
		objXmlHttp.onload = p_Handler; 
		objXmlHttp.onerror = p_Handler; 
	} 
		
	//Return the instantiated object 
	return objXmlHttp; 
} 

/* function to send XMLHttp request */
function SendXMLHttpRequest(p_objXMLHttp, p_URL) { 
	p_objXMLHttp.open('GET', p_URL, true); 
	p_objXMLHttp.send(null); 
} 
/*=====================================================================================================================*/

function openEmailClient(p_UserID,p_Domain,p_Subject) {
   var m_arrParameters = openEmailClient.arguments;
   
   if (m_arrParameters.length==3) {
      document.location = 'mailto:' + m_arrParameters[0] + '@' + m_arrParameters[1] + '?subject=' + m_arrParameters[2];
   } else {
      document.location = 'mailto:' + m_arrParameters[0] + '@' + m_arrParameters[1];
   }
}

function showHideList(p_Div, p_Anchor) {
   var m_oDivContent = document.getElementById(p_Div);
   
   if (m_oDivContent.style.display == 'none') {
      m_oDivContent.style.display = 'block';
      p_Anchor.innerHTML = 'Hide list';
   } else {
      m_oDivContent.style.display = 'none';
      p_Anchor.innerHTML = 'Show list';
   }   
   return true
}

function showHideDesc(p_Div, p_Anchor) {
   var m_oDivContent = document.getElementById(p_Div);
   
   if (m_oDivContent.style.display == 'none') {
      m_oDivContent.style.display = 'block';
      p_Anchor.innerHTML = '[hide description]';
   } else {
      m_oDivContent.style.display = 'none';
      p_Anchor.innerHTML = '[more..]';
   }   
   return true
}

function printWindow(){
	browserVersion = parseInt(navigator.appVersion)
	if (browserVersion >= 4) window.print();
}

/* 
	~ This function reads a media URL and generates embedding code to play back the audio file. 
	~ Windows browsers (except for Internet Explorer) will play back the file with the Windows Media Player *plugin.* Internet Explorer will use Windows Media Player.
	~ Non-Windows browsers will play back the file with their standard audio handler for the MIME type audio/mpeg. On Macs, that handler will usually be QuickTime.
	~ Original code can be found at http://www.oreillynet.com/pub/a/oreilly/digitalmedia/2006/05/31/build-a-better-web-audio-player.html?page=1 by David Battino.
*/
function embedPlayer(p_MediaURL, p_intWidth, p_intHeight) { 
	// If you have a default audio directory, e.g., http://www.your-media-hosting-site.com/sounds/, you can put it here to make links on the referring page shorter.
	var audioFolder = "/catalogue/preview/"; 
	
	if (arguments.length < 3) {
		p_intWidth = 280;
		p_intHeight = 69;
	}

	// Get Operating System 
	var isWin = navigator.userAgent.toLowerCase().indexOf("windows") != -1
	if (isWin) { // Use MIME type application/x-mplayer2
		visitorOS="Windows";
	} else { // Use MIME type audio/mpeg, audio/x-wav, etc.
		visitorOS="Other";
	}

	var audioURL = audioFolder + p_MediaURL;
	
	var objTypeTag = "application/x-mplayer2"; // The  MIME type to load the WMP plugin in non-IE browsers on Windows
	if (visitorOS != "Windows") { objTypeTag = "audio/mpeg"}; // The MIME type for Macs and Linux 
	
	document.writeln("<div style='text-align: center;'>");
	document.writeln("<object width='" + p_intWidth + "' height='" + p_intHeight + "'>"); // Width is the WMP minimum. Height = 45(WMP controls) + 24 (WMP status bar) 
	document.writeln("<param name='type' value='" + objTypeTag + "'>");
	document.writeln("<param name='src' value='" + audioURL + "'>");
	document.writeln("<param name='autostart' value='1'>");
	document.writeln("<param name='showcontrols' value='1'>");
	document.writeln("<param name='showstatusbar' value='1'>");
	document.writeln("<param name='volume' value='100'>");
	document.writeln("<embed src ='" + audioURL + "' type='" + objTypeTag + "' autoplay='true' autostart='1' width='" + p_intWidth + "' height='" + p_intHeight + "' volume='100' controller='1' showstatusbar='1' bgcolor='#ffffff'></embed>"); // Firefox and Opera Win require both autostart and autoplay
	document.writeln("</object>");
	document.writeln("</div>");
	document.close();
} 

function setMonthNumberOfDays(oYear, oMonth, oDay) {
	var oSelectedDate1stDayOfTheMonth;
	var oSelectedDateLastDayOfTheMonth;	
	var iPreviouslySelectedDay;
	var iTimeDifference, iSelectedMonthNumberOfDays;	
	var i;
	
	try {
		iPreviouslySelectedDay = oDay.options[oDay.selectedIndex].value;
		
		oSelectedDate1stDayOfTheMonth = new Date(oYear.options[oYear.selectedIndex].value, oMonth.options[oMonth.selectedIndex].value,1);
		iTimeDifference = oSelectedDate1stDayOfTheMonth - 86400000;
		
		oSelectedDateLastDayOfTheMonth = new Date(iTimeDifference);
		iSelectedMonthNumberOfDays = oSelectedDateLastDayOfTheMonth.getDate();
		
		for (var i = 0; i < oDay.length; i++) {
			oDay.options[0] = null;
		}
		
		for (var i = 0; i < iSelectedMonthNumberOfDays; i++) {oDay.options[i] = new Option(i+1,i+1);}

		if (iSelectedMonthNumberOfDays >= iPreviouslySelectedDay) {
			oDay.options[iPreviouslySelectedDay-1].selected = true;
		} else {
			oDay.options[0].selected = true;
		}
	} catch(e) {return}
}

/* description: get the index of the selected option in radio button array. */
function selectedRadioButtonIndex(oRadioButton) {
	var iCtr,iSelectedRadioButtonIndex;
	var blnSelected = false;
	
	for(iCtr=0;iCtr<oRadioButton.length;iCtr++) {
		if (oRadioButton[iCtr].checked) {
			iSelectedRadioButtonIndex = iCtr;
			blnSelected = true;
			break;
		}
	}
		
	if (blnSelected) {	return iSelectedRadioButtonIndex	} 
	else {		return -1	}
}

function transferSelectedList(oListFrom,oListTo) {
	var iCtr = 0;
	
	if (oListFrom.selectedIndex != -1) {
		for(iCtr=0;iCtr<oListFrom.options.length;++iCtr) {
			if (oListFrom.options[iCtr].selected) {
				oListTo.options[oListTo.options.length] = new Option(oListFrom.options[iCtr].innerText, oListFrom.options[iCtr].value);
				oListTo.options[oListTo.options.length-1].selected = true;
				oListFrom.options[iCtr] = null;
				iCtr = iCtr-1;
			}
		}
	} else {alert('No choices were selected for transfer');}
}

function emptyListBox(oListBox) {
	var iCtr;
	
	for(iCtr=0;iCtr<oListBox.options.length;iCtr++) {
		oListBox.options[iCtr] = null;
	}
}

function selectAllList(oListBox) {
	var iCtr
		
	for(iCtr=0;iCtr<oListBox.options.length;iCtr++) {
		oListBox.options[iCtr].selected = true;
	}
}

function isAllowedStringValue(argString) {
	var ValidStringExp = /\w+/;	
	
	if (argString.match(ValidStringExp)==null){
		return false
   } else {
		return true
   }
}

function trimSpaces(argString) {
	var iCtr = 0;
	var StringA = argString;
	var StringB = argString;
	
	/*comment: remove leading spaces*/
	for(iCtr=0;iCtr<StringA.length;iCtr=0) {
		if (StringA.charAt(0)!=' ') {
			break;
		} else {
			/*comment: check if the string is not all spaces*/
			if (StringA.length>1) {
				StringB = StringA.substring(1,StringA.length);
				StringA = StringB;
			} else {
				StringA = '';
			}
		}
	}
	
	/*comment: remove trailing spaces*/
	for(iCtr=StringA.length-1;iCtr>0;iCtr--) {
		if (StringA.charAt(iCtr)!=' ') {
			break;
		} else {
			StringB = StringA.substring(0,iCtr);
			StringA = StringB;
		}
	}
	
	return StringA;
}

function openWindow(URL,argWidth,argHeight) {
	var NewWindowFeatures = "width=" + argWidth + ",height=" + argHeight + ",left=5,top=5,scrollbars=yes,resizable=no";
	window.open(URL,"oNewWindow",NewWindowFeatures);
}

function getDateDiff(argDate1, argDate2) {
	iDiff = Date.parse(argDate2.toString()) - Date.parse(argDate1.toString());
	
	iInSec = iDiff / 1000;
	iMin = iInSec / 60;
	iHr = iMin / 60;
	iDay = iHr / 24;
	
	getDateDiff = iDay;
}

function isValidEmail(emailStr) {
	
	/* The following variable tells the rest of the function whether or not to verify that the address ends in a two-letter country or well-known
	TLD.  1 means check it, 0 means don't. */
	var checkTLD=1;

	/* The following is the list of known TLDs that an e-mail address must end with. */
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/i;

	/* The following pattern is used to check if the entered e-mail address fits the user@domain format.  It also is used to separate the username
	from the domain. */

	var emailPat=/^(.+)@(.+)$/;

	/* The following string represents the pattern for matching all special characters.  We don't want to allow special characters in the address. 
	These characters include ( ) < > @ , ; : ' \ " . [ ] */

	var specialChars="\\(\\)><@,;:\\'\\\\\\\"\\.\\[\\]";

	/* The following string represents the range of characters allowed in a 
	username or domainname.  It really states which chars aren't allowed.*/

	var validChars="\[^\\s" + specialChars + "\]";

	/* The following pattern applies if the "user" is a quoted string (in which case, there are no rules about which characters are allowed
	and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com	is a legal e-mail address. */

	var quotedUser="(\"[^\"]*\")";

	/* The following pattern applies for domains that are IP addresses, rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	e-mail address. NOTE: The square brackets are required. */

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

	/* The following string represents an atom (basically a series of non-special characters.) */

	var atom=validChars + '+';

	/* The following string represents one word in the typical username.
	For example, in john.doe@somewhere.com, john and doe are words.
	Basically, a word is either an atom or quoted string. */

	var word="(" + atom + "|" + quotedUser + ")";

	// The following pattern describes the structure of the user

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	/* Finally, let's start trying to figure out if the supplied address is valid. */

	/* Begin with the coarse pattern to simply break up user@domain into
	different pieces that are easy to analyze. */

	var matchArray=emailStr.match(emailPat);

	if (matchArray==null) {

	/* Too many/few @'s or something; basically, this address doesn't
	even fit the general mould of a valid e-mail address. */

	//alert("Incorrect e-mail address. (check @ and .'s)");
	return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];

	// Start by checking that only basic ASCII characters are in the strings (0-127).
	for (i=0; i<user.length; i++) {
	if (user.charCodeAt(i)>127) {
	//alert("The User ID contains invalid characters.");
	return false;
	   }
	}
	for (i=0; i<domain.length; i++) {
	if (domain.charCodeAt(i)>127) {
	//alert("The domain name contains invalid characters.");
	return false;
	   }
	}

	// See if "user" is valid 
	if (user.match(userPat)==null) {

	// user is not valid
	//alert("The email username is invalid.");
	return false;
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
	host name) make sure the IP address is valid. */

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {

	// this is an IP address
	for (var i=1;i<=4;i++) {
	if (IPArray[i]>255) {
	//alert("Destination IP address is invalid!");
	return false;
	   }
	}
	return true;
	}

	// Domain is symbolic name.  Check if it's valid.					 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
	//alert("The domain name is invalid.");
	return false;
	   }
	}

	/* domain name seems valid, but now make sure that it ends in a known top-level domain (like com, edu, gov) or a two-letter word,
	representing country (uk, nl), and that there's a hostname preceding the domain or country. */

	if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
		//alert("The address must end in a well-known domain or two letter " + "country.");
		return false;
	}

	// Make sure there's a host name preceding the domain.

	if (len<2) {
		//alert("This address is missing a hostname!");
		return false;
	}

	// If we've gotten this far, everything's valid!
	return true;
}

//****** the following codes below are transferred here from JScriptFunction.js ******//
//**03.12.2007**/

// Created by: Robert Sangil
// Script Used In: Search\SearchEngine.aspx
function getSearchValue(value)
	{
		var s =  document.getElementById('txtSearch');
		s.value = value;
		s.focus();
	}
	
// Created by: Robert Sangil
// Script Used In: Components\header.ascx
	function checkSearch()
	{
		var x =  document.getElementById('txtSearch');
		if (x.value.length == 0)
		{
			alert('Please enter search field...');
			x.focus();
			return false;
		}
	}
// Created by: Robert Sangil
// Script Used In: UserLogIn\LogIn.aspx;Affiliate\AffiliateLogIn.aspx	
	function checkEnter(e, buttonid)
	{
		var bt = document.getElementById(buttonid); 
		a = e.keyCode;
		if (a == 13)
		{
			bt.click();
			return false; 
		}		
	}

// Created by: Robert Sangil
// Script Used In: UserLogIn\LogIn.aspx;Affiliate\AffiliateLogIn.aspx	
	function AgreeTerms()
	{
		var a = document.getElementById('chkSubmit');
		var b = document.getElementById('btnSubmit');
		if (a.checked == true)
		{
			b.disabled = false;
			b.focus();
		}
		else
		{
			b.disabled = true;
		}
	}

// Created by: Robert Sangil
// Script Used In: UserLogIn\LogIn.aspx;Affiliate\AffiliateLogIn.aspx	
	function IsVisibleNewsFormat(value)
	{
		var y = document.getElementById('optNewsY');
		var n = document.getElementById('optNewsN');
		
		var h = document.getElementById('optFormatH');
		var t = document.getElementById('optFormatT');
		var b = document.getElementById('optFormatB');	
		
		if (value == 'true')
		{
			y.checked = true;
			n.checked = false;
						
			h.disabled = false;
			t.disabled = false;
			b.disabled = false;
		}
		else
		{
			y.checked = false;
			n.checked = true;
			
			h.disabled = true;
			t.disabled = true;
			b.disabled = true;
		}
	}
	
	function m_click(value, xLink)
	{
	    var p = document.getElementById("m_PageNo");
		p.value = value;
		var x = document.getElementById("frmSearchResults");
		
		if (xLink!=''){x.action="/"+xLink+"/"+value+"/"}
		
		x.submit();
		return false;
	}	
		
// Created by: Robert Sangil
// Script Used In: terms.aspx;UserLogIn\ManageAccount.aspx,SignUp.aspx;
//				   Affiliate\AffiliateAgreement.aspx,AffiliateManageAccount.aspx,AffiliateRegistration.aspx	
	function sample(obj)
	{
		var x = document.getElementById("cboState");
		if (obj.value == "United States")
		{
			x.disabled = false;
			x.focus();
		}
		else
		{
			x.disabled = true;
			x.selectedIndex = 0;
		}		
	}
	
	// used in user registration page.
	// for validating minimum number of characters required in a field
	function validatePwdLength(sender, args){
		
		var sLength = args.Value;
		if (sLength.length >= 6)
		    {
			  args.IsValid = true;
			  return;
			} 
		else {
			  args.IsValid = false;
			  return;
			}
	}
	
	//created by HeidiSP
	/* Check if an option button is selected */
	function GetSelectedItem() {
		var selected = ""
		len = document.form[0].StarRate.length

		for (i = 0; i <len; i++) {
			if (document.f1.r1[i].checked) {
			selected = document.form[0].StarRate[i].value
			}
		}

		if (selected == "") {
		alert("Select Rating.")
		}
		
	}

/*Counts remaining characters 04/17/07- heidiSP*/
 function countAreaChars(areaName,counter,limit){
   
	if (areaName.value.length>limit)
		areaName.value = areaName.value.substring(0,limit);
	else
		counter.value = limit - areaName.value.length;
}

function AutoResize(){	
	try {
	    var _col1 = document.getElementById('leftside');
	    var _col2 = document.getElementById('mainside');
	    var _col3 = document.getElementById('rightside');
	
	    var _sideBarLeftContainer = document.getElementById('sideBarLeftContainer');
	    var _sideBarRightContainer = document.getElementById('sideBarRightContainer');
		    
	    if ((_col1) && (_col2) && (_col3) )
	    {		       
	        if ((_col1.scrollHeight >= _col3.scrollHeight) && (_col1.scrollHeight >= _col2.scrollHeight))
		    {
		        //alert('1')
		        _col1.style.height=_col1.scrollHeight+15+ "px";
			    _col2.style.height=_col1.scrollHeight+15 + "px";
			    _col3.style.height=_col1.scrollHeight+15 + "px";
		    }
		    else if ((_col2.scrollHeight >= _col1.scrollHeight) && (_col2.scrollHeight >= _col3.scrollHeight))
		    {
		        //alert('2')
		        _col1.style.height=_col2.scrollHeight+15+"px";
			    _col2.style.height=_col2.scrollHeight+15+"px";
			    _col3.style.height=_col2.scrollHeight+15+"px";
		    }
		    else if ((_col3.scrollHeight >= _col1.scrollHeight) && (_col3.scrollHeight >= _col2.scrollHeight))
		    {
		        //alert('3')
		        _col1.style.height=_col3.scrollHeight+15+"px";
			    _col2.style.height=_col3.scrollHeight+15+"px";
			    _col3.style.height=_col3.scrollHeight+15+"px";
		    }
		    else if ((_col1.scrollHeight >= _col2.scrollHeight) && (_col2.scrollHeight >= _col3.scrollHeight) && (_col1.scrollHeight >= _col3.scrollHeight))
		    {
		        //  alert('4')
		        _col1.style.height=_col1.scrollHeight+15+"px";
			    _col2.style.height=_col1.scrollHeight+15+"px";
			    _col3.style.height=_col1.scrollHeight+15+"px";
		    }    		
	    } //if	
	    else {
	        var _col1 = document.getElementById('leftside');
	        var _col2 = document.getElementById('mainside2');
	        var _sideBarLeftContainer = document.getElementById('sideBarLeftContainer');
	        if ((_col1) && (_col2) && (_sideBarLeftContainer))
	        {	
		        if ((_col1.scrollHeight >= _col2.scrollHeight))
		        {
			        _col1.style.height=_col1.scrollHeight+15+ "px";
			        _col2.style.height=_col1.scrollHeight+15+ "px";    			    
		        }
		        else 
		        {
		            _col1.style.height=_col2.scrollHeight+15+ "px";
			        _col2.style.height=_col2.scrollHeight+15+ "px";
		        }    		    
	        }
	    }
	} //try
	catch(e){
	    //alert(e.description)
	}
}

function showHideContent(p_Div,p_Img) {
   var m_oDivPerformers = document.getElementById(p_Div);
   var m_oExpandIcon = document.getElementById(p_Img);
   
   if (location.href.indexOf('/downloads.aspx')>=0){
       if (m_oDivPerformers.style.display == 'none') {
          m_oDivPerformers.style.display = 'block';
          m_oExpandIcon.src = '/images/collapse.png';
          m_oExpandIcon.title = 'Hide Details';
       } else {
          m_oDivPerformers.style.display = 'none';
          m_oExpandIcon.src = '/images/expand.png';
          m_oExpandIcon.title = 'Show Details';
       }
   }
   else {
       if (m_oDivPerformers.style.display == 'none') {
          m_oDivPerformers.style.display = 'block';
          m_oExpandIcon.src = '/images/collapse.gif';
          m_oExpandIcon.title = 'Hide Details';
       } else {
          m_oDivPerformers.style.display = 'none';
          m_oExpandIcon.src = '/images/expand.gif';
          m_oExpandIcon.title = 'Show Details';
       }
   }
}

function toggleImgB(objChk,objImg){
				var objCB	= document.getElementById(objChk);
				var obIB = document.getElementById(objImg);
				if  (objCB.checked == true) 
				{obIB.disabled=false;}
				else{obIB.enabled=false;}
			}			

function passParam(){
    var x =  document.getElementById("email");
		if (x.value.length == 0)
		{
			alert('Please enter email address...');
			x.focus();
			return false;
		}
		x =  document.getElementById("password");
		if (x.value.length == 0)
		{
			alert('Please enter password...');
			x.focus();
			return false;
		}
	var p = document.getElementById("email").value + "|" + document.getElementById("password").value + "|" + document.getElementById("chkMe").value ;
	CallServer (p,'Wait while login in progress...');
    return true;
}

 function ReceiveServerData(args, context){
        alert(context);
        //location.reload(true); 
        //alert(document.getElementById("chkMe").value);
        location.href=location.pathname;
  }
function OnError(message, context){
       alert(message.substring(0,message.length-2));
       var n;
       if (n=message.indexOf("not activated")>0)location.href="/UserLogIn/SendEmailConfirmation.aspx";
       if (n=message.indexOf("set to cookie")>0){
       //alert(location.href=location.pathname + "?ec=true");
       location.href=location.pathname;
       }
  }
 
function 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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage(){ //v3.0
  var i,j=0,x,ximg,a=swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){
        document.MM_sr[j++]=x; 
        var n, s = x.src;
        if (n=s.indexOf("chk1.gif") >0)ximg="/images2/chk2.gif" ;
        else ximg="/images2/chk1.gif";
        if(!x.oSrc) x.oSrc=x.src; x.src=ximg;
        
        if (ximg="/images2/chk2.gif")
            document.getElementById("chkMe").value="false";
        else 
            document.getElementById("chkMe").value="true";
        }
   //alert(x.src);
}     			

function checkAlert(n){
var i    
	i = n.substr(n.length - 11,2);
	var theform;
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
	   theform = document.frmLang;
	}
	else { theform = document.forms["frmLang"]; }
	theform.hdnLang.value = i;		  
	if (location.pathname.indexOf('/selections/series.aspx')>=0){
	   theform.action='/selections.aspx?selectioncat=series'
	}
	if (location.pathname.indexOf('/selections/listeningguides.aspx')>=0){
	   theform.action='/selections.aspx?selectioncat=listeningguides'
	}
	theform.submit();		
}

function SetOpacity(elem, opacityAsInt)
 {
     var opacityAsDecimal = opacityAsInt;
     
     if (opacityAsInt > 100)
         opacityAsInt = opacityAsDecimal = 100; 
     else if (opacityAsInt < 0)
         opacityAsInt = opacityAsDecimal = 0; 
     
    opacityAsDecimal /= 100;
    if (opacityAsInt < 1)
        opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0
    
    elem.style.opacity = (opacityAsDecimal);
    elem.style.filter  = "alpha(opacity=" + opacityAsInt + ")";
}

function HighLightLang(pValue){
   DimBody()
   if (pValue!='EN'){document.getElementById('EN').style.backgroundColor='#000000'}
   document.getElementById(pValue).style.backgroundColor='#F8CE14'
}

function DimBody(){
  if (document.getElementById('divFloat').style.display==''){
       try { SetOpacity(document.getElementById('mainside'),30);} catch(e){}       
       try { SetOpacity(document.getElementById('mainside2'),30);} catch(e){}       
       try { SetOpacity(document.getElementById('leftside'),30);} catch(e){}       
       try { SetOpacity(document.getElementById('rightside'),30);} catch(e){}       
   }
   else {
       try { SetOpacity(document.getElementById('mainside'),100);} catch(e){}       
       try { SetOpacity(document.getElementById('mainside2'),100); } catch(e){}       
       try { SetOpacity(document.getElementById('leftside'),100); } catch(e){}       
       try { SetOpacity(document.getElementById('rightside'),100); } catch(e){}     
   }
   
}

function DWNShowHide(pID){        
    var inputs = document.getElementsByTagName('tr');     
    xExpand=false;

	for(i=0; i<inputs.length;i++)
	{	    	    
        if (inputs[i].id.indexOf(pID+'-')>=0 ){
            if (document.getElementById('img'+pID).src.indexOf('/images/expand.gif')>=0){
		       document.getElementById(inputs[i].id).style.display='';		       
		    }
	    }
		if (inputs[i].id.indexOf(pID+'-')>=0 ){
            if (document.getElementById('img'+pID).src.indexOf('/images/collapse.gif')>=0){
		       document.getElementById(inputs[i].id).style.display='none';
		    }
	    }	   	 
	}
	
	if (document.getElementById('img'+pID).src.indexOf('/images/expand.gif')>=0){
	    document.getElementById('img'+pID).src='/images/collapse.gif';
    }
    else if (document.getElementById('img'+pID).src.indexOf('/images/collapse.gif')>=0){
        document.getElementById('img'+pID).src='/images/expand.gif'
    }
        
    var inputs1 = document.getElementsByTagName('img');     
	for(i=0; i<inputs1.length;i++)
	{
	   try {
	         if (document.getElementById(inputs1[i].id).src.indexOf('/images/collapse.gif')>=0)
	         {xExpand=true;}
	      }
	   catch(e) {}	    	    	    
	}
	if (xExpand==false){
	         document.getElementById('tdAlbum').innerHTML=''
	         document.getElementById('tdTime').innerHTML='Album / Work / Track Title '
	         document.getElementById('tdFormat').innerHTML=''
	}
	else {
	    document.getElementById('tdAlbum').innerHTML='Album / Work / Track Title '
	    document.getElementById('tdTime').innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
	    document.getElementById('tdFormat').innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Format&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'}
}

//ABO:12-19-2008 - Start here -- Added functionality
function showHideContent2(p_Div,p_Img,p_ImgVal1,p_ImgVal2) {
   var m_oDivPerformers = document.getElementById(p_Div);
   var m_oExpandIcon = document.getElementById(p_Img);
  try{
       if (m_oDivPerformers.style.display == 'none') {
          //alert(m_oDivPerformers.id + '--show')
          m_oDivPerformers.style.display = 'block';
          m_oExpandIcon.src = p_ImgVal2 ;
          m_oExpandIcon.title = 'Hide Details';
       } else {
          //alert(m_oDivPerformers.id + '--hide')
          m_oDivPerformers.style.display = 'none';
          m_oExpandIcon.src = p_ImgVal1;
          m_oExpandIcon.title = 'Show Details';
       }
   }catch(e){
   }
}

//ABO:12-19-2008 - Added functionality
function setSession(p_divName, p_divID,opt){
var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; 
var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0; 
var exp = new Date( );
var nowPlusOneDay = exp.getTime( ) +  (24 * 60 * 60 * 1000); //Expires after one day
exp.setTime(nowPlusOneDay);
var d1=(getCookie('div')!=undefined)? getCookie('div'):"";
var s1=(getCookie('sub')!=undefined)? getCookie('sub'):"";

var i=0;
    if (opt) {
     //Main
            i=d1.indexOf(p_divName);
            if (i<0) d1=d1 + "|" + p_divName;
            else d1=d1.replace("|" + p_divName,'');
            setCookie('div',d1, exp);
    }else{ 
    //Sub
            i=s1.indexOf(p_divName);
            if (i<0)s1=s1+ "|" + p_divName;
            else s1=s1.replace("|" + p_divName,'');
            setCookie('sub',s1, exp);
    }
    return true;

}

//ABO:1-5-2009 - Added functionality
function cascadeNode(){
var img1,img2
var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; 
var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0; 
var exp = new Date( );
var nowPlusOneDay = exp.getTime( ) +  (24 * 60 * 60 * 1000); //Expires after one day
exp.setTime(nowPlusOneDay);
       
var d1=(getCookie('div')!=undefined)? getCookie('div'):"";
var s1=(getCookie('sub')!=undefined)? getCookie('sub'):"";
//alert('d1:' + d1 + ' s1:' + s1);
//Sub menu
        
                
        if (s1==""){
            setCookie('sub',s1, exp);
            getCookie('sub')
         }
        img1='/images2/vista_f.gif';
        img2='/images2/vista_f2.gif';
                
        x= s1.split('|');
        for(var i=1;i<x.length;i+=1){
            showHideContent2(x[i],'imgChild' + x[i].substr(4,x[i].length-4),img1,img2) 
        }

         if (d1==""){    
                //sessvars.divParam ="";
                for(n=1; n<2;n+=1){
                  //sessvars.divParam = sessvars.divParam + "|div_" + n;
                  //document.getElementById('div_'+n).style.display='none';
                  d1= d1 + "|div_" + n;                  
                }
                //d1=sessvars.divParam; 
                setCookie('div',d1, exp);
                d1=getCookie('div');
          }        
        img1='/images2/vista_f.gif';
        img2='/images2/vista_f2.gif';
        x= d1.split('|');        
               
        for(var i=1;i<x.length;i+=1){
          showHideContent2(x[i],'imgBullet' + x[i].substr(x[i].length-1,1),img1,img2) 
   };
   
}


//ABO:12-19-2008 - Added Functionality for Session handling
function setCookie(name, value, expires)
{
    EraseCookie(name, value, -1)
    document.cookie = name + "=" + value + "; expires=" + (expires ? expires.toGMTString() : "") + "; path=/";
 }

function EraseCookie(name, value, days){   
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    
    document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name)
{
  //alert('getCookie'+document.cookie)
  var dcookie = document.cookie; 
  var cname = name + "=";
  var clen = dcookie.length;
  var cbegin = 0;
  while (cbegin < clen)
  {
    var vbegin = cbegin + cname.length;
    if (dcookie.substring(cbegin, vbegin) == cname)
    { 
      var vend = dcookie.indexOf (";", vbegin);
      if (vend == -1) vend = clen;
      return dcookie.substring(vbegin, vend);
    }
    cbegin = dcookie.indexOf(" ", cbegin) + 1;
    if(cbegin == 0) break;
  }
  return null;
}

/*
sessvars=function(){
	var x={};
		x.$={
		prefs:{
			memLimit:2000,
			autoFlush:true,
			crossDomain:false,
			includeProtos:false,
			includeFunctions:false
		},
		parent:x,
		clearMem:function(){
			for(var i in this.parent){if(i!="$"){this.parent[i]=undefined}};
			this.flush();
		},
		usedMem:function(){
			x={};
			return Math.round(this.flush(x)/1024);
		},
		usedMemPercent:function(){
			return Math.round(this.usedMem()/this.prefs.memLimit);
		},
		flush:function(x){
			var y,o={},j=this.$$;
			x=x||top;
			for(var i in this.parent){o[i]=this.parent[i]};
			o.$=this.prefs;
			j.includeProtos=this.prefs.includeProtos;
			j.includeFunctions=this.prefs.includeFunctions;
			y=this.$$.make(o);
			if(x!=top){return y.length};
			if(y.length/1024>this.prefs.memLimit){return false}
			x.name=y;
			return true;
		},
		getDomain:function(){
				var l=location.href
				l=l.split("///").join("//");
				l=l.substring(l.indexOf("://")+3).split("/")[0];
				while(l.split(".").length>2){l=l.substring(l.indexOf(".")+1)};
				return l
		},
		debug:function(t){
			var t=t||this,a=arguments.callee;
			if(!document.body){setTimeout(function(){a(t)},200);return};
			t.flush();
			var d=document.getElementById("sessvarsDebugDiv");
			if(!d){d=document.createElement("div");document.body.insertBefore(d,document.body.firstChild)};
			d.id="sessvarsDebugDiv";
			d.innerHTML='<div style="line-height:20px;padding:5px;font-size:11px;font-family:Verdana,Arial,Helvetica;'+
						'z-index:10000;background:#FFFFCC;border: 1px solid #333;margin-bottom:12px">'+
						'<b style="font-family:Trebuchet MS;font-size:20px">sessvars.js - debug info:</b><br/><br/>'+
						'Memory usage: '+t.usedMem()+' Kb ('+t.usedMemPercent()+'%)&nbsp;&nbsp;&nbsp;'+
						'<span style="cursor:pointer"><b>[Clear memory]</b></span><br/>'+
						top.name.split('\n').join('<br/>')+'</div>';
			d.getElementsByTagName('span')[0].onclick=function(){t.clearMem();location.reload()}
		},
		init:function(){
			var o={}, t=this;
			try {o=this.$$.toObject(top.name)} catch(e){o={}};
			this.prefs=o.$||t.prefs;
			if(this.prefs.crossDomain || this.prefs.currentDomain==this.getDomain()){
				for(var i in o){this.parent[i]=o[i]};
			}
			else {
				this.prefs.currentDomain=this.getDomain();
			};
			this.parent.$=t;
			t.flush();
			var f=function(){if(t.prefs.autoFlush){t.flush()}};
			if(window["addEventListener"]){addEventListener("unload",f,false)}
			else if(window["attachEvent"]){window.attachEvent("onunload",f)}
			else {this.prefs.autoFlush=false};
		}
	};
	
	x.$.$$={
		compactOutput:false, 		
		includeProtos:false, 	
		includeFunctions: false,
		detectCirculars:true,
		restoreCirculars:true,
		make:function(arg,restore) {
			this.restore=restore;
			this.mem=[];this.pathMem=[];
			return this.toJsonStringArray(arg).join('');
		},
		toObject:function(x){
			if(!this.cleaner){
				try{this.cleaner=new RegExp('^("(\\\\.|[^"\\\\\\n\\r])*?"|[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t])+?$')}
				catch(a){this.cleaner=/^(true|false|null|\[.*\]|\{.*\}|".*"|\d+|\d+\.\d+)$/}
			};
			if(!this.cleaner.test(x)){return {}};
			eval("this.myObj="+x);
			if(!this.restoreCirculars || !alert){return this.myObj};
			if(this.includeFunctions){
				var x=this.myObj;
				for(var i in x){if(typeof x[i]=="string" && !x[i].indexOf("JSONincludedFunc:")){
					x[i]=x[i].substring(17);
					eval("x[i]="+x[i])
				}}
			};
			this.restoreCode=[];
			this.make(this.myObj,true);
			var r=this.restoreCode.join(";")+";";
			eval('r=r.replace(/\\W([0-9]{1,})(\\W)/g,"[$1]$2").replace(/\\.\\;/g,";")');
			eval(r);
			return this.myObj
		},
		toJsonStringArray:function(arg, out) {
			if(!out){this.path=[]};
			out = out || [];
			var u; // undefined
			switch (typeof arg) {
			case 'object':
				this.lastObj=arg;
				if(this.detectCirculars){
					var m=this.mem; var n=this.pathMem;
					for(var i=0;i<m.length;i++){
						if(arg===m[i]){
							out.push('"JSONcircRef:'+n[i]+'"');return out
						}
					};
					m.push(arg); n.push(this.path.join("."));
				};
				if (arg) {
					if (arg.constructor == Array) {
						out.push('[');
						for (var i = 0; i < arg.length; ++i) {
							this.path.push(i);
							if (i > 0)
								out.push(',\n');
							this.toJsonStringArray(arg[i], out);
							this.path.pop();
						}
						out.push(']');
						return out;
					} else if (typeof arg.toString != 'undefined') {
						out.push('{');
						var first = true;
						for (var i in arg) {
							if(!this.includeProtos && arg[i]===arg.constructor.prototype[i]){continue};
							this.path.push(i);
							var curr = out.length; 
							if (!first)
								out.push(this.compactOutput?',':',\n');
							this.toJsonStringArray(i, out);
							out.push(':');                    
							this.toJsonStringArray(arg[i], out);
							if (out[out.length - 1] == u)
								out.splice(curr, out.length - curr);
							else
								first = false;
							this.path.pop();
						}
						out.push('}');
						return out;
					}
					return out;
				}
				out.push('null');
				return out;
			case 'unknown':
			case 'undefined':
			case 'function':
				if(!this.includeFunctions){out.push(u);return out};
				arg="JSONincludedFunc:"+arg;
				out.push('"');
				var a=['\n','\\n','\r','\\r','"','\\"'];
				arg+=""; for(var i=0;i<6;i+=2){arg=arg.split(a[i]).join(a[i+1])};
				out.push(arg);
				out.push('"');
				return out;
			case 'string':
				if(this.restore && arg.indexOf("JSONcircRef:")==0){
					this.restoreCode.push('this.myObj.'+this.path.join(".")+"="+arg.split("JSONcircRef:").join("this.myObj."));
				};
				out.push('"');
				var a=['\n','\\n','\r','\\r','"','\\"'];
				arg+=""; for(var i=0;i<6;i+=2){arg=arg.split(a[i]).join(a[i+1])};
				out.push(arg);
				out.push('"');
				return out;
			default:
				out.push(String(arg));
				return out;
			}
		}
	};
}
	
*/
	

