
// do some browser sniffing
var isNav4=false;
var isNav6=false;
var isIE4=false;
var isIE40=false;

	if ((navigator.appVersion.indexOf("MSIE 4") >= 0) && (navigator.appName.indexOf("Explorer") >= 0))
	{
		isIE40 = true;
	}
	else {
	    if (navigator.appVersion.charAt(0) == "4")
		{
			if (navigator.appName.indexOf("Explorer") >= 0)
			{
			isIE4 = true;
			}
			else
			{
				isNav4 = true;
			}
		}
		else if (navigator.appVersion.charAt(0) > "4")
		{
			isNav6 = true;
		}
	}

// Reload the document if a Netscape 4 user resizes the window


if(isNav4) {
	origWidth=innerWidth;
	origHeight=innerHeight;
	onresize=function(){
		if(innerWidth!=origWidth||innerHeight!=origHeight)location.reload()
	}
}
//stop the browser sniffing, you've done enuf already.


function sizeIt(){
if(navigator.appName == "Netscape"){
return
	} else {	
	document.forms[0].search.size="16"
}
}

function checkEmail(form,temp){
//you must pass both the name of the element you want checked (as a string) AND the form object itself.
	for( i = 0; i < form.elements.length; i++ ) {
		if ( form.elements[i].type == "text" && form.elements[i].name == temp ){
			email = form.elements[i].value
			email = email.toLowerCase()
			if( email == "" ) {
				alert( "Please enter your Email Address" )
				form.elements[i].focus()
				return
			} else
			if( form.elements[i].value.indexOf("@") > -1 ){
				if((email.indexOf(".com") > -1)||(email.indexOf(".org") > -1)
		   		||(email.indexOf(".gov") > -1)||(email.indexOf(".net") > -1)
			    ||(email.indexOf(".mil") > -1)||(email.indexOf(".edu") > -1)
	    		||(email.indexOf(".us") > -1)||(email.indexOf(".int") > -1)
			    ||(email.indexOf(".um") > -1)||(email.indexOf(".cc") > -1)    
			    ||(email.indexOf(".tv") > -1)||(email.indexOf(".ws") > -1)
			    ||(email.indexOf(".biz") > -1)||(email.indexOf(".int") > -1)    
			    ||(email.indexOf(".zz") > -1)||(email.indexOf(".ca") > -1)
					||(email.indexOf(".dk") > -1)){			
				} else {
					alert("That does not appear to be a valid email address")
					return
				}
			} else {
				alert("That does not appear to be a valid email address")
				return
			}
		}
	}

	
//alert("form would be submitted")
form.submit()
}

function sizeSpacer(){
			if(navigator.appName == "Netscape" && parseInt(navigator.appVersion) > "4"){
				document.images.spacer.width = 425;
			}					
			if (navigator.appName != "Netscape"){
				document.images.spacer.width = 415;
			}
			
}

function formSize(form){
// The form needs to be named "form" ie <form name="form" .....
	for( i = 0; i < document.form.elements.length; i++ ) {
		if ( document.form.elements[i].type == "text" || document.form.elements[i].type == "password" ){
			if(navigator.appName == "Netscape" && parseInt(navigator.appVersion) < "6"){
				document.form.elements[i].size = "30"
			} else {
				document.form.elements[i].size = "45"
			}
		}
	}
}

function checkFormer(){
//script for navbar search
form = document.navSearch
if(form.search.value == "") {
alert("Please enter a keyword")
form.search.focus()
return
}
//alert("form would be submitted")
form.submit()
}

// script for buddy check
function checkBuddy(form,temp){
var warn = ""
if ( form.FirstName.value == "" ){
warn = warn + "First Name\n"
}
if ( form.Email.value == "" ){
warn = warn + "Email\n"
}
if ( form.ZipCode.value == "" ){
warn = warn + "Zip Code\n"
}
if ( form.Password.value == "" ){
warn = warn + "Password\n"
}
if (form.Age.options[form.Age.selectedIndex].value == "") {
warn = warn + "Age Group\n"
}
var state = form.State.options[form.State.selectedIndex].value
//check for warn and send form to checkEmail to validate Email
if (warn != ""){
alert("You must fill in these fields:\n" + warn)
}else{
checkEmail(form,temp)
}}
// end of buddy check scripts


