/* 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*/
	/*Modified to implement a counter limit as well as an actual character limit
	    
        Buddy James 09/24/2010

         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 countAreaChars(areaName,counter,countLimit,characterLimit){

    if (areaName.value.length > characterLimit)
        areaName.value = areaName.value.substring(0, characterLimit);
    else
        if (areaName.value.length <= countLimit) {
            counter.value = countLimit - 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(){
    var inputs = document.getElementsByTagName('input');
	for(i=0; i<inputs.length;i++)
	{	  
	    if (inputs[i].id.indexOf('_txtE')>=0 ){            	    
	       try {
	          document.getElementById(inputs[i].id).focus();
	       }
	       catch(e){}
	    }       
	}
  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'):"";
                
        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;
}

function renderPlayerPreview(p_PreviewIndex, p_XML) {    
	var flashvars = {
				startAuto:'false'
                        , trackList:p_XML
			};
			var params = {
				AllowScriptAccess:'always'
			      , Quality:'high'
			};
			var attributes = {
				id:'colplayer'
				, wmode:'Transparent'
			};
			swfobject2.embedSWF("/catalogue/colPreviewPlayer.swf", "colplayer", "17", "17", "9", false, flashvars, params, attributes);
			//swfobject2.embedSWF("/catalogue/colPreviewPlayer.swf", "colplayer1", "18", "18", "9", false, flashvars, params, attributes);			
	
}

function m_click2(value, xLink){
	    var p = document.getElementById("m_PageNo");
		p.value = value;
		var x = document.getElementById("frmSearchResults");
		document.getElementById("m_PageNo").value=value;
		//alert(document.getElementById("m_PageNo").value);
		x.submit();
		return false;
	}	
	
	
// Created by: ABO 10/15/2009
// Script Used In: UserLogIn\ManageAccount.aspx
	function sample2(obj,strObj)
	{
		var x = document.getElementById(strObj);
		if ((obj.value == "United States") || (obj.value == "Canada") )
		{
			x.disabled = false;
			x.focus();
		}
		else
		{
			x.disabled = true;
			x.selectedIndex = 0;
		}
		
	}
	
	// Set Attributes if Same address for Billing is checked
var paramBill, paramShip
paramShip='txtAddessShipping1;txtAddessShipping2;txtCityShipping;txtZipCodeShipping;cboCountryShipping;drpShipState;txtFirstnameShipping;txtLastnameShipping;txtPhoneShipping'
paramBill='txtAddessBilling1;txtAddessBilling2;txtCityBilling;txtZipCodeBilling;cboCountryBilling;drpBillState;txtFirstname;txtLastname;txtPhoneBilling'

function SetShipping (bool)
{
 if (bool)
      {
                    copyValues(paramBill,paramShip);
  } else  {
               
               //setReadOnly(1,false)  
               var obj ;
                    obj= document.getElementById('cboCountryShipping');
                    //sample2(obj,'cboStateShipping');
          }
    }

 function IsAllWithNoValues(param) {
        var arrParam = new Array()
        var  i
        arrParam = param.split(";")
                for (i=0;i< arrParam.length;i++) {
                          if (document.getElementById(arrParam[i]).value==''){
                                    //alert(document.getElementById(arrParam[i]).value);
                                    document.getElementById('chkSameAddess').checked = false;
                                    document.getElementById(arrParam[i]).focus();
                                    return true;
                            } 
                }
                if (document.getElementById('cboCountryShipping').value=="Others")  {
               document.getElementById('cboCountryShipping').focus(); 
                return true;
               } 
                if ((document.getElementById('cboCountryShipping').value=="United States") && (document.getElementById('cboStateShipping').value.indexOf("Choose")>=0)) {
              document.getElementById('cboStateShipping').focus();
              return true;
              }
               return false 
}
  
   
function setReadOnly(p, opt){
var param = (p==1)? paramShip: paramBill;
//var lnk =  (p==1)? 'lnkShipEdit':'lnkBillEdit';
        var arrParam = new Array()
        var  i
        arrParam = param.split(";")
       if (opt){
                for (i=0;i< arrParam.length;i++) {
                   //alert(arrParam[i]);
                       if (arrParam[i].indexOf("cbo")!=-1)
                                 document.getElementById(arrParam[i]).setAttribute('disabled',true);
                     else
                            document.getElementById(arrParam[i]).setAttribute('disabled',true); 
              } 
       }
       else
        {
                for (i=0;i< arrParam.length;i++) {
                       if (arrParam[i].indexOf("cbo")!=-1)
                                  document.getElementById(arrParam[i]).removeAttribute('disabled','disabled');
                     else
                            document.getElementById(arrParam[i]).removeAttribute('disabled','disabled');
              }
             document.getElementById(arrParam[0]).focus();
        } 
            

 }

function copyValues(objBill,objShip){
var arrBill= new Array()
arrBill= objBill.split(";")
var arrShip = new Array()
arrShip =objShip.split(";")
var i,s
        for (i=0;i< arrBill.length;i++) 
       { 
               document.getElementById(arrShip[i]).value=document.getElementById(arrBill[i]).value;
        }
}

function getStateValuesManage(pFrom, pTo, cCode,cboVal){
	   	var iCtr=0;
		var pCtry='--';
		if (cCode=='United States')pCtry='US';
		if (cCode=='Canada')pCtry='CA';
		//alert(pCtry);
		if(pCtry=='--') document.getElementById(pTo).disabled=true;
		else document.getElementById(pTo).disabled=false;

	
		try {
		for(iCtr=0;iCtr<document.getElementById(pTo).options.length;++iCtr) {
		    document.getElementById(pTo).remove(iCtr);
			iCtr = iCtr-1;
	    }} catch(e){}
		
		try {
			for(iCtr=0;iCtr<document.getElementById(pFrom).options.length;++iCtr) {
			    if (document.getElementById(pFrom).options[iCtr].value.indexOf(pCtry+'-')>=0){
				    document.getElementById(pTo).options[document.getElementById(pTo).options.length]=new Option(document.getElementById(pFrom).options[iCtr].innerHTML, document.getElementById(pFrom).options[iCtr].value);			   
				}						
			}
		} catch(e){}
		
for(iCtr=0;iCtr<document.getElementById(pTo).options.length;++iCtr) {
		       try {
			      if ((pTo.indexOf('Bill')>0) && (document.getElementById(pTo).options[iCtr].value.indexOf('-'+cboVal )>=0)){			      
				     document.getElementById(pTo).options[iCtr].selected=true;
			      }
			   } catch(e){}
			   try {
			      if ((pTo.indexOf('Ship')>0) && (document.getElementById(pTo).options[iCtr].value.indexOf('-'+cboVal )>=0)){
				     document.getElementById(pTo).options[iCtr].selected=true;
				     //alert(iCtr);
			      }
			      //else alert(cboVal);
               } catch(e){}				  
		}
}

