// JavaScript Document
//GoogleAd type: 0-480x60 (top), 1-160x600 (left side)
//GoogleChannel: 0-LeakyBagel, 1- LMM, 2-Skeletales
function writeGoogleAd( chanType, sizeType)
{
	var channel = "";
	switch (chanType)
		{
		case 0: //Leakybagel
			{
			channel = "google_ad_channel ='7714787077'\n";
			channel += "google_color_border = 'DFF2FD'\n";
			channel += "google_color_bg = 'DFF2FD'\n";
			break;
			}
		case 1: //LMM
			{
			channel = "google_ad_channel ='4604009747'\n";
			channel += "google_color_border = 'FDEFD2'\n";
			channel += "google_color_bg = 'FDEFD2'\n";
			break;
			}
		case 2: //Skeletales
			{
			channel = "google_ad_channel ='7714787077'\n"; //leakybagel channel
			channel += "google_color_border = 'E0FFE3'\n";
			channel += "google_color_bg = 'E0FFE3'\n";
			break;
			}
		default: break;
		}
	var size = "";
	if (sizeType == 0)
		{
		size = "google_ad_width = 468;\n";
		size += "google_ad_height = 60;\n";
		size += "google_ad_format = '468x60_as';\n";
		}	
	else
		{
		size = "google_ad_width = 160;\n";
		size = "google_ad_height = 600;\n";
		size = "google_ad_format = '160x600_as';\n";
		}
	
	document.write('<script type="text/javascript"><!--\n');
	document.write('google_ad_client = "pub-6717843455019075";\n');
	document.write(size);
	document.write(channel);
	document.write('google_color_link = "0000CC";\n');
	document.write('google_color_url = "008000";\n');
	document.write('google_color_text = "000000";\n');
	document.write('//--></script>\n');
	document.write('<script type="text/javascript"\n');
	document.write('src="http://pagead2.googlesyndication.com/pagead/show_ads.js">\n');
	document.write('</script>');
}

function changeVisible(name)
{
	var element=document.getElementById(name);
	if (element)
	{
	 	if (element.style.display=='none' || element.style.display=='')
			element.style.display='block';
		else element.style.display='none';
	}
}

function EmailUs()
{
var myEmail = "comments";
myEmail += "@";
myEmail += "leakybagel.com";
if (confirm("Would you like to send an email to " + myEmail + " (Skeletales) with your default mail program?"))
		document.location = "mailto:" + myEmail;
}
		
function WriteEmailAddress() {
var email = "comments";
email += "@";
email += "leakybagel.com";
document.write(email);
}

function WriteEmailAddress1() {
var email = "<a href='mailto:comments";
email += "@";
email += "leakybagel.com'>";
document.write(email);
}

function EmailVerify()
{
	if (document.emailAFriend.recipName.value == ""){
	alert("Please enter your friend's name"); return;}
	var RecipEmail = document.emailAFriend.recipEmail.value;
	if (RecipEmail == "" || (RecipEmail.indexOf("@") == -1)) {
	alert("Please enter a valid email for your friend");
	return; }
	if (document.emailAFriend.senderName.value == ""){
	alert("Please enter your name"); return;}
	var YourEmail = document.emailAFriend.senderEmail.value;
	if (YourEmail=="" || (YourEmail.indexOf("@") == -1)) {
	alert("Please enter a valid email");
	return; }
	document.emailAFriend.submit();
}

function SetEmailMessage(type)
{
var Text = "Hello (Recipient Name), (Your name)";
if (type == "SimAddy")
	Text += " has invited you to check out a free program called SimAddy to use with The Sims and The Sims2! ";
if (type == "HealthyNote")
	Text += " has invited you to check out a free program called HealthyNote to keep a record of your daily nutritional intake! ";
if (type == "AlarmClock")
	Text += " has invited you to check out a free program called AlarmClock in which you can set 3 different alarms and a countdown! ";
if (type == "WordGame")
	Text += " has invited you to check out a free program called WordGame in which you make guesses to decrypt a phrase! ";

Text += "There are also other great software programs at LeakyBagel.com!";
Text += " Check out screenshots and a description of this FREE software!";
Text += "(Link to "+type+" page)";
//return Text;
document.emailAFriend.textarea1.value = Text;
}

