//////////////////////////////////////////////////////
// global.js
/////////////////////////////////////////////////////

//***************************
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",481,479);
    return false;
}

//*********************
function showPlayerPopup(pURL) {
//*********************
  if (document.all) 
    playerHref = document.anchors(pURL).href;
  else
    playerHref = document.anchors[pURL].href;
    
  openWidth = 481;
  openHeight = 479;

  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 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');
}