function DoIt(num){
var width = 0;
	if(navigator.appName == "Netscape"){
		width = window.innerWidth
		//width = width - 345
		//if(width < 400){
		//	width = 400;
		//}
	} else {
		width = document.body.clientWidth
		width = width - 340;
		if(width < 415){
			width = 415;
		}
	}
Output = "<td width=" + width + " valign=top align=left class=text>" + width
alert(Output)
document.writeln(Output);	
return Output;
}

function makeLayer(num){
	if(navigator.appName!="Netscape"){
		document.write('<div align=left id=L' + num + ' onMouseOver=rollOver(' + num + ') onMouseOut=rollOut(' + num + ')>');
	} else {
		document.write('<div align="left"><layer visibility=hide onMouseover=rollOver(' + num + ') onMouseOut=rollOut(' + num + ')></div>');
	}
}
	
function mouseIn(num){
imgSrc= "nav" + num;
document.images[imgSrc].src="http://images.kare11.com/images/bluepad.gif";
return true;
}
function mouseOut(num){
imgSrc= "nav" + num;
document.images[imgSrc].src="http://images.kare11.com/images/redpad.gif";
return true;
}

function rollOn(num){
document.images[num].src="http://images.kare11.com/images/amex/" + num + "-on.gif";
return true;
}
function rollOff(num){
document.images[num].src="http://images.kare11.com/images/amex/" + num + "-off.gif";
return true;
}

function handleResize(){
//	if(navigator.appName != "Netscape"){
//		location.href=document.URL
//	} else {
//	navigator.plugins.refresh(true);
//		return;
//	}
if(navigator.appName == "Netscape" && parseInt(navigator.appVersion) > "4"){
location.href=document.URL
} return
}


function rollOver(Obj){
	if(navigator.appName == "Netscape"){
		return
  } else {
		if (Obj == 1) {layerNo = "L1"; Left=210;}
		if (Obj == 2) {layerNo = "L2"; Left=281;}
		if (Obj == 3) {layerNo = "L3"; Left=362;}
		if (Obj == 4) {layerNo = "L4"; Left=443;}
		if (Obj == 5) {layerNo = "L5"; Left=514;}
		if (Obj == 6) {layerNo = "L6"; Left=585;}
		//document.all[layerNo].style.width = "150";
		document.all[layerNo].style.visibility = "visible";
	}
}
function rollOut(Obj){
	if(navigator.appName == "Netscape"){
		return
	} else {
		if (Obj == 1) layerNo = "L1";
		if (Obj == 2) layerNo = "L2";
		if (Obj == 3) layerNo = "L3";
		if (Obj == 4) layerNo = "L4";
		if (Obj == 5) layerNo = "L5";
		if (Obj == 6) layerNo = "L6";
		document.all[layerNo].style.visibility = "hidden";
	}
}
// Start Olympic Layer Generation
function OlyMakeLayer(num){
	if(navigator.appName!="Netscape"){
		document.write('<div align=left id=OL' + num + ' onMouseOver=OlyRollOver(' + num + ') onMouseOut=OlyRollOut(' + num + ')>');
	} else {
		document.write('<div align="left"><layer visibility=hide onMouseover=OlyRollOver(' + num + ') onMouseOut=OlyRollOut(' + num + ')></div>');
	}
}

