// E-Comp form submission scripts
var action= "none";
function seteCompAction(button) {
	if (button == "coName") {
		document.images['coName'].src = "/images/ecp/ecomp_co_name03_on.gif";
		document.images['coSymbol'].src = "/images/ecp/ecomp_co_symbol03_off.gif";
	} else {
		document.images['coSymbol'].src = "/images/ecp/ecomp_co_symbol03_on.gif";
		document.images['coName'].src = "/images/ecp/ecomp_co_name03_off.gif";
	}
	action = button;
}
function eCompSubmit() {
	submitUrl = "http://www.ecomponline.com/Ecomp/foxnews/";
	if (document.eCompForm.defaultText.value == "") {
		alert("You must enter a company name or symbol to continue.");
	} else {
		if (action == "none") {
			alert("You must select your type of search before you can continue.");
		} else if (action == "coName") {
			window.location = submitUrl+"companies.tcl?dir=foxnews&compname="+document.eCompForm.defaultText.value;
		} else if (action == "coSymbol") {
			window.location = submitUrl+"company.tcl?dir=foxnews&symbol="+document.eCompForm.defaultText.value;
		}
	}
	return false;
}

// Photo Pop Script for Story Pages
function photoPop(photo,caption,credit,width) {
	var w = 440;
	var h = 375;
	if (doCheck && navigator.platform == "MacPPC"){
		w = w - 16;
		h = h - 16;
	}
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var dimensions = 'height='+h+',width='+w+',top='+wint+',left='+winl+',resizable=\'no\'';
	if (width == 300) {
		var leftGut = 105;
		var topGut = 50;
		var rightCol = 335;
		var height = 200;
	} else {
		var leftGut = 160;
		var topGut = 10;
		var rightCol = 280;
		var height = 300;
	}
	if (caption.search(/%5C/g) != -1) {caption = caption.replace(/%5C/g,"");}
	if (credit.search(/%5C/g) != -1) {credit = credit.replace(/%5C/g,"");}
	var win = window.open('','foxPhoto',dimensions); 
	var d = win.document; 
	d.writeln("<html>"); 
	d.writeln("<head>");
	d.writeln("<title>FOXNews.com</title>");
	d.writeln("<LINK REL=STYLESHEET TYPE=\"text/css\" HREF=\"/basestyles2003.css\">"); 
	d.writeln("</head>"); 
	d.writeln("<body marginheight=0 marginwidth=0 topmargin=0 leftmargin=0 background=\"/images/bg_photo_popup.gif\" onLoad=\"window.focus();\">"); 
	d.writeln("<table cellpadding=0 cellspacing=0 border=0 width=440>");
	d.writeln("<tr>");
	d.writeln("<td><img src=\"/images/clear_dot.gif\" width="+leftGut+" height="+topGut+"></td>");
	d.writeln("<td><img src=\"/images/clear_dot.gif\" width="+rightCol+" height="+topGut+"></td>");
	d.writeln("</tr>");
	d.writeln("<tr>");
	d.writeln("<td><img src=\"/images/clear_dot.gif\" width="+leftGut+" height=10></td>");
	d.writeln("<td valign=\"top\">");
	d.writeln("<table cellpadding=0 cellspacing=0 border=0 width="+width+">");
	d.writeln("<tr><td><img src=\"/images/"+photo+"\" border=0 width="+width+" height="+height+"></td></tr>");
	if (credit != "") {d.writeln("<tr><td class=\"capblack\" align=\"right\">"+credit+"</td></tr>");}
	if (caption != "") {d.writeln("<tr><td class=\"capblack\">"+caption+"</td></tr>");}
	d.writeln("</table>");
	d.writeln("</td>");
	d.writeln("</tr>");
	d.writeln("</table>");
	d.writeln("</body>"); 
	d.writeln("</html>"); 
	d.close(); 
}

// E-mail a Friend Link Function
function emailFriend() {
    if (document.emailFriend.byline.value == "none") {
        document.emailFriend.byline.value = "FOXNews";
    }
    if (window.location == "http://www.foxnews.com/story/0,2933,18502,00.html" || window.location == "http://www.foxnews.com/story/0,2933,20055,00.html") {
        document.emailFriend.date.value = "";
    }
    document.emailFriend.url.value = window.location;
    document.emailFriend.submit();
}

// E-mail Address Validator
function isEmail(email) {
	emailArray = new Array ();
	if (email.search(/,/g) == -1 && email.search(/ /g) == -1) {
		emailArray[0] = email;
	} else if (email.search(/,/g) != -1) {
		emailArray = email.split(',');
	} else {
		return false
	}
	for (n=0;n<emailArray.length;n++) {
		emailAdd = emailArray[n].replace(/ /, "");
		atPos = emailAdd.indexOf("@"); 
		dotPos = emailAdd.lastIndexOf(".");
		lastPos = emailAdd.length-1;
		if (atPos < 1 || dotPos-atPos < 2 || lastPos-dotPos<2 || emailAdd.search(/ /g) != -1) {
			return false;
			break;
		} else {
			emailValidate = true;
		}
	}
	return emailValidate;
}

// Below are Special Section Images, URLs, and Functions
specialImages = new Array("490_vid_prof.jpg","490_gotomypc.gif","490_bosley.gif","490_forbes.jpg","490_lear.gif");
specialLinks = new Array("http://hits.videoprofessor.com/cgi-bin/hit?page=879-105553756415680","/specialsections/gotomypc.html","/specialsections/bosley.html","/specialsections/forbes.html","/specialsections/lear.html");
loadSpecialImgs = new Array();
for(i=0; i < specialImages.length; i++) {
  loadSpecialImgs[i] = new Image;
  loadSpecialImgs[i].src = "/images/"+specialImages[i];
}
spImgIndex = -1;
function specialImgSwitch() {
	spImgIndex++;
	if (spImgIndex == specialImages.length) {spImgIndex = 0}
	document.images['fixedSpImg'].src = "/images/"+specialImages[spImgIndex];		
	spImgInt = setTimeout('specialImgSwitch()', 7000);
}
function spImgLink() {
	linkIndex = spImgIndex;
	if(linkIndex == -1) {linkIndex = 0}
	if (linkIndex == 0) {
		window.open(specialLinks[linkIndex]);
	} else {
		window.location = specialLinks[linkIndex];
	}
}