// *** Browser Detection Script
if (!document.getElementById) {
	if (window.location != "http://www.foxnews.com/story/0,2933,95396,00.html") {
		window.location = "http://www.foxnews.com/story/0,2933,95396,00.html";
	}
}

var doCheck = (document.all!=null);

if (doCheck == false) {
	versionNN = navigator.appVersion;
	if (versionNN.search(/5.0/i) == -1) 
		browser = "NN4";
	else 
		browser = "NN6";
} else {
	var agt = navigator.userAgent.toLowerCase();
	if ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) 
		browser = "IE";
	else 
		browser = "OP";
}

// sitereg Cookie Detection
var gender = "";
var birthyear = "";
var zipcode = "";
var country = "";
var hhincome = "";
var industry = "";
var jobtitle = "";
var watchchannel = "";
var email = "";
var firstname = "";
var isFoxFan = false;
var isRegistered = false;
var openInsightDemo = "";

var crumbSR=unescape(document.cookie);

if (crumbSR.indexOf("sitereg=") > -1) {
	var isRegistered = true;
	startSR = crumbSR.indexOf("sitereg=") + 8;
	endSR = crumbSR.indexOf(";", startSR);
	if (endSR == -1)
		endSR = crumbSR.length;
	var cookieSR = crumbSR.substring(startSR,endSR);
	cookiebitesSR = cookieSR.split("|");
	
	gender = cookiebitesSR[0];
	birthyear = cookiebitesSR[1];
	zipcode = cookiebitesSR[2];
	country = cookiebitesSR[3];
	hhincome = cookiebitesSR[4];
	industry = cookiebitesSR[5];
	jobtitle = cookiebitesSR[6];
	watchchannel = cookiebitesSR[7];
	if (cookiebitesSR.length < 9) {
	    email = "";
		firstname = "";
	} else {
		email = cookiebitesSR[8];
		firstname = cookiebitesSR[9];
		isFoxFan = true;
	}
	openInsightDemo = "&if_nt_gender="+gender;
	openInsightDemo += "&if_nt_birthyear="+birthyear;
	openInsightDemo += "&if_nt_zip="+zipcode;
	openInsightDemo += "&if_nt_country="+country;
	openInsightDemo += "&if_nt_hhincome="+hhincome;
	openInsightDemo += "&if_nt_industry="+industry;
	openInsightDemo += "&if_nt_jobtitle="+jobtitle;
	openInsightDemo += "&if_nt_watchchannel="+watchchannel;
}

// *** Delete line below if image paths are relative
imgPath = "http://www.foxnews.com";

// *** Below is array containing rollover image paths
navimgNames = new Array(
	imgPath+"/images/top_nav/nav_on_business03.gif",
	imgPath+"/images/top_nav/nav_on_foxfan03.gif",
	imgPath+"/images/top_nav/nav_on_foxlife03.gif",
	imgPath+"/images/top_nav/nav_on_foxpolls03.gif",
	imgPath+"/images/top_nav/nav_on_access03.gif",
	imgPath+"/images/top_nav/nav_on_politics03.gif",
	imgPath+"/images/top_nav/nav_on_shows03.gif",
	imgPath+"/images/top_nav/nav_on_topstories03.gif",
	imgPath+"/images/top_nav/nav_on_views03.gif",
	imgPath+"/images/top_nav/nav_on_weather03.gif",
	imgPath+"/images/top_nav/nav_on_fea_foxfriends03.gif",
	imgPath+"/images/top_nav/nav_on_fea_foxreport03.gif",
	imgPath+"/images/top_nav/nav_on_fea_oreillyfactor03.gif",
	imgPath+"/images/top_nav/nav_on_fea_realestate03.gif",
	imgPath+"/images/top_nav/nav_on_fea_yourworld03.gif",
	"images/nav_on_local03.gif",
	"images/nav_on_usstates03.gif",
	"images/nav_on_pollen03.gif",
	"images/nav_on_world03.gif",
	"images/nav_on_email03.gif"
)

