//ChillCAM Javascripts

// Note: JavaScripts by JakeMAN! - jakeman@jakeman.com
//       (except for 'showdate() and isEmail()' which I got 
//       from: www.javascriptsource.com and www.javascript.com



function jakeman()
{
var result;
	result = window.confirm("It's JakeMAN! See me live at http://www.jakeman.com/live.");
	if (result != false)
	window.location.href="http://www.jakeman.com/live";
}


function killtext1()
{
	if (document.joinemaillist.join.value=="Enter Email") {
	document.joinemaillist.join.value=""
	}
}

function killtext1a()
{
	if (document.joinemaillist.join.value=="") {
	document.joinemaillist.join.value="Enter Email"
	}
}

function killtext2()
{
	if (document.emailer.emailfrom.value=="Enter Your Email") {
	document.emailer.emailfrom.value=""
	}
}

function killtext2a()
{
	if (document.emailer.emailfrom.value=="") {
	document.emailer.emailfrom.value="Enter Your Email"
	}
}

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function setColor(el, bg) {
  if (el.style) el.style.backgroundColor = bg;
}

function joinmailinglist()
{
  var bgBad = "#FFFFCC";
  var bgGood = "white";
  var valid = true;
  var dude = document.joinemaillist.join.value;

	if (dude=="Enter Your Email Address" || dude=="" || dude==" ") {
		valid = false;
   		setColor(document.joinemaillist.join, bgBad);	
		window.alert("Please enter your EMAIL Address.");
		document.joinemaillist.join.value="";
		document.joinemaillist.join.focus()
		return false;
	} else {
	setColor(document.joinemaillist.join, bgGood);
	}

	if (isEmail(dude)==false) {
	window.alert("I don't think '" + dude + "' is a real email address.\nIt should look something like this:\n\nsomedude@somewhere.com")
	valid = false;
   	setColor(document.joinemaillist.join, bgBad);	
	document.joinemaillist.join.value="";
	document.joinemaillist.join.focus()
	return false;
	}
	var mylength;
	mylength=dude.length
	if (mylength>254) {
	window.alert("Dude, I KNOW you\'re not trying to crash the ChillCAM home page!\n\nIf you're not, then your email address is too darn long!")
	valid = false;
   	setColor(document.joinemaillist.join, bgBad);		
	document.joinemaillist.join.value="";
	document.joinemaillist.join.focus()	
	return false;
	}
	if (isEmail(dude)==true) {
	document.joinemaillist.joinemailkey.value="yes"	
	return true;
	}	
}


function emailcomments()
{
  var bgBad = "#FFFFCC";
  var bgGood = "white";
  var valid = true;
  var dude = document.emailer.emailfrom.value;

	if (dude=="" || dude==" " || dude=="Enter Your Email Address") {
	valid = false;
   	setColor(document.emailer.emailfrom, bgBad);		
	window.alert("Please enter your email address.")
	document.emailer.emailfrom.value="";
	document.emailer.emailfrom.focus()
	return false;
	}
	if (isEmail(dude)==false) {
	valid = false;
   	setColor(document.emailer.emailfrom, bgBad);	
	window.alert("I don't think '" + dude + "' is a real email address.\nIt should look something like this:\n\nsomedude@somewhere.com")
	document.emailer.emailfrom.value="";
	document.emailer.emailfrom.focus()
	return false;
	}
	var mylength;
	mylength=dude.length
	if (mylength>254) {
	valid = false;
   	setColor(document.emailer.emailfrom, bgBad);		
	window.alert("Dude, I KNOW your not trying to crash the ChillCAM home page!\n\nIf you\'re not, then your email address is too darn long!")
	document.emailer.emailfrom.value="";
	document.emailer.emailfrom.focus()	
	return false;
	}
	if (isEmail(dude)==true) {
	document.emailer.emailcommentskey.value="yes"
	return true;
	}
}


