//////////////////////////////////////////////////////
// global.js
/////////////////////////////////////////////////////

//***************************
function _hbxStrip(a){
//***************************
  a = a.split("|").join("");
  a = a.split("&").join("");
  a = a.split("'").join("");
  a = a.split("#").join("");
  a = a.split("$").join("");
  a = a.split("%").join("");
  a = a.split("^").join("");
  a = a.split("*").join("");
  a = a.split(":").join("");
  a = a.split("!").join("");
  a = a.split("<").join("");
  a = a.split(">").join("");
  a = a.split("~").join("");
  a = a.split(" ").join("+");

  return a;
}

//***************************
function get_cookie(Name) {
//***************************
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      end = document.cookie.indexOf(";", offset);
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;

}
//***************************
function loadornot(){
//***************************
if (get_cookie('popunder')==''){
loadpopunder()
document.cookie="popunder=yes"
}
}
//***************************
function loadpopunder(){
//***************************
win2=window.open('http://www.sonypictures.com/movies/showtimes/popunder_redirect/','tickets')
win2.blur()
window.focus()
}


///////////////////////////////////////////////////////////////

//*********************
function showPlayer(pURL) {
//*********************
    displayWindow(pURL,"Player",620,435,"directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
    return false;
}

//*********************
function showPlayerPopup(pURL) {
//*********************
  if (document.all) 
    playerHref = document.anchors(pURL).href;
  else
    playerHref = document.anchors[pURL].href;
    
  openWidth = 481;
  openHeight = 492;

  openLeft = (screen.width-openWidth)/2;
  openTop = (screen.height-openHeight)/2;

  var strFeatures = "height="+openHeight+",width="+openWidth+",left="+openLeft+",top="+openTop
    +",directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0";

  open(playerHref,'SelectAsset', strFeatures);
}

//*********************
function showPhoto(pURL){
//*********************
  displayWindow(pURL,"Photo",400,470);
  return false;
}


//*********************
function displayWindow(theURL,winName,width,height,features) { //v3.1
//*********************
  var window_width = width;
  var window_height = height;
  var newfeatures= features;
  var window_top = (screen.height-window_height)/2;
  var window_left = (screen.width-window_width)/2;
  newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ','+ newfeatures + '');
  newWindow.focus();
}

//*********************
function MM_openBrWindow(theURL,winName,features) { //v2.0
//*********************
  window.open(theURL,winName,features);
}

//*********************
function mm_openbrwindow(theURL,winName,features) { //v2.0
//*********************
  window.open(theURL,winName,features);
}
 		  