loadNavImgs = new Array();

// *** Below loops thru image paths and loads images into cache
for(i=0; i < navimgNames.length; i++) {
  loadNavImgs[i] = new Image;
  loadNavImgs[i].src = navimgNames[i];
}

// *** Below is the rollover/rollout scripts
function roll(name, state) {
	document.images[name].src = imgPath+"/images/top_nav/nav_"+state+"_"+name+"03.gif";
}
function rollOver(name) {
	document.images[name].src = imgPath+"/images/top_nav/nav_on_"+name+"03.gif";
}
function rollOut(name) {
	document.images[name].src = imgPath+"/images/top_nav/nav_off_"+name+"03.gif";
}

function weatherRoll(name, state) {
	document.images[name].src = "images/nav_"+state+"_"+name+"03.gif";
}


function weatherRoll(name, state) {
	document.images[name].src = "images/nav_"+state+"_"+name+"03.gif";
}

// *** Below is the pop-up script to launch the channel finder
function pop(mypage, myname, w, h, scroll,menu) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no';
	if (menu=='yes')
		winprops += ',menubar=yes,toolbar=yes,locationbar=yes';
		
	win = window.open(mypage, myname, winprops);
	  if ((window.navigator.appName.indexOf("Microsoft")==0) &
	      (window.navigator.appVersion.substring(0,1)=="4"))
	  {
	    damnBrowser = 1;
	  }
	  else if ((window.navigator.appName.indexOf("Netscape")==0) &
	           (window.navigator.appVersion.substring(0,1)=="4"))
	  {
	    damnBrowser = 1;
	  }
	  else if (parseFloat(navigator.appVersion.substring(0,navigator.appVersion.indexOf("")))>=3.0)
	  {
	    if ((window.navigator.appName.indexOf("Microsoft")=="0") &
	        (window.navigator.userAgent.indexOf("Mac")>=0) & (parseFloat(navigator.appVersion.substring(0,navigator.appVersion.indexOf("")))<4.0))
	    { }
	    else
	    {
	      win.focus();
	    }
	}
}

// Scroll Function for Search Text Box
searchInt = -1;
scrolling = true;
function searchScroll(state) {
	if (scrolling) {
		if (state == 'ongoing') {
			textBox = document.searchForm.ext_qkw.value;
			newBox = textBox.slice(1,(textBox.length));
			document.searchForm.ext_qkw.value = newBox+textBox.charAt(0);
			searchInt = setTimeout("searchScroll('ongoing')", 400);
		} else {
			document.searchForm.ext_qkw.value = " FOX News and Web: sources include Google, Ask Jeeves, WebCrawler. . .";
			searchInt = setTimeout("searchScroll('ongoing')", 3000);
		}
	}
}
// Search Validation Script Below
function searchSub() {
	if (scrolling || document.searchForm.ext_qkw.value.length == 0) {
		alert("Please enter text into the text field.");
		return false;
	} else {
		return true;
	}
}
function searchFocus() {
	if (scrolling) {
		document.searchForm.ext_qkw.value='';
		scrolling = false;
		if (searchInt!=-1) {
			clearTimeout(searchInt);
		}
	}
}

function redirectSiteReg() {
	window.location = 'http://www.foxnews.com/site_registration.html?url=' + window.location;
}

function loader(weather_pageType) {
	if (!isRegistered) {
//		redirectSiteReg();
	}
}
ffBugs = new Array("exclusives", "insider", "newsletters");
loadffImgs = new Array();
for(c=0; i < ffBugs.length; c++) {
  loadffImgs[c] = new Image;
  loadffImgs[c].src = ffBugs[i];
}

function ffImage() {
	ffBugNum = Math.floor(Math.random() * 3);
	document.writeln("<td><a href=\"http://www.foxnews.com/foxfan/index.html\"><img src=\"http://www.foxnews.com/images/top_nav/bug_foxfan_"+ffBugs[ffBugNum]+".gif\" border=0 width=85 height=72></a></td>");
}