function myaddwebcam()
{
  var bgBad = "#FFFFCC";
  var bgGood = "white";
  var valid = true;
  var mysiteurl = document.addwebcam.siteurl.value;
  var mysitename = document.addwebcam.sitename.value;
  
	if (mysiteurl=="" || mysiteurl==" " || mysiteurl=="http://") {
	valid = false;
   	setColor(document.addwebcam.siteurl, bgBad);		
	window.alert("Please enter your Web Cam's U.R.L.")
	document.addwebcam.siteurl.value="http://";
	document.addwebcam.siteurl.focus()
	return false;
	}
	var mylength;
	mylength=mysiteurl.length
	if (mylength>254) {
	valid = false;
   	setColor(document.emailer.emailfrom, bgBad);		
	window.alert("Dude, I KNOW your not trying to crash the ChillCAM home page!\n\nIf you're not, then your Site U.R.L. is too darn long!")
	document.addwebcam.siteurl.value="";
	document.addwebcam.siteurl.focus()	
	return false;
	}
	
	
	if (mysitename=="" || mysitename==" ") {
	valid = false;
   	setColor(document.addwebcam.sitename, bgBad);		
	window.alert("Please enter your Web Cam's Name")
	document.addwebcam.sitename.value="";
	document.addwebcam.sitename.focus()
	return false;
	}
	var mylength;
	mylength=mysitename.length
	if (mylength>254) {
	valid = false;
   	setColor(document.emailer.emailfrom, bgBad);		
	window.alert("Dude, I KNOW your not trying to crash the ChillCAM home page!\n\nIf you're not, then your Site Name is too darn long!")
	document.addwebcam.sitename.value="";
	document.addwebcam.sitename.focus()	
	return false;
	}
	document.addwebcam.myselectcase.value=2
	return true;
}

function whichversion()
{
blur();
window.open("http://www.jakeman.com/chillcam/new/Which_Version.htm",
"MailingListWindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,scrolling=0,resizable=0,copyhistory=0,width=420,height=200,");


// Following line of code redirects remote window to another URL (if necessary).
// myWindow.location = "http://www.chillcam.com";
}

function showdate()
{
d = new Array(
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
);
m = new Array(
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
);

today = new Date();
day = today.getDate();
year = today.getYear();

if (year < 2000)    
year = year + 1900;  

end = "th";
if (day==1 || day==21 || day==31) end="st";
if (day==2 || day==22) end="nd";
if (day==3 || day==23) end="rd";
day+=end;

var PleaseShowDate = (d[today.getDay()]+", "+m[today.getMonth()]+" "+day+", " + year);
document.write(PleaseShowDate);
}

hexColor = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
function mOver() {
for (i = 0; i < 13; i++) {
setTimeout('document.emailer.mybutton.style.background = "#'+hexColor[12-i]+'0'+hexColor[12-i]+'0c0";', i * 40);
setTimeout('document.emailer.mybutton.style.color = "#'+hexColor[i]+'0'+hexColor[i]+'0c0";', i * 40);
   }
}
function mOut() {
for (i = 0; i < 12; i++) {
setTimeout('document.emailer.mybutton.style.background = "#'+hexColor[i]+'0'+hexColor[i]+'0c0";', i * 40);
setTimeout('document.emailer.mybutton.style.color = "#'+hexColor[12-i]+'0'+hexColor[12-i]+'0c0";', i * 40);
   }
}


function golinks(dir){

	if (dir=="back"){
		document.links.Direction.value="back";
		document.links.submit();	
	}else {
		if (dir==""){
			document.links.Direction.value="forward";
			return true;	
		}else {
			document.links.Direction.value="forward";
			document.links.submit();	
		}
	}
}


function bottommenu()
{
document.write("<a href=./index.asp>Home</a>");
document.write("&nbsp;&#149;&nbsp;");
document.write("<a href=./owners_manual.asp>Owners Manual</a>");
document.write("&nbsp;&#149;&nbsp;");
document.write("<a href=./links.asp>ChillCAM Links</a>");
document.write("<br><img src=./images/spacer.gif width=1 height=4><br>");
document.write("<a href=./chat.asp>ChillCAM Chat</a>");
document.write("&nbsp;&#149;&nbsp;");
document.write("<a href=javascript:whichversion()>Register Now!</a>");
document.write("&nbsp;&#149;&nbsp;");
document.write("<a href=./download.asp>Download</a>");
document.write("<br><img src=./images/spacer.gif width=1 height=4><br>");
document.write("<a href=./add_web_cam.asp>Add Cam Link</a>");
//document.write("&nbsp;&#149;&nbsp;");
//document.write("<a href=./contact.asp>Contact ChillCAM</a>");
}


