//Flash Control
function mainMovie_DoFSCommand(command, args) { 
	switch(command) {
		case 'lang':
			var href = window.location.href;
			var host = window.location.host;
			if (href.substring(href.length-1,href.length) == '#') href = href.substring(0,href.length-1)
			window.location = replaceSubstring(href, host + '/en', host + '/tc')
			break;
		case 'schedules':
			location = '/schedules/';
			break;
		case 'highlights':
			location = '/highlights/';
			break;
		case 'program descriptions':
			location = '/programs/';
			break;
		case 'press releases':
			location = '/press/';
			break;
		case 'anchors & correspondents':
			location = '/anchors/';
			break;
		case 'cnn news group':
			//pop up sub menu in flash
			break;
		case 'company profile':
			location = '/groups/corporate/';
			break;
		case 'cnn international':
			location = '/groups/international/';
			break;
		case 'cnn headline news':
			location = '/groups/headline/';
			break;
		case 'cnn mobile':
			location = '/groups/mobile/';
			break;
		case 'cnn radio':
			location = '/groups/radio/';
			break;
		default:
			break;
	}
}
function sectionMovie_DoFSCommand(command, args) { 
	switch(command) {
		case 'lang':
			var href = window.location.href;
			var host = window.location.host;
			if (href.substring(href.length-1,href.length) == '#') href = href.substring(0,href.length-1)
			window.location = replaceSubstring(href, host + '/en', host + '/tc')
			break;
		default:
			break;
	}
}
function replaceSubstring(inputString, fromString, toString) {
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) {
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else {
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      }
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   }
   return temp;
}

document.write("<scr"+"ipt type='text/javascript' src='/lib/js/x_core.js'></scr"+"ipt>")
document.write("<scr"+"ipt type='text/javascript' src='/lib/js/x_event.js'></scr"+"ipt>")


function MM_swapImgRestore() { //v3.0
  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_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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() { //v3.0
  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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Scroll Move
var IE  = navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1;
function movePosition(){
  position = Math.floor(position*0.9);
  if( position > 0.1 ){
    window.scrollTo(0,position)
    setTimeout("gotoPageTop()",15);
  } else { window.scrollTo(0,0) }
}

function gotoPageTop(){
  if( IE ){
    position = document.body.scrollTop;
  } else {
    position = window.pageYOffset;
  } movePosition()
}

//front page schedule height setting
function frontScheduleHeight(){
	xHeight('MiddleTable',xClientHeight()-430)
	xHeight('SchLayer',xHeight('MiddleTable'))
}

//middle content height adjustments
function ContentHeight(){
	xHeight('MiddleTable',xClientHeight()-211)
}

function ContentHeight2(){
	xHeight('MiddleTable',xClientHeight()-296)
}

function ContentTableHeight(){
	xHeight('ContentTable',xClientHeight()-211-60)
}

//Hightlight popup pdf
function highlightsGetDoc(region,doc){
	doc = '/lib/files/docs/highlights/'+region+'/'+doc;
	if (doc.substring(doc.length-3)=='pdf'){
		objViewer(doc,'PDF',760,490);
	}else{
		window.location = doc
	}
}

//Manual popup pdf
function objViewer(obj,type,width,height){
	MM_openBrWindow('/tools/misc/viewer.cfm?type='+type+'&filepath='+obj,type,'menubar=yes,resizable=yes,width='+width+',height='+height);
}

function manualGetDoc(doc){ objViewer(doc,'PDF',760,490); }
function cableGetDoc(doc) {	objViewer(doc,'PDF',760,490); }
function imageGetDoc(img) {	objViewer(img,'image',760,490); }
function openExternalLink(url) {	objViewer(escape(url),'extlink',775,560); }

//Program Descriptions item mouse over
function OverEffect(obj,toggle){
	if (toggle) {
		overBackgroundColor = '#dedede';
		overFontColor = '#cc0000';
		obj.style.backgroundColor = overBackgroundColor;
		obj.style.color = overFontColor;
		obj.style.cursor = 'hand';
	} else {
		overBackgroundColor = '';
		overFontColor = '#666666';
		obj.style.backgroundColor = overBackgroundColor;
		obj.style.color = overFontColor;
		obj.style.cursor = '';
	}
}
