﻿// GLOBAL VARS
var browser			= navigator.appName;
var browserVer		= navigator.appVersion;
var flashVersion 	= deconcept.SWFObjectUtil.getPlayerVersion();
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	/*
	if(pageWidth==windowWidth && pageHeight>windowHeight && browser=="Netscape"){
		pageWidth -= 20;
	}
	*/
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}
function isIE6(){
	if(browser.indexOf("Internet Explorer")>-1){
		var thisVer = browserVer.split("MSIE")[1];
		if(thisVer.indexOf("6.0;")>-1){
			return true;
		}
	}
	return false;
}
function findPos(obj) {
	//alert("--")
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	
	return [curleft,curtop];
}
var currentPlay=-1;
function show_FLV_movie(idx, movieCode,loopPos){
	if(loopPos!=currentPlay){
		if(currentPlay!=-1){
			$("player_"+currentPlay+"").innerHTML = '';
			$("player_wrap_"+currentPlay+"").style.display = 'none';
			if(isIE6()){
				$("show_movie_btn_"+currentPlay+"").style.bottom = 18 + 'px';
			}else{
				$("show_movie_btn_"+currentPlay+"").style.bottom = 3 + 'px';
			}
			$("show_movie_btn_"+loopPos+"").className = 'showMovieNow';
		}
		var d = new Date();
		$("player_wrap_"+loopPos+"").style.display = 'inline';
		
		if(isIE6()){
			$("show_movie_btn_"+loopPos+"").style.bottom = 561 + 'px';
		}else{
			$("show_movie_btn_"+loopPos+"").style.bottom = 543 + 'px';
		}
		$("show_movie_btn_"+loopPos+"").className = 'now_playing_arrow';
		
		var movie_player = new SWFObject('JS/flvplayer_jewsex.swf','mpl','640','520','8', '#000000');
		movie_player.addParam("allowfullscreen","true");
		movie_player.addVariable("autostart","true");
		movie_player.addVariable('width','640');
		movie_player.addVariable('height','520');
		movie_player.addVariable("idx", idx);
		movie_player.addVariable("movieCode", movieCode);
		movie_player.write("player_"+loopPos);
		
		var y_pos = (Position.cumulativeOffset( $("player_wrap_"+loopPos) )[1]);
		window.scrollTo(0, y_pos);
		currentPlay=loopPos;
	}else{
		$("player_"+currentPlay+"").innerHTML = '';
		$("player_wrap_"+currentPlay+"").style.display = 'none';
		if(isIE6()){
				$("show_movie_btn_"+currentPlay+"").style.bottom = 18 + 'px';
			}else{
				$("show_movie_btn_"+currentPlay+"").style.bottom = 3 + 'px';
			}
		$("show_movie_btn_"+loopPos+"").className = 'showMovieNow';
		currentPlay = -1;
	}
}
function setPlayer(idx, loopPos){
	var movie_player = new SWFObject('JS/flvplayer.swf','mpl','640','520','8');
	movie_player.addParam("allowfullscreen","true");
	movie_player.addVariable("autostart","true");
	movie_player.addVariable('width','640');
	movie_player.addVariable('height','520');
	movie_player.addVariable("idx",idx);
	movie_player.write("player_"+loopPos);
	var y_pos = (Position.cumulativeOffset( $("player_wrap_"+loopPos) )[1]);

}
function set_iframe_size(){
	var headerHeight = document.getElementById('header').offsetHeight;
	document.getElementById('main_iframe').style.height = (getPageSize()[1] - headerHeight - 5) + "px";
}
function subscribers_popup(acn){
	switch(acn){
		case "hide": $('subscribers_popup').style.display = 'none';break;
		case "show": $('subscribers_popup').style.display = 'inline';break;
	}
}
function subscriber_url(){
	var thisURL = window.location.toString().toLowerCase();
	//$('testZone').innerHTML += thisURL + "<br>";
	if(thisURL.indexOf("default.asp")>-1)
		thisURL = thisURL.replace("default.asp", 	"payment.asp");
	
	if(thisURL.indexOf("movielist.asp")>-1)
		thisURL = thisURL.replace("movielist.asp", 	"payment.asp");	
		
	if(thisURL.indexOf("ivrlist.asp")>-1)
		thisURL = thisURL.replace("ivrlist.asp", 	"payment.asp");
	
	if(thisURL.indexOf("login.asp")>-1)
		thisURL = thisURL.replace("login.asp", 		"payment.asp");
		
	if(thisURL.indexOf("idmovie=")>-1){
		new_url = thisURL.substring(0, thisURL.indexOf("idmovie=")+8);
		if(new_url.indexOf("&")>-1){
			temp_url = thisURL.substring(new_url.length, thisURL.length);
			temp_url = temp_url.substring(temp_url.indexOf("&"), temp_url.length);
			thisURL = new_url + "-2" + temp_url;
		}
	}else{
		if(thisURL.indexOf("?")>-1){
			thisURL += "&IDMovie=-2";
		}else{
			thisURL += "?IDMovie=-2";
		}
	}
	location.href = thisURL;
	//$('testZone').innerHTML += thisURL + "<br>";
}



