
/*
Name: navigateCategory()
Author: Shane Oatman
Date: July 7, 2000
*/

function navigateCategory(strFile){
	
	if(strFile.toUpperCase() != "CATEGORY")
		location.href = strFile;
		
	return;
	
	
}

/*
Name ViewTrailer (trailerID, mid)
Author: Ken Wong
Date: August 21, 2001
*/

function ViewTrailer (tid, mid)
{
	var strTrailerID;
	var strMid;
	strTrailerID = escape(tid);
	strMid = escape("mid");
    
    // scroll to top of page if necessary
    location.href = "#";
    
    // Now trailers are viewed in the Screening Room instead of external window
    linkToScreeningRoom( 'trailer', "?tid=" + tid + "&mid=" + mid );
}


// removed duplicate code - same exact code as showScreeningRoom() function - use that instead,
// this function still remains as a 'wrapper' function
function linkToScreeningRoom(promoOrTrailer, trailerInfo) {	
    showScreeningRoom(promoOrTrailer, trailerInfo);
}


// Function : trimString()
// Purpose  : String trimming
// Returns  : trimmed string
function trimString(sToTrim){
	var iStart, iEnd;
	var sTrimmed;
	var cChar;
	var bLoop;

	iEnd = sToTrim.length - 1;
	iStart = 0;
	bLoop = true;

	cChar = sToTrim.charAt(iStart);
	while ((iStart < iEnd) && ((cChar == "\n") || (cChar == "\r") ||
                                (cChar == "\t") || (cChar == " "))){
		iStart ++;
		cChar = sToTrim.charAt(iStart);
	}

	cChar = sToTrim.charAt(iEnd);
	while ((iEnd >= 0) && ((cChar == "\n") || (cChar == "\r") ||
                            (cChar == "\t") || (cChar == " "))){
		iEnd --;
		cChar = sToTrim.charAt(iEnd);
	}

	if (iStart <= iEnd){
		sTrimmed = sToTrim.substring(iStart, iEnd + 1);
	} else {
		sTrimmed = "";
	}

	return sTrimmed;
}


// COOKIES.JS

// Heinle's function for retrieving a cookie.
function getCookie(name){
  var cname = name + "=";               
  var dc = document.cookie;             
  if (dc.length > 0) {              
    begin = dc.indexOf(cname);       
    if (begin != -1) {           
      begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}

// An adaptation of Dorcht's function for setting a cookie.
function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) + 
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}

// An adaptation of Dorcht's function for deleting a cookie.
function delCookie (name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}


function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );
if ( expires )
{
	expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && 
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
	
// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


function CookiesEnabled()
{
	cookie_set = false;
	
	Set_Cookie( 'test', 'none', '', '/', '', '' );
	if ( Get_Cookie( 'test' ) )
	{
		cookie_set = true;
		Delete_Cookie('test', '/', '');
	}

	return cookie_set;
}

/*
Name: CreateOBJ ( string )
Author: Matt Heitto
Date: September 18, 2006
Purpose: Used to bypass the activex "click to activate" on interactive flash objects
*/

function CreateOBJ(x) {
	document.write(x);
}

// Search function (Movies, Games, Directors, Actors) on the top nav bar
function SubmitSearch(form) {
  
  if (form.search_select.value == "game") {
	// search for games
	if (document.URL.indexOf("/francais/") > 0)
	{
		form.action = '/francais/search/search_games.asp';
	}
	else
	{
		form.action = '/search/search_games.asp';
	}
  }
  else {
	// search for movies
	if (document.URL.indexOf("/francais/") > 0)
	{
	    form.action = '/francais/search/search.asp';
	}
	else
	{
		form.action = '/search/search.asp';
	}
  }
  form.sv.value = form.sv.value.replace(/\s*$/,"").replace(/^\s*/,"");
  if (form.sv.value == "Enter keyword") {
	
	alert ("Please specify keyword(s) to search for.");

    return false;
  }
  if (form.sv.value == "Écrivez le mot-clé") {
	
	alert ("Veuillez préciser un ou des mots-clés pour votre recherche.");
	
	return false;
  }
  
  if (form.sv.value.length < 1) {
	if (document.URL.indexOf("/francais/") > 0)
	{
	    alert ("Veuillez fournir au moins un caractère pour votre recherche.");
	}
	else
	{
	    alert ("Please provide at least one character for your search.");
	}
    return false;
  }
  return true;
}