function OlyRollOver(Obj){
	if(navigator.appName == "Netscape"){
		return
  } else {
		if (Obj == 1) {layerNo = "OL1"; Left=210;}
		if (Obj == 2) {layerNo = "OL2"; Left=281;}
		if (Obj == 3) {layerNo = "OL3"; Left=362;}
		if (Obj == 4) {layerNo = "OL4"; Left=443;}
		if (Obj == 5) {layerNo = "OL5"; Left=514;}
		if (Obj == 6) {layerNo = "L6"; Left=585;}
		document.all[layerNo].style.visibility = "visible"; 
	}
}
function OlyRollOut(Obj){
	if(navigator.appName == "Netscape"){
		return
	} else {
		if (Obj == 1) layerNo = "OL1";
		if (Obj == 2) layerNo = "OL2";
		if (Obj == 3) layerNo = "OL3";
		if (Obj == 4) layerNo = "OL4";
		if (Obj == 5) layerNo = "OL5";
		if (Obj == 6) layerNo = "OL6";
		document.all[layerNo].style.visibility = "hidden";
	}
}
// End Olympic Layer Generation



function openWin(w,h,URL) {
		if(navigator.appName != "Netscape"){
			w = parseInt(w) + 15
			h = parseInt(h) + 15
			
		}
    newWin=window.open(URL,"HandBags","resizable=yes,scrollbars=yes,width=" + w + ",height=" + h)
    }
		
function mypopUp(){
var myURLArray = document.URL.split("#");
var myURL = myURLArray[0]
newwin = window.open('','','top=50,left=50,width=300,height=300,scrollbars=yes,resizable=yes');
if (!newwin.opener) newwin.opener = self;
	with (newwin.document)
		{
			open();
				writeln("<html><head><title>Send This Link to a Friend</title>");
				writeln("<script>");
				writeln("function checkForm(formObj){");
				writeln("var URI = formObj.URL.value");
				writeln("var email = formObj.email.value;");
				writeln("var emailLength = email.length;");
				writeln("var emailWarning = 0;");
				writeln("var from = formObj.from.value;");
				writeln("var fromLength = from.length;");
				writeln("var fromWarning = 0;");
				writeln("var name = formObj.name.value;");
				writeln("var nameLength = name.length;");
				writeln("var nameWarning = 0;");
				writeln("for(i=0; i \< emailLength; i++){");
				writeln("if (email.charAt(i) == '@'){");
				writeln("emailWarning = 1	}}");
				writeln("if(emailWarning == 0){");
				writeln("alert('The TO email address you entered does not appear to be valid.  Please double check it.');");
				writeln("formObj.email.focus();return;}");
				writeln("for(i=0; i < fromLength; i++){");
				writeln("if (from.charAt(i) == '@'){");
				writeln("fromWarning = 1	}}");
				writeln("if(fromWarning == 0){");
				writeln("alert('The FROM email address you entered does not appear to be valid.  Please double check it.');");
				writeln("formObj.from.focus();return;}");
				writeln("if (name.length == 0){");
				writeln("alert('Please enter your name.');");
				writeln("formObj.name.focus();return;}");
				writeln("formObj.URL.value = URI;");
				writeln("formObj.submit()}");
				writeln("<\/script>");
				writeln('</head><body><link rel="stylesheet" href="http://images.kare11.com/includes/style.css">');
				writeln('<div align="left">');
				writeln('<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr>');
				writeln('<td><img src="http://images.kare11.com/images/ad.JPG"></td><td align="center">');
				writeln('<a class="wx3">Enter your friend\'s email address, your email address and your name.  Then click <b>Send</b> to send this page. </a><br><a class="wx">No information will be saved by KARE\-11</a></td></tr></table>');
				writeln('<form name="myForm" action="http://images.kare11.com/cgi-bin/SendLink.pl" method="post">');
				writeln('<input type="hidden" name="URL" value="' + myURL + '">');
				writeln('<table width="100%" cellspacing="0" cellpadding="2" border="0"><tr><td align="right"><a class="text">Your Friend\'s Email:</a></td><td><input type="text" name="email" value=""></td></tr>');
				writeln('<tr><td align="right"><a class="text">Your Email:</a></td><td><input type="text" name="from" value=""></td></tr>');
				writeln('<tr><td align="right"><a class="text">Your Name:</a></td><td><input type="text" name="name" value=""></td></tr>');
				writeln('<tr><td>&nbsp;</td><td align="left"><input type="button" value="Send" onclick="checkForm(this.form)"></form></td></tr></table>');
				writeln('<div align="center"><a href="#" onClick="window.close()" class="text1">Close this Window</a></div></body></html>');
			close();
		}//end with
}