function submitSignUp()
{
var username = document.signup.username.value;
var email = document.signup.email.value;
var email2 = document.signup.email2.value;
if (username=="" || username.length < 6) {
alert("You must enter a username of 6 or more characters!");
return false;}
if ( username.length > 17) {
alert("You must enter a username of less than 18 characters!");
return false;}
if (email=="" || email2 =="" || email.length < 4) {
alert("Please enter a valid email and verify it so we can reach you and send a temporary password to you.");
return false;}
if (email != email2) {
alert("Your 2 email addresses do not match.");
return false;}
if (email.indexOf("@") == -1){
alert("Email addresses must have an @ in them.");
return false;
}
return true;
}

function submitLogIn() {
var username = document.signin.username.value;
var pass = document.signin.pass.value;
if ((username == "") || (pass==""))
{
	alert("One or more fields are blank");
  	document.signin.username.focus();
	return false;
}
	else {
	//document.signin.browserIE.value = IsIE();
	return true;
	}
}

function submitForgotPass() {
var username= document.forgotPass.username.value;
var email = document.forgotPass.email1.value;
if (username=="" || email == ""){
	alert("Please fill in both fields.");
	return false;}
if (email.indexOf("@") == -1){
alert("Email addresses must have an @ in them.");
return false;}
return true;
}

function submitInfoChange() {
var pass = document.editInfo.newPass1.value;
var pass2 = document.editInfo.newPass2.value;
var email = document.editInfo.email.value;
if (pass != pass2){
alert("Your two passwords do not match.");
return false;}
if (pass.length != "" && pass.length < 4){
alert("Please enter a password of more than 4 characters.");
return false;}
if (pass.length != "" && pass.length > 10){
alert("Please enter a password of less than 11 characters.");
return false;}
if (email=="") {
alert("Please enter a valid email so we can reach you");
return false;}
if (email.indexOf("@") == -1){
alert("Email addresses must have an @ in them.");
return false;}
return true;
}

/*
function submitFilledOutForm(numFields) {
var index = 1;
for (index; index <= numFields; index++)
	{
	var fieldName = "field"+index;
	var field = document.fillout[fieldName].value;
	if (field == "")
		{
		alert("Please fill out all fields before submitting!");
		return false;
		}
	}
return true;
}

function DoOperationOnSkele(SkelId, SkelTitle, Mode) {
//MODE = 0 for EDIT, MODE= 1 for DELETE
	if (Mode == 1) //DELETE
	{
	if (confirm('Are you SURE you want to delete the Skeletale "'+SkelTitle+'"?!?'))
		{
		//window.location= "skel_account.php?Operation=delete&ID="+SkelId;
		document.skelOps.TypeField.value = 1;
		document.skelOps.SkelIdField.value = SkelId;
		document.skelOps.submit();
		}
	}
	else //EDIT
		{
		document.skelOps.TypeField.value = 0;
		document.skelOps.SkelIdField.value = SkelId;
		document.skelOps.submit();
		}
}

//CREATE A SKELETALE FORM STUFF
function insertAtCursor(myField, myValue) {
	//IE support
	if (document.selection) {
	myField.focus();
	sel = document.selection.createRange();
	sel.text = myValue;
	}
//MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == '0') 
    	{
    	var startPos = myField.selectionStart;
    	var endPos = myField.selectionEnd;
    	myField.value = myField.value.substring(0, startPos)
    	+ myValue + ' '
    	+ myField.value.substring(endPos, myField.value.length);
    	} 
	else 
   	 	{
    	myField.value += myValue;
    	}
	myField.focus();
	CheckFormLength(myField);
}

function CheckFormLength(myField)
{
//alert('Hello');
var count = myField.value.length;
//alert(count);
document.createForm.charCount.value = count;
if (myField.value.length >= 2000)
	{
	alert('You have reached the maximum number of characters.');
	return false;
	}
return true;
}

function CheckCreateForm()
{
	var theTitle = document.createForm.title.value.length;
	if (theTitle < 3 || theTitle > 30)
	{
		alert('Please enter a title from 3 to 30 characters.');
		return false;
	}
	var theCount = document.createForm.thetext.value.length;
	if (theCount < 10 || theCount > 2000)
	{
		alert('Please enter 10 to 2000 characters for your skeletale.');
		return false;
	}

	return true;
}

function OpenCategoryHelp()
{
if (new_win1)
	new_win1.focus();
else
	var new_win1 = window.open('catExp.html', 'catWin', 'scrollbars,width=500,height=500');
	new_win1.focus();
//new_win.document.writeln("<html>Hello!</html>");

}

function OpenGrammarHelp()
{
if (new_win)
	new_win.focus();
else
	var new_win = window.open('grammarExp.html', 'grammarWin', 'scrollbars,width=500,height=500');
new_win.focus();
//new_win.document.writeln("<html>Hello!</html>");

}

*/