	// Common Functions:

	function preload_images()
	{
		imgs = preload_images.arguments; 
		for(i = 0; i < imgs.length; i++)
		{
			eval("image" + i + " = new Image();");
			eval("image" + i + ".src = '" + imgs[i] + "';");
		}
	}
	
	function rollover(imageName, imageFile)
	{
		if (document.images)
		{
			document[imageName].src = imageFile;
		}
	}
	
	function rollout(imageName, imageFile)
	{
		if (document.images)
		{
			document[imageName].src = imageFile;
		}
	}
	
	function popupFile(fileName, w, h)
	{
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,resizable=0,menubar=0,toolbar=0,location=0' ;
		title = 'MyCokePopUp' + Math.floor(Math.random()*1000000+1);
		win = window.open(fileName, title, winprops);
		if(win) {
			win.focus();
			if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
		}
	}
	
		
	function popupFileWallpaperTrivia(fileName, typeWindow)
	{
		var winl = (screen.width) / 2;
		var wint = (screen.height) / 2;
		winprops = 'height=600,width=800,top='+wint+',left='+winl+',scrollbars=yes,resizable=0,menubar=0,toolbar=0,location=0' ;
		title = 'MyCokePopUp' + Math.floor(Math.random()*1000000+1);
		if(typeWindow==800){
			//alert("800");
			location.href = "cAtWWallpaper.html?&wallpaper_name="+fileName;
			//win = window.open("cAtWWallpaper.html?&wallpaper_name="+fileName, title, winprops);
		}else if(typeWindow==1024){
			//alert("1024");
			location.href = "cAtWWallpaper.html?&wallpaper_name="+fileName;
			//win = window.open("cAtWWallpaper.html?&wallpaper_name="+fileName, title, winprops);
		}
		/*if(win) {
			win.focus();
			if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
		}*/
	}
	
	function openMediaWindow(mediaType)
	{
		popupFile(mycokeDomainSSL+'displayreferfriendpage.do?mediaType=' + mediaType, 400, 530);
	}

	function openTour() {
		var studiotour;
		var studiowindow;
		studiotour = '/pages/tour.html';
		studiowindow = window.open(studiotour,"Tour_the_CokeStudios","width=560,height=300,status='no',toolbar='no', menubar='no',scrollbars=0");
	}
	
	function goHome() {
		window.location = mycokeDomain;
	}
	function changeURL(url) {
		window.location = url;
	}

	function getHost(fullURL)
	{
		var re = new RegExp('^[(?:f|ht)tp(?:s)?\://]*[www.]*([^./]*)', 'im');
		var matched = fullURL.match(re);
		if(matched != null)
			return matched[1].toString();
		else
			return fullURL;
	}
	
	function getReferal()
	{
		var myTag = getSpecificParam('tag')
		var referer = (myTag==null)?document.referrer:myTag;
		referer = getHost(referer);
		return referer;
	}
	
	function popupFileNoScrolls(fileName, w, h)
	{
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,resizable=0,menubar=0' ;
		title = 'MyCokePopUp' + Math.floor(Math.random()*1000000+1);
		win = window.open(fileName, title, winprops);
		if(win) {
			win.focus();
			if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
		}
	}
		
		// Example:
		// writeCookie("myCookie", "my name", 24);
		// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
		function writeCookie(name, value, hours)
		{
			
			//alert("writeCookie " + name);
			var expire = "";
			if(hours != null){
				expire = new Date((new Date()).getTime() + hours * 3600000);
				expire = "; expires=" + expire.toGMTString();
			}
			document.cookie = name + "=" + escape(value)+ expire;
			//alert(document.cookie);
		}
		// Example:
		// alert( readCookie("myCookie") );
		function readCookie(name)
		{
			var cookieValue = "";
			var search = name + "=";
			if(document.cookie.length > 0)
			{
				offset = document.cookie.indexOf(search);
				if (offset != -1){
					offset += search.length;
					end = document.cookie.indexOf(";", offset);
					if (end == -1) end = document.cookie.length;
					cookieValue = unescape(document.cookie.substring(offset, end))
				}
			}
			flashProxy.call("readCookieReturn", cookieValue);
		}
		//---
		function readCookiex(name)
		{
			var cookieValue = "";
			var search = name + "=";
			if(document.cookie.length > 0)
			{
				offset = document.cookie.indexOf(search);
				if (offset != -1){
					offset += search.length;
					end = document.cookie.indexOf(";", offset);
					if (end == -1) end = document.cookie.length;
					cookieValue = unescape(document.cookie.substring(offset, end))
				}
			}
			return cookieValue;
		}
		//---
		function readCookieCallBack(name, callback)
		{
			var cookieValue = "";
			var search = name + "=";
			if(document.cookie.length > 0)
			{
				offset = document.cookie.indexOf(search);
				if (offset != -1){
					offset += search.length;
					end = document.cookie.indexOf(";", offset);
					if (end == -1) end = document.cookie.length;
					cookieValue = unescape(document.cookie.substring(offset, end))
				}
			}
			flashProxy.call(callback, cookieValue);
		}
		// This version returns the cookieValue rather than calling the Flash Proxy
		 //alert( readCookie2("myCookie") );
		function readCookie2(name)
		{
			//alert("cookieReaded " + name);
			var cookieValue = "";
			var search = name + "=";
			if(document.cookie.length > 0)
			{
				offset = document.cookie.indexOf(search);
				if (offset != -1){
					offset += search.length;
					end = document.cookie.indexOf(";", offset);
					if (end == -1) end = document.cookie.length;
					cookieValue = unescape(document.cookie.substring(offset, end))
				}
			}
			return cookieValue;
		}
		//----
		
		function RemoveCookie (name) 
		{ 
			if (GetCookie(name) != "") 
			{
				document.cookie = name +  "="  + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
			}
		}
		//function that check if browser are cookies enabled
		function checkCookies(){
			var tmpcookie = new Date();
   			chkcookie = (tmpcookie.getTime() + '');
   				document.cookie = "chkcookie=" + chkcookie + "; path=/";
    			if (document.cookie.indexOf(chkcookie,0) < 0) {
      				return false;
      				}
    			else {
      				return true;
    				}	
		}

		
	/*//	
	function jsTestInfo(value)
	{
		//alert("from js to flash " + " proxy " + flashProxy + " uid " + uid );
		flashProxy.call('testInfo', value);
	}*/

	//	
	function doUpdateFlashHeader(value)
	{
		flashProxy.call('doUpdateFlashHeader', value);
	}
	
	//	
	function updateFlashHeader(value)
	{
		//alert("updateFlashHeader loaded");
		parent.doUpdateFlashHeader();
	}	
	
	// 
	function doAlert(value)
	{
		alert("from flash " + value);
	}
	
	// 
	function doAlert2(value)
	{
		alert("from flash  doAlert2 " + value);
	}

	function CountChars()
	{
		if(document.submitFilmForm.synopsis.value.length > 500)
		{
			document.submitFilmForm.synopsis.value = document.submitFilmForm.synopsis.value.substring(0, 500);
		}
	}
function MM_swapImgRestore() { 
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { 
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { 
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function endLoad(){
	flashProxy.call("onLoadIframe", true);
	//alert("endLoadVar")
}

function isThereClientInstalled()
{
    try {      
      var thereLauncher = new ActiveXObject( "There.Launcher" );
      var thereVoiceTrainer = new ActiveXObject( "There.VoiceTrainer" );
      
      if( thereLauncher || thereVoiceTrainer )
        return true;
      
    } catch( error ) {
        return false;
    }
}

function browserIsSupported()
{
  var agent = navigator.userAgent.toLowerCase();
  var major = parseInt(navigator.appVersion);
  var minor = parseFloat(navigator.appVersion);

  var isOpera = agent.indexOf("opera") != -1;
  var isIe = !isOpera && ( agent.indexOf("msie") != -1 );
  var isIe3 = isIe && ( major < 4 ) && ( agent.indexOf("msie 6") == -1 );
  var isIe4 = isIe && ( major == 4 ) && ( agent.indexOf("msie 4") != -1 );
  var isIe5Up = isIe && !isIe3 && !isIe4;

  return isIe5Up;
}
function callSpotlight(sTrack,src,type)
{
	//alert("callSpotlight");
	var axel = Math.random()+"";
	var nRnd = axel * 10000000000000;
	if(src == null || src == "") src = "1352258";
	if(type == null || type == "") type = "cokec468";
	var floodlightTag = "http://fls.doubleclick.net/activityi;src="+src+";type="+type+";cat=" + sTrack + ";ord="+ nRnd + "?"; 
	
	//alert(floodlightTag);
	if(document.getElementById("DCLK_FLDiv"))
	{
		var flDiv=document.getElementById("DCLK_FLDiv");
	}else{
		var flDiv=document.body.appendChild(document.createElement("div"));
		flDiv.setAttribute("id","DCLK_FLDiv");
		flDiv.style.position="absolute";
		flDiv.style.visibility="hidden";
		flDiv.style.top="0px";
	}
	flDiv.innerHTML='<iframe id="DCLK_FLIframe" src="' + floodlightTag + '" WIDTH=1 HEIGHT=1 FRAMEBORDER=0></iframe>';
}

function callSearchRevTag(type,src)
{
	var tagDiv = document.getElementById("SRTAG_"+type);
	if(!tagDiv)
	{
		var flDiv = document.getElementById("SRTAG_FLDiv");
		if(!flDiv)
		{
			flDiv=document.body.appendChild(document.createElement("div"));
			flDiv.setAttribute("id","SRTAG_FLDiv");
			flDiv.style.position="absolute";
			flDiv.style.visibility="hidden";
			flDiv.style.top="0px";
		}
		
		tagDiv = flDiv.appendChild(document.createElement("div"));
		tagDiv.setAttribute("id","SRTAG_"+type);
		tagDiv.style.position="absolute";
		tagDiv.style.visibility="hidden";
		tagDiv.style.top="0px";
	}
	tagDiv.innerHTML="<img src='"+src+"' width='1' height='1' border='0'/>";
}

function callSearchRevTag_byType(type)
{
	var src = "https://s1.srtk.net/www/delivery/ti.php?trackerid=699&cb=430680013&_sr_amount=0&_sr_page="+type;
	callSearchRevTag(type,src);
}