//***************************************************
function GetCookieValue(offset) {
//***************************************************
	var endstr = document.cookie.indexOf (";", offset);
	
	if (endstr == -1) {
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}

//***************************************************
function GetCookie(name) {
//***************************************************
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	
	while (i < clen) {
		var j = i + alen;
		
		if (document.cookie.substring(i, j) == arg) {
			return GetCookieValue(j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		
		if (i == 0) { break; }
	}
	return null;
}

//***************************************************
function SetCookie(name,value,expires,path,domain,secure) {
//***************************************************
	document.cookie = name + "=" + escape (value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}

//***************************************************
function DeleteCookie(name,path,domain) {
//***************************************************
	if (GetCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

//***************************************************
function FixCookieDate(date) {
//***************************************************
	var base = new Date(0);
	var skew = base.getTime();
	
	if (skew > 0) { date.setTime(date.getTime() - skew); }
}

//***************************************************
function popFull(url,name){
//***************************************************
var w = 480, h = 340;

if (document.all || document.layers) {
   w = screen.availWidth;
   h = screen.availHeight;
}else{
	w = screen.width;
	h = screen.height;
}

var url;
var popW;
var popH;

window.open(url,name,'width=' + w + ',height=' + h + ',top=0,left=0');
}

//***************************************************
IE = navigator.appName=="Microsoft Internet Explorer";
NS = navigator.appName=="Netscape";
browsertype = parseInt(navigator.appVersion);
var newWin=null;
function poppit(theUrl,theName,width,height,scroll)
//***************************************************
{
	var scrollVar = "no";
	if (scroll == "1" ) {
		scrollVar = "yes";
	} else {
		scrollVar = "no";
	}
	var _params = "width=" + width + ",height=" + height + ",resizable=no,status=no,scrollbars="+scrollVar;
	
	// CENTER ON BROWSERS WHICH SUPPORT JSCRIPT 1.2
	if (browsertype >= 4) {
		_left = ( (screen.width-width) >>1 );
		_top = ( (screen.height-height) >>1 );
	} else {
		_left = ( (800-width) >>1 );
		_top = ( (600-height) >>1 );
	}
	
	if (IE) _params += ",top=" + _top + ",left=" + _left;
	else if (NS) _params += ",screenX=" + _left + ",screenY=" + _top;
	
	newWin = window.open(theUrl, theName, _params);
	if ( newWin!=null && !(IE && browsertype<5) )
		newWin.focus(); // MSIE4 DOESN'T FOCUS WINDOWS
}

//***************************************************
function clearText(thefield){
//***************************************************
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 

//*********************
function embedFlash(fileName, width, height, bgcolor, quality, align, salign, wmode, scale, play, flashvars, menu, base, devicefont, loop) {	
//*********************
	var text;
	text = "";
	
	if ((null == bgcolor)||(bgcolor == "")) {
		parambgcolor = "";
		embedbgcolor = "";
	} else {
		parambgcolor = "<param value=\"" + bgcolor + "\" name=\"bgcolor\" />";
		embedbgcolor = " bgcolor=\"" + bgcolor + "\"";
	}
	
	if ((null == quality)||(quality == "")) {
		quality = "high";
	}
	
	if ((null == align)||(align == "")) {
		align = "middle";
	}
	
	if ((null == salign)||(salign == "")) {
		paramsalign = "";
		embedsalign = "";
	} else {
		paramsalign = "<param value=\"" + salign + "\" name=\"salign\" />";
		embedsalign = " salign=\"" + salign + "\"";
	}
	
	if ((null == wmode)||(wmode == "")) {
		paramwmode = "";
		embedwmode = "";
	} else {
		paramwmode = "<param value=\"" + wmode + "\" name=\"wmode\" />";
		embedwmode = " wmode=\"" + wmode + "\"";
	}
	
	if ((null == scale)||(scale == "")) {
		paramscale = "";
		embedscale = "";
	} else {
		paramscale = "<param value=\"" + scale + "\" name=\"scale\" />";
		embedscale = " scale=\"" + scale + "\"";
	}
	
	if ((null == play)||(play == "")) {
		paramplay = "";
		embedplay = "";
	} else {
		paramplay = "<param value=\"" + play + "\" name=\"play\" />";
		embedplay = " play=\"" + play + "\"";
	}
	
	if ((null == flashvars)||(flashvars == "")) {
		paramflashvars = "";
		embedflashvars = "";
	} else {
		paramflashvars = "<param value=\"" + flashvars + "\" name=\"flashvars\" />";
		embedflashvars = " flashvars=\"" + flashvars + "\"";
	}
	
	if ((null == menu)||(menu == "")) {
		parammenu = "";
		embedmenu = "";
	} else {
		parammenu = "<param value=\"" + menu + "\" name=\"menu\" />";
		embedmenu = " menu=\"" + menu + "\"";
	}
	
	if ((null == base)||(base == "")) {
		parambase = "";
		embedbase = "";
	} else {
		parambase = "<param value=\"" + base + "\" name=\"base\" />";
		embedbase = " base=\"" + base + "\"";
	}
	
	if ((null == devicefont)||(devicefont == "")) {
		paramdevicefont = "";
		embeddevicefont = "";
	} else {
		paramdevicefont = "<param value=\"" + devicefont + "\" name=\"devicefont\" />";
		embeddevicefont = " devicefont=\"" + devicefont + "\"";
	}
	
	if ((null == loop)||(loop == "")) {
		paramloop = "";
		embedloop = "";
	} else {
		paramloop = "<param value=\"" + loop + "\" name=\"loop\" />";
		embedloop = " loop=\"" + loop + "\"";
	}

 
	text +="<object align=\"" + align + "\" id=\"main\" height=\"" + height + "\" width=\"" + width + "\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\">";
	text +="<param value=\"" + fileName + "\" name=\"movie\" />";
	text +="<param value=\"" + quality + "\" name=\"quality\" />";
	text += parambgcolor + paramsalign + paramwmode + paramscale + paramplay + paramflashvars + parammenu + parambase + paramdevicefont + paramloop;
	text += "<embed pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" align=\"" + align + "\" name=\"movie\" quality=\"" + quality + "\" height=\"" + height + "\" width=\"" + width + "\" src=\"" + fileName + "\"" + embedbgcolor + embedsalign + embedwmode + embedscale + embedplay + embedflashvars + embedmenu + embedbase + embeddevicefont + embedloop +  "></embed></object>";
	document.write(text);
}