function checkIt(form){
var missing = ""
if (form.to.options[form.to.selectedIndex].value == ""){
	alert("Please choose a department to send the message to")
	form.to.focus
	return
}
if (form.subject.value == ""){
	missing = missing + "\n Subject"
}

if (form.message.value == ""){
	missing = missing + "\n Message"
}
if(missing != ""){
if(confirm("Are you sure you want to send a message without a " + missing)){
	checkEmail(form,'from')
} return
}else{
	checkEmail(form,'from')
}
}

function BustFrames(url) {
	if (isNav4){
		document.location = "http://www.kare11.com" + url
		if (top.location != document.location){
		  top.location = document.location;
		}
	}else{
		if (self.parent.frames.length!=0)
		{
			top.location.href(url);
		}
	}
}


function checkForm(form)  {
	var checkstr = "0123456789";
	var displayWarning = 0
	var endWarn = 0
	var leap = 0
	var err = 0
	var DateTemp = ""
	
	tempDate = form.news_day.value.length
	for (i = 0; i < form.news_day.value.length; i++) {
	  if (checkstr.indexOf(form.news_day.value.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + form.news_day.value.substr(i,1);
	  }
  }
	if(tempDate != DateTemp.length){
		alert("Please enter a valid numeric date to search")
		return
	}
	
	if(DateTemp == ""){
		alert("Please enter a valid date to search")
		form.news_day.focus
		displayWarning=1
		return
	}
	
        var day = form.news_day.value
	var month = form.news_month.value
	var year = form.news_year.value
  if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
  	leap = 1;
  }
  if ((month == 2) && (leap == 1) && (day > 29)) {
	  err = 23;
  }
  if ((month == 2) && (leap != 1) && (day > 28)) {
  	err = 24;
  }
  if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
		err = 25;
  }
  if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
  	err = 26;
  }
	if(err != 0 ){	
		displayWarning = 1	
		alert("That appears to be an invalid date for the month and year you have chosen")
		form.news_day.focus
		return
	} else {
		displayWarning = 0
	}
	if (displayWarning == 0) {
		//alert("form would be submitted")
			form.submit()
	}
}



function checkFormKey(form){	
	var displayWarning = 0				
	if(form.search.value == "") {
		displayWarning = 1
		alert("Please enter a keyword")
		form.search.focus
		return
	}
	
	if (displayWarning == 0) {
//		alert("form would be submitted")
	form.submit()
	}
}


function checkButton(form){
	for (i=0;i<form.R1.length;i++){
		if(form.R1[i].checked){
			form.submit()
			return
		}
	}
	alert("Please choose a dress to vote for")
	return
}



function preload(){
	if(document.images){
		var image1 = new Image();
		image1.src = "http://images.kare11.com/images/advise-on.gif";
		var image2 = new Image();
		image2.src = "http://images.kare11.com/images/ask-on.gif";
		var image3 = new Image();
		image3.src = "http://images.kare11.com/images/click-on.gif";
		var image4 = new Image();
		image4.src = "http://images.kare11.com/images/find-on.gif";
		var image5 = new Image();
		image5.src = "http://images.kare11.com/images/watch-on.gif";

		
	}
}
function preloadNav(){
	if(document.images){
		var image6 = new Image();
		image6.src = "http://images.kare11.com/images/bluepad.gif";
	}
}
function chgBg(obj,color){
if (document.all || document.getElementById)
  obj.style.backgroundColor=color;
else if (document.layers)
  obj.bgColor=color;
}		
