	/**
	* Depends on ClientServerBridge.asp to be written before including this file
	*/	
		
	var activeMenu = "undefined";
	var TV = 0;
	
  /**
  * returns the value and text of the smart search combo from frames
  * @return {array}
  */
	function GetSmartFrame()
	{
		var smartSearch = new Array("","");
		var smartText = document.getElementById("SmartText");
  		var smartSelect = document.getElementById("SmartSelect");
  		if (smartSelect != null){
  			index = smartSelect.selectedIndex;
			smartSearch[0] = smartSelect.options[index].value;
		}
		if (smartText != null){
			smartSearch[1] = smartText.value;
			smartSearch[1] = smartSearch[1].replace(/ /g, "%20");
		}
		return smartSearch;
	}
	
	/**
	 * submits the smart search form
	 * @return {void}
	 */
  	function DoSearchFrame() {
  		var form = document.thisForm;
  		var smartSearch = new Array("","");
 		
		smartSearch = GetSmartFrame();
		action = "SmartSearch.asp?Find=" + smartSearch[0] + "&Sort=Date+Added";
		if (smartSearch[1] != ""){
			action += "&Fields=";
			if (smartSearch[0].toLowerCase().indexOf("star") > -1){//oct 30.2007 Geanina: if star then remove narrow
				action += "Star";
			}else{
				action += "Phrase";
			}
			action += "|&Values=" + smartSearch[1] + "|";
		}
  	  			
		form.action = action;
		form.submit();
	}
	

	/**
	 * opens the gallery in a pop up page
	 * @param {string} starEnc the star name
	 * @param {string} typeEnc the type
	 * @param {string} movie the movie code
	 * @param {string} photo
	 * @return {void}
	 */
	function OpenGallery(starEnc, typeEnc, movie, photo) {
		if (!window.open("GalleryWind.asp?Star=" + starEnc + "&Type=" + typeEnc + "&Photo=" + photo + "&Movie=" + movie, "Gallery", "width=750,height=680,scrollbars=no,toolbar=no,directories=no,status=no,resizable=no"))
			PopupBlocked();
	}
	
	/**
	 * sends back the query params for voting a star
	 * @param {string} star
	 * @return {void}
	 */
	function StarVote(star) {
		Sureflix.SendBack("What=StarVote&Star=" + URLencode(star) + "&Member=" + jsMember);
		alert(jsYourVote);
	}
	
	/**
	 * opens the rating scene page in a pop up window
	 * @param {string} movie
	 * @param {string} scene
	 * @return {void}
	 */
	function RateScene(movie, scene) {
		if (!window.open("Rate.asp?Movie=" + movie + "&Scene=" + scene, "Rate", "width=536,height=230,scrollbars=no,toolbar=no,directories=no,status=no,resizable=no"))
			PopupBlocked();
	}
	
	/**
	 * plays sample video
	 * @param {string} sample Can be an empty string or a movie code
	 * @return {void}
	 */
	function PlaySample(paramSample) {
		var sessionSample = Sureflix.getMovieSample();

		if (sessionSample == "Sample" && (!paramSample))
		{
			if (!window.open('PreviewPlayer.asp',null,"width=700,height=660,scrollbars=no,toolbar=no,directories=no,resizable=yes,status=no")) {
				PopupBlocked();
				return;
			}
			return;
		}
		// if the parameter is not empty use it, otherwise use the session variable
		var sample = (paramSample || sessionSample);
		
		PlayScene(sample, -2, 1, undefined, false);
	}
	
	/**
	 * opens About page in a pop up window
	 * @return {void}
	 */
	function PlayAbout() {
		if (window.setResizable)
			resizable = "yes"
		else
			resizable = "no";
		if (!window.open("About.asp", "Player", "width=656,height=600,scrollbars=yes,toolbar=no,directories=no,status=no,resizable="+resizable))
			PopupBlocked();
	}

	function Wizard(p_set_id,p_section_id) {
		height = window.screen.availHeight-80;
		left = Math.round((window.screen.availWidth-656)/2);		
		if (!window.open("Wizard.asp?frmSet_Id="+p_set_id+"&frmSection_Id=" + p_section_id + "&frmWidth=" + 620, "Wizard", "width=656,height=" + height + ",left=" + left + ",top=20,directories=no,scrollbars=yes,resizable=yes,location=no,toolbar=yes"))
			PopupBlocked();
	}
	
	/**
	 * opens the FAQ page in a pop up window
	 * @param {string} faq
	 * @return {void}
	 */
	function FAQ(faq) {
		height = window.screen.availHeight-80;
		left = Math.round((window.screen.availWidth-656)/2);
		
		if (!window.open("FAQ.asp?faq=" + faq, "Wizard", "width=656,height=" + height + ",left=" + left + ",top=20,directories=no,scrollbars=yes,resizable=yes,location=no,toolbar=yes"))
			PopupBlocked();
	}
	
	function 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=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 PreloadImagegen() { //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=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];
			}
		}
	}	

	/**
	 * Swaps out the source of an image; used mostly for rollover effects.
	 * @param {String} id The id of the image element
	 * @param {String} name The name of an image object
	 * @example	&lt;IMG src="SureFlixPowerU.gif" name="NSureFlixPower" 
	 * 	onmouseout="di('NSureFlixPower','ISureFlixPowerU');" 
	 * 	onmouseover="di('NSureFlixPower','ISureFlixPowerO');" /&gt;
	 *  //<A href=http://dev.sureflix.com/work/ClientSamples/di.htm target=_blank>test code</A>
	 *  @return {void}
	 */
	function di(id,name){
		if ((id != activeMenu) && (document.images)) {
			document.images[id].src=eval(name+".src");
		}
	}
	
	/**
	 * Swaps out the source of an image; used mostly for rollover effects.
	 * @param {String} id The id of the image element
	 * @param {String} name The name of an image object
	 * @return {void}
	 */
	function dx(id,name){
		if ((id != activeMenu) && (document.images)) {
			document.images[id].src= name;
		}
	}	
	
	/**
	 * Swaps out the source of an image; used mostly for rollover effects.
	 * @param {String} id The id of the image element
	 * @param {String} name The name of an image object
	 * @return {void}
	 */
	function dr(id,name){
		if ((id != activeMenu) && (document.images)) {
			document.images[id].src= name;
		}
	}	
	
	/**
	 * Swaps out the source of an image; used mostly for rollover effects.
	 * @param {String} id The id of the image element
	 * @param {String} name The name of an image object
	 * @return {void}
	 */
	function dg(id,name){
		if ((id != activeMenu) && (document.images)) {
			document.images[id].src= name;
		}
	}	
	
	/**
	 * Swaps out the source of an image; used mostly for rollover effects.
	 * @param {String} id The id of the image element
	 * @param {String} name The name of an image object
	 * @return {void}
	 */
	function dm(id,name){
		if ((id != activeMenu) && (document.images)) {
			document.images[id].src= name;
		}
	}	
	
	function window_onload() {
		if ( document.thisForm._method ) {
			if (document.thisForm._method.value==" " | document.thisForm._method.value=="  ") {
				document.thisForm._method.value="";
			}
		}
		
		if (window.frame_onload) frame_onload();
		if (window.page_onload) page_onload();
	}	
	
	function GetVid(theVid) {
		vid = FIND(theVid);
		if (vid)
			return(vid)
		else if (document.embeds)
			return(document.embeds[theVid])
		else
			return(false);
	}	

	function get_id4(id) {
		if (document.all) {
			return document.all[id];
		}
		else if (document.layers) {
			document.layers[id].style=document.layers[id];
			return document.layers[id];
		}
	}
	
	function frame_onload() {
		form = document.thisForm;
		
		// 06/09/06 Amy: changed to submit form to smartsearch for maleflixxx only
		// and to submit to search for all other sites
		var sitesEnabled = 'BlueDoorFlixxx.tv|GayTwinksLive.com|maleflixxx.tv|MattSterling.tv|pigsexguys.com|RADVideo.tv|Sex4hotmenTest.tv|hothouseondemand.com';
		sitesEnabled = sitesEnabled.toUpperCase();		
		var smartText = document.getElementById("SmartText");
		if (sitesEnabled.indexOf(jsSiteUpperCase) != -1){
			if (smartText != null) 
				smartText.onkeydown = SmartSearchKeyDown;
		}else{
			if (smartText != null) 
				smartText.onkeydown = QuickFindKeyDown;
		}
		if (form.HunkEmail) form.HunkEmail.onkeydown = RegisterKeyDown;
	}	
	
	function QuickFindKeyDown(keyStroke) {
		key = (isNav ? keyStroke.which : window.event.keyCode);
		if (key == 13) {
			QuickFind();
			return(false);
		}
		else {
			return(true);
		}
	}

	function SmartSearchKeyDown(keyStroke) {
		key = (isNav ? keyStroke.which : window.event.keyCode);
		if (key == 13) {
			DoSearchFrame();
			return(false);
		}
		else {
			return(true);
		}
	}

  	function QuickFind() {
  		var form = document.thisForm;
  		var smartSearch = new Array("","");
  		var index = 0;

  		smartSearch = GetSmartFrame();  
  		
		if (smartSearch != null && smartSearch.length == 2){
		    form.action = "SmartSearch.asp?Page=1&Find=Movies&Fields=" + smartSearch[0] + "&Values=" + smartSearch[1];
			form.submit();
		}
	}
	
	function RegisterKeyDown(keyStroke) {
		key = (isNav ? keyStroke.which : window.event.keyCode);
		if (key == 13) {
			Register();
			return(false);
		}
		else {
			return(true);
		}
	}
	
	//Declare this variable here to track clean up of the hunk email box
	//needs to be a global share. False by default
	var hunkInputCleared = false;
	function RegisterFocus() {
		emailbox = document.thisForm.HunkEmail;
		if (!hunkInputCleared) {
			emailbox.value = "";
			hunkInputCleared = true;
		}
		return(true);
	}
		
	function Register() {
		
		email = document.thisForm.HunkEmail.value;
		
		if ((email == "") || (email.indexOf(" ") != -1) || (email.indexOf("@") == -1) || (email.indexOf(".") == -1)) {
			alert(jsErrEmailEnter);
			return;
		}
		
		if (!window.open("register.asp?Email=" + URLencode(email),"popup","width=450,height=200,scrollbars=no,toolbar=no,directories=no,resizable=no,status=no"))
			PopupBlocked();
	}

	var isNav = (navigator.appName.indexOf("Netscape") != -1);
	var isMac = (navigator.platform.indexOf("Mac") != -1);

	var browserOK = DetectBrowser();
		
	function DetectBrowser(){
	
		var detect = navigator.userAgent.toLowerCase();
		var browser,version,total,thestring;

		var browser,version,total,thestring;

		if (checkIt('konqueror'))
		{
			browser = "Konqueror";
		}
		else if (checkIt('safari')) browser = "Safari";
		else if (checkIt('omniweb')) browser = "OmniWeb";
		else if (checkIt('opera')) browser = "Opera";
		else if (checkIt('webtv')) browser = "WebTV";
		else if (checkIt('icab')) browser = "iCab";
		else if (checkIt('aol')) browser = "AOL";
		else if (checkIt('firefox')) browser = "Firefox";
		else if (checkIt('msie')) browser = "Internet Explorer";
		else if (!checkIt('compatible'))
		{
			browser = "Netscape Navigator"
			version = detect.charAt(8);
		}
		else browser = "An unknown browser";
		
		if (!version) version = detect.charAt(place + thestring.length);

		function checkIt(string)
		{
			place = detect.indexOf(string) + 1;
			thestring = string;
			return (place > 0);
		}

		var siteFeatures;
		
 		switch (browser)
		{	
			case "Internet Explorer":
				if (version <= 5){
					//03-24-2005 Nestor: Detect if version 5.2 for MAC
					if (isMac)
					{
						MacVersion = parseInt(detect.charAt(place + thestring.length+2));
						if (MacVersion >= 2) siteFeatures = "basic";
					}
					else
					{
						siteFeatures = "none";
					}
				}
				if ((version > 5) && (version < 6)){
					siteFeatures = "basic";
				}
				if (version >= 6){
					siteFeatures = "full";
				}
				break;
			case "Netscape Navigator":
				if (version <= 4.7){
					siteFeatures = "none";
				}
				if ((version > 4.7) && (version < 7)){
					siteFeatures = "basic";
				}
				if (version >= 7){
					siteFeatures = "full";
				}
				break;
			case "AOL":
				if (version <= 6){
					siteFeatures = "none";
				}
				if ((version > 6) && (version < 8)){
					siteFeatures = "basic";
				}
				if (version >= 8){
					siteFeatures = "full";
				}
				break;
			case "Firefox":
				// 07/17/2006 Amy:
				//siteFeatures = "basic";
				siteFeatures = "full";
				break;
			default:
				siteFeatures = "full";
				break;
		}

		return siteFeatures;
	} 
	
	
