// JavaScript Document
var foundation_selected = null;
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 hide_foundations(){
	if(foundation_selected != null){
		obj = document.getElementById(foundation_selected);
		obj.className = obj.className.replace('selected','');
		foundation_selected = null;
	}
	obj = document.getElementById('f1');
	if(obj)
		obj.style.display = 'none';
	obj = document.getElementById('f2');
	if(obj)
		obj.style.display = 'none';
	obj = document.getElementById('f3');
	if(obj)
		obj.style.display = 'none';
}

function show_foundation(obj_id, caller){
	hide_foundations();
	foundation_selected = caller;
	obj = document.getElementById(caller);
	obj.className = obj.className + ' selected';

	obj = document.getElementById(obj_id);
	obj.style.display="block";
	return false;
}

function hide_videosnews(){
	obj = document.getElementById('vn'+vn_id[0]);
	if(obj)
		obj.style.display = 'none';
	obj = document.getElementById('vn'+vn_id[1]);
	if(obj)
		obj.style.display = 'none';
	obj = document.getElementById('vn'+vn_id[2]);
	if(obj)
		obj.style.display = 'none';
}

function show_video(obj_id){
	hide_videosnews();
	obj = document.getElementById(obj_id);
	obj.style.display = 'block';
	return false;
}

function clear_all(){
	hide_foundations();
	hide_videosnews();
	hide_cr_popups();
}

function hide_cr_popups(){
	objs = document.getElementsByTagName('div');
	for(i=0; i<objs.length; i++){
		if(objs[i].className == 'cr_popup'){
			objs[i].style.display = 'none';
		}
	}
}

function show_cr_popup(obj_id){
	hide_cr_popups();
	obj = document.getElementById(obj_id);
	obj.style.display = 'block';
	return false;
}

function popup_window(url, windw_name, windw_width, windw_height){
	var windw = window.open(url+'?w='+windw_width+'&h='+windw_height,windw_name,'width='+windw_width+',height='+windw_height);
	windw.focus();
	return false;
}

function hide_is_popups(){
	objs = document.getElementsByTagName('div');
	for(i=0; i<objs.length; i++){
		if(objs[i].className == 'is_popup'){
			objs[i].style.display = 'none';
		}
	}
}

function show_is_popup(popup_id, direction){
	hide_is_popups();
	minusY = 0;
	minusX = 0;
	obj = document.getElementById('pop_'+popup_id);
	if(direction == 'right'){
		minusY = 190;
		minusX = 80;
	}
	if(direction == 'left'){
		minusY = 190;
		minusX = 180;
	}
	
	obj.style.top = tempY-minusY+'px';
	obj.style.left = tempX-minusX+'px';
	obj.style.display = 'block';
}


// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }

if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + scrOfX;
    tempY = event.clientY + scrOfY;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
//  document.Show.MouseX.value = tempX;
//  document.Show.MouseY.value = tempY;
  return true
}


var up,down;
var min1,sec1;
var cmin1,csec1,cmin2,csec2,chour1,cday1,chour2,cday2;
var start_time;
var day_obj = document.getElementById('day');
var hour_obj = document.getElementById('hour');
var min_obj = document.getElementById('min');
var sec_obj = document.getElementById('sec');


function Days() {
  for(var i=0;i<start_time.length;i++) if(start_time.substring(i,i+1)==":") break;
  data = start_time.substring(0,i);
  start_time = start_time.substring(i+1,start_time.length);
  return(data);
}

function Hours() {
  for(var i=0;i<start_time.length;i++) if(start_time.substring(i,i+1)==":") break;
  data = start_time.substring(0,i);
  start_time = start_time.substring(i+1,start_time.length);
  return(data);
}

function Minutes() {
  for(var i=0;i<start_time.length;i++) if(start_time.substring(i,i+1)==":") break;
  data = start_time.substring(0,i);
  start_time = start_time.substring(i+1,start_time.length);
  return(data);
}

function Seconds() {
  return(start_time);
}

function Display(day,hour,min,sec) {
  var disp;
  if(day<=9) disp="0"+day;
  else disp=day;
  day_obj.innerHTML = disp;
  
  if(hour<=9) disp="0"+hour;
  else disp=hour;
  hour_obj.innerHTML = disp;

  if(min<=9) disp="0"+min;
  else disp=min;
  min_obj.innerHTML = disp;

  if(sec<=9) disp="0"+sec;
  else disp=sec;
  sec_obj.innerHTML = disp;
}

function Down() {
  cday2=1*Days();
  chour2=1*Hours();
  cmin2=1*Minutes();
  csec2=1*Seconds();
  DownRepeat();
}

function DownRepeat() {
  if (!day_obj){
	day_obj = document.getElementById('day');
	hour_obj = document.getElementById('hour');
	min_obj = document.getElementById('min');
	sec_obj = document.getElementById('sec');
  }
  csec2--;
  if(csec2==-1) { csec2=59; cmin2--; }
  if(cmin2==-1) { cmin2=59; chour2--; }
  if(chour2==-1) { chour2=23; cday2--; }
  Display(cday2,chour2,cmin2,csec2);
  if((cday2==0)&&(chour2==0)&&(cmin2==0)&&(csec2<=3)) {document.location.href=document.location.href}
  else down=setTimeout("DownRepeat()",1000);
}

var ok;
ok=false;

function checkEmail(email) {
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email.value)) {
		return false;
	}
	return true;
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}
var yPos1;
var cur_page;
var cur_clip;
function check_agree(page, clipfile){
	c_val = getCookie('agree');
	cur_page = page;
	cur_clip = clipfile;
	if(c_val == null || c_val == ''){
		if(browser == 'Internet Explorer'){
			if (self.pageYOffset) {
				yPos1 = self.pageYOffset;
			} else if (document.documentElement && document.documentElement.scrollTop){
				yPos1 = document.documentElement.scrollTop; 
			} else if (document.body) {
				yPos1 = document.body.scrollTop;
			}
			window.scrollTo(0, 0); 

			bod = document.getElementsByTagName('body')[0];
			bod.style.height = '100%';
			bod.style.overflow = 'hidden';
	  
			htm = document.getElementsByTagName('html')[0];
			htm.style.height = '100%';
			htm.style.overflow = 'hidden'; 
		}
		document.getElementById('myoverlay').style.display='block';
		document.getElementById('disclosure_box').style.display='block';
		return false;
	}
	if(cur_page == 'ER'){
		document.getElementById(player_box_id).innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="322" height="242" id="redsoxPlayer" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="transparent"/><param name="movie" value="sample.swf?clipfile='+cur_clip+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="sample.swf?clipfile='+cur_clip+'" quality="high" bgcolor="#ffffff" width="322" height="242" name="redsoxPlayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" /></object>';
	}
	document.getElementById(player_box_id).style.display='block';
	return true;
}
function agreeclick(status){
	document.getElementById('disclosure_box').style.display='none';
	document.getElementById('myoverlay').style.display='none';
	if(status==1){
		document.cookie='agree=true';
		if(cur_page == 'ER'){
			document.getElementById(player_box_id).innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="322" height="242" id="redsoxPlayer" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="transparent"/><param name="movie" value="sample.swf?clipfile='+cur_clip+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="sample.swf?clipfile='+cur_clip+'" quality="high" bgcolor="#ffffff" width="322" height="242" name="redsoxPlayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" /></object>';
		}
		document.getElementById(player_box_id).style.display='block';
	}

	if(browser == 'Internet Explorer'){
		window.scrollTo(0, yPos1);

		bod = document.getElementsByTagName('body')[0];
		bod.style.height = 'auto';
		bod.style.overflow = 'auto';
  
		htm = document.getElementsByTagName('html')[0];
		htm.style.height = 'auto';
		htm.style.overflow = 'auto'; 
	}
}