/********************************************************************************************
newUserValidate2:		validates a new user entry form
version added by pixsoul
returns:	true if all field entries are correct, false otherwise
********************************************************************************************/
function newUserValidate2() {
	var errMsg = "";
	
	if (document.addUser.firstName.value.length == 0) {
		errMsg			+= "You must provide your first name.\r\n"
		//document.getElementById("firstName").style.backgroundColor	= "#990000";
	}
	else {
		
	}
	
	if (document.addUser.lastName.value.length == 0) {
		errMsg			+= "You must provide your last name.\r\n"
		//document.getElementById("lastName").style.backgroundColor	= "#990000";
	}
	else {
		
	}
	
	if (document.addUser.address.value.length == 0) {
		errMsg			+= "You must provide your address.\r\n"
		//document.getElementById("address").style.backgroundColor	= "#990000";
	}
	else {
		//document.getElementById("address").style.backgroundColor	= "#662d91";
	}
	
	if (document.addUser.city.value.length == 0) {
		errMsg			+= "You must provide your city.\r\n"
		//document.getElementById("city").style.backgroundColor	 	= "#990000";
	}
	
	if (document.addUser.state.selectedIndex == 0) {
		errMsg			+= "You must select your state or province.\r\n"
		//document.getElementById("city").style.backgroundColor 		= "#990000";
	}
	
	if (document.addUser.postalCode.value.length == 0) {
		errMsg			+= "You must provide your postal code.\r\n"
		//document.getElementById("city").style.backgroundColor	 	= "#990000";
	}
	
	if  ((document.addUser.city.value.length > 0) && (document.addUser.state.selectedIndex > 0) && (document.addUser.postalCode.value.length > 0)){
		//document.getElementById("city").style.backgroundColor 		= "#662d91";
	}
	
	if (document.addUser.country.selectedIndex == 0) {
		errMsg			+= "You must select your country.\r\n"
		//document.getElementById("country").style.backgroundColor 	= "#990000";
	}
	else {
		//document.getElementById("country").style.backgroundColor	= "#662d91";
	}
	
	if (document.addUser.email.value.length == 0) {
		errMsg			+= "You must provide your email address.\r\n"
		//document.getElementById("email").style.backgroundColor	 	= "#990000";
	}
	else {
		var filter=/^.+@.+\..{2,3}$/;
		if (filter.test(document.addUser.email.value)) {
			//document.getElementById("email").style.backgroundColor 	= "#662d91";
		}
		else {
			errMsg			+= "You must provide a valid email address.\r\n"
			//document.getElementById("email").style.backgroundColor	= "#990000";
		}
	}
	
	if (document.addUser.mobile.value.length != 13) {
		errMsg			+= "You must supply a valid Mobile Phone Number beginning with your area code.\r\n"
		//document.getElementById("mobile").style.backgroundColor 	= "#990000";
	}
	else {
		//document.getElementById("mobile").style.backgroundColor 	= "#662d91";
	}
	
	if (document.addUser.password1.value.length < 3) {
		errMsg			+= "You must provide a password of at least 3 alphanumeric characters.\r\n"
		//document.getElementById("password1").style.backgroundColor 	= "#990000";
	}
	else {
		//document.getElementById("password1").style.backgroundColor 	= "#662d91";
	}
	
	if (document.addUser.password1.value != document.addUser.password1.value) {
		errMsg			+= "Your passwords do not match.\r\n"
		//document.getElementById("password1").style.backgroundColor 	= "#990000";
		//document.getElementById("password2").style.backgroundColor 	= "#990000";
	}
	else {
		//document.getElementById("password1").style.backgroundColor 	= "#662d91";
		//document.getElementById("password2").style.backgroundColor 	= "#662d91";
	}
	
	if (document.addUser.policies.checked == false) {
		errMsg			+= "You must agree to the terms of use and privacy policy.\r\n"
		//document.getElementById("policy").style.backgroundColor 	= "#990000";
	}
	else {
		//document.getElementById("policy").style.backgroundColor 	= "#662d91";
	}
	
	if (errMsg == "")
		return true;
	else {
		alert (errMsg);
		return false;
	}
}

/********************************************************************************************
newUserValidate:		validates a new user entry form

returns:	true if all field entries are correct, false otherwise
********************************************************************************************/
function newUserValidate() {
	var errMsg = "";
	
	if (document.addUser.firstName.value.length == 0) {
		errMsg			+= "You must provide your first name.\r\n"
		document.getElementById("name").style.backgroundColor	 	= "#990000";
	}
	else {
		document.getElementById("name").style.backgroundColor 		= "#662d91";
	}
	
	if (document.addUser.lastName.value.length == 0) {
		errMsg			+= "You must provide your last name.\r\n"
		document.getElementById("name").style.backgroundColor	 	= "#990000";
	}
	else {
		document.getElementById("name").style.backgroundColor 		= "#662d91";
	}
	
	if ((document.addUser.keyword.value.length < 2) || (document.addUser.keyword.value.length > 15)) {
		errMsg			+= "You must provide a keyword that is between 2-15 alpha-numeric characters.\r\n"
		document.getElementById("key").style.backgroundColor 		= "#990000";
	}
	else {
		document.getElementById("key").style.backgroundColor 		= "#662d91";
	}
	
	if (document.addUser.address.value.length == 0) {
		errMsg			+= "You must provide your address.\r\n"
		document.getElementById("address").style.backgroundColor	= "#990000";
	}
	else {
		document.getElementById("address").style.backgroundColor	= "#662d91";
	}
	
	if (document.addUser.city.value.length == 0) {
		errMsg			+= "You must provide your city.\r\n"
		document.getElementById("city").style.backgroundColor	 	= "#990000";
	}
	
	if (document.addUser.state.selectedIndex == 0) {
		errMsg			+= "You must select your state or province.\r\n"
		document.getElementById("city").style.backgroundColor 		= "#990000";
	}
	
	if (document.addUser.postalCode.value.length == 0) {
		errMsg			+= "You must provide your postal code.\r\n"
		document.getElementById("city").style.backgroundColor	 	= "#990000";
	}
	
	if  ((document.addUser.city.value.length > 0) && (document.addUser.state.selectedIndex > 0) && (document.addUser.postalCode.value.length > 0)){
		document.getElementById("city").style.backgroundColor 		= "#662d91";
	}
	
	if (document.addUser.country.selectedIndex == 0) {
		errMsg			+= "You must select your country.\r\n"
		document.getElementById("country").style.backgroundColor 	= "#990000";
	}
	else {
		document.getElementById("country").style.backgroundColor	= "#662d91";
	}
	
	if (document.addUser.email.value.length == 0) {
		errMsg			+= "You must provide your email address.\r\n"
		document.getElementById("email").style.backgroundColor	 	= "#990000";
	}
	else {
		var filter=/^.+@.+\..{2,3}$/;
		if (filter.test(document.addUser.email.value)) {
			document.getElementById("email").style.backgroundColor 	= "#662d91";
		}
		else {
			errMsg			+= "You must provide a valid email address.\r\n"
			document.getElementById("email").style.backgroundColor	= "#990000";
		}
	}
	
	if (document.addUser.mobile.value.length != 13) {
		errMsg			+= "You must supply a valid Mobile Phone Number beginning with your area code.\r\n"
		document.getElementById("mobile").style.backgroundColor 	= "#990000";
	}
	else {
		document.getElementById("mobile").style.backgroundColor 	= "#662d91";
	}
	
	if (document.addUser.password1.value.length < 3) {
		errMsg			+= "You must provide a password of at least 3 alphanumeric characters.\r\n"
		document.getElementById("password1").style.backgroundColor 	= "#990000";
	}
	else {
		document.getElementById("password1").style.backgroundColor 	= "#662d91";
	}
	
	if (document.addUser.password1.value != document.addUser.password1.value) {
		errMsg			+= "Your passwords do not match.\r\n"
		document.getElementById("password1").style.backgroundColor 	= "#990000";
		document.getElementById("password2").style.backgroundColor 	= "#990000";
	}
	else {
		document.getElementById("password1").style.backgroundColor 	= "#662d91";
		document.getElementById("password2").style.backgroundColor 	= "#662d91";
	}
	
	if (document.addUser.policies.checked == false) {
		errMsg			+= "You must agree to the terms of use and privacy policy.\r\n"
		document.getElementById("policy").style.backgroundColor 	= "#990000";
	}
	else {
		document.getElementById("policy").style.backgroundColor 	= "#662d91";
	}
	
	if (errMsg == "")
		return true;
	else {
		alert (errMsg);
		return false;
	}
}

/********************************************************************************************
add2cart:		validates a new cart entry form

returns:	true if all field entries are correct, false otherwise
********************************************************************************************/
function add2cart() {
	var errMsg = "";
	
	if ((document.addKeywords.keyword.value.length < 2) || (document.addKeywords.keyword.value.length > 15)) {
		errMsg			+= "You must provide a keyword that is between 2-15 alpha-numeric characters.\r\n";
		document.getElementById("key").style.backgroundColor 		= "#990000";
	}
	else {
		document.getElementById("key").style.backgroundColor 		= "#662d91";
	}
	
	if ((document.addKeywords.product.length) && (document.addKeywords.product.length > 1)) {
		//there's more than 1 plan listed
		prodCheck 			= -1;
		for (i=document.addKeywords.product.length-1; i > -1; i--) {
			if (document.addKeywords.product[i].checked) {
				prodCheck = i; 
				i = -1;
			}
		}
		if (prodCheck == -1) {
			errMsg			+= "You must select a plan. (" + document.addKeywords.product.length+ ")\r\n";
			document.getElementById("plan").style.backgroundColor 		= "#990000";
		}
		else {
			document.getElementById("plan").style.backgroundColor 		= "#662d91";
		}
	}

	if (errMsg == "")
		return true;
	else {
		alert (errMsg);
		return false;
	}
}


/********************************************************************************************
validateLogin:		validates a login attempt

returns:	true if all field entries are correct, false otherwise
********************************************************************************************/
function validateLogin() {
	var errMsg = "";
	
	if (document.login.email.value.length == 0)
		errMsg			+= "You must provide your email address.\r\n"
	else {
		var filter=/^.+@.+\..{2,3}$/;
		if (filter.test(document.login.email.value) === false)
			errMsg			+= "You must provide a valid email address.\r\n"
	}
	
	if (document.login.password.value.length == 0)
		errMsg			+= "You must provide your password.\r\n"
	
	if (errMsg == "")
		return true;
	else {
		alert (errMsg);
		return false;
	}
}



/********************************************************************************************
myMessageValidate:		validates the message manager

returns:	true if all field entries are correct, false otherwise
********************************************************************************************/
function myMessageValidate() {
	var errMsg			= "";
	var counter			= 0;
	var temp, selectCheck;
	
	//a minimum of 2 contact forms must be selected for either free form or contact form
	var i = 1;
	var temp 			= "msgFields" + i;
	
	
	//loop through all the selections to capture at least two 
	for (i=1; i<= 21; i++) {
		temp 			= "msgFields" + i;
		selectCheck		= "document.keyMsg." +temp+ ".selectedIndex";
		if (eval(selectCheck) > 0)
			counter++;
	}
	
	if (counter < 2)
		errMsg			+= "You must provide choose at least two contact data to be included in your message.\r\n"
	
	if (errMsg == "")
		return true;
	else {
		alert (errMsg);
		return false;
	}
}




/********************************************************************************************
chkSchedForm:		validates the submitted schedule form

returns:	true if all field entries are correct, false otherwise
********************************************************************************************/
function chkSchedForm(formName, i) {
	var errMsg		= "";
	
	//must build the form vars
	tmpFormName		= formName + i;
	tmpBegTime		= "begTime" + i;
	tmpEndTime		= "endTime" + i;
	tmpMsg			= "msg" + i;
	
	begTime			= "document." +tmpFormName+ "." +tmpBegTime+ ".value.length";
	endTime			= "document." +tmpFormName+ "." +tmpEndTime+ ".value.length";
	msg				= "document." +tmpFormName+ "." +tmpMsg+ ".value.length";
	
	if (eval(begTime) == 0)
		errMsg		+= "You must provide a Beginning Date.\r\n"
	
	if (eval(endTime) == 0)
		errMsg		+= "You must provide a Ending Date.\r\n"
	
	if (eval(msg) == 0)
		errMsg		+= "You must provide a Message.\r\n"

	if (errMsg == "")
		return true;
	else {
		alert (errMsg);
		return false;
	}
}


/********************************************************************************************
affValidate:		validates a new affiliate entry form

returns:	true if all field entries are correct, false otherwise
********************************************************************************************/
function affValidate() {
	var errMsg = "";
	
	if (document.affiliate.firstName.value.length == 0) {
		errMsg			+= "You must provide your first name.\r\n"
		document.getElementById("name").style.backgroundColor	 	= "#990000";
	}
	else {
		document.getElementById("name").style.backgroundColor 		= "#662d91";
	}
	
	if (document.affiliate.lastName.value.length == 0) {
		errMsg			+= "You must provide your last name.\r\n"
		document.getElementById("name").style.backgroundColor	 	= "#990000";
	}
	else {
		document.getElementById("name").style.backgroundColor 		= "#662d91";
	}
	
	if (document.affiliate.address.value.length == 0) {
		errMsg			+= "You must provide your address.\r\n"
		document.getElementById("address").style.backgroundColor	= "#990000";
	}
	else {
		document.getElementById("address").style.backgroundColor	= "#662d91";
	}
	
	if (document.affiliate.city.value.length == 0) {
		errMsg			+= "You must provide your city.\r\n"
		document.getElementById("city").style.backgroundColor	 	= "#990000";
	}
	
	if (document.affiliate.state.selectedIndex == 0) {
		errMsg			+= "You must select your state or province.\r\n"
		document.getElementById("city").style.backgroundColor 		= "#990000";
	}
	
	if (document.affiliate.postalCode.value.length == 0) {
		errMsg			+= "You must provide your postal code.\r\n"
		document.getElementById("city").style.backgroundColor	 	= "#990000";
	}
	
	if  ((document.affiliate.city.value.length > 0) && (document.affiliate.state.selectedIndex > 0) && (document.affiliate.postalCode.value.length > 0)){
		document.getElementById("city").style.backgroundColor 		= "#662d91";
	}
	
	if (document.affiliate.country.selectedIndex == 0) {
		errMsg			+= "You must select your country.\r\n"
		document.getElementById("country").style.backgroundColor 	= "#990000";
	}
	else {
		document.getElementById("country").style.backgroundColor	= "#662d91";
	}
	
	if (document.affiliate.email.value.length == 0) {
		errMsg			+= "You must provide your email address.\r\n"
		document.getElementById("email").style.backgroundColor	 	= "#990000";
	}
	else {
		var filter=/^.+@.+\..{2,3}$/;
		if (filter.test(document.affiliate.email.value)) {
			document.getElementById("email").style.backgroundColor 	= "#662d91";
		}
		else {
			errMsg			+= "You must provide a valid email address.\r\n"
			document.getElementById("email").style.backgroundColor	= "#990000";
		}
	}
	
	if (document.affiliate.phone.value.length != 13) {
		errMsg			+= "You must supply a valid Phone Number beginning with your area code.\r\n"
		document.getElementById("phone").style.backgroundColor 	= "#990000";
	}
	else {
		document.getElementById("phone").style.backgroundColor 	= "#662d91";
	}
	
	if (document.affiliate.policies.checked == false) {
		errMsg			+= "You must agree to the Affiliate Agreement.\r\n"
		document.getElementById("policy").style.backgroundColor 	= "#990000";
	}
	else {
		document.getElementById("policy").style.backgroundColor 	= "#662d91";
	}
	
	if (errMsg == "")
		return true;
	else {
		alert (errMsg);
		return false;
	}
}



/********************************************************************************************
connectorValidate:		validates a new connector entry form

returns:	true if all field entries are correct, false otherwise
********************************************************************************************/
function connectorValidate() {
	var errMsg = "";
	
	if (document.connector.firstName.value.length == 0) {
		errMsg			+= "You must provide your first name.\r\n"
		document.getElementById("name").style.backgroundColor	 	= "#990000";
	}
	else {
		document.getElementById("name").style.backgroundColor 		= "#662d91";
	}
	
	if (document.connector.lastName.value.length == 0) {
		errMsg			+= "You must provide your last name.\r\n"
		document.getElementById("name").style.backgroundColor	 	= "#990000";
	}
	else {
		document.getElementById("name").style.backgroundColor 		= "#662d91";
	}
	
	if (document.connector.address.value.length == 0) {
		errMsg			+= "You must provide your address.\r\n"
		document.getElementById("address").style.backgroundColor	= "#990000";
	}
	else {
		document.getElementById("address").style.backgroundColor	= "#662d91";
	}
	
	if (document.connector.city.value.length == 0) {
		errMsg			+= "You must provide your city.\r\n"
		document.getElementById("city").style.backgroundColor	 	= "#990000";
	}
	
	if (document.connector.state.selectedIndex == 0) {
		errMsg			+= "You must select your state or province.\r\n"
		document.getElementById("city").style.backgroundColor 		= "#990000";
	}
	
	if (document.connector.postalCode.value.length == 0) {
		errMsg			+= "You must provide your postal code.\r\n"
		document.getElementById("city").style.backgroundColor	 	= "#990000";
	}
	
	if  ((document.connector.city.value.length > 0) && (document.connector.state.selectedIndex > 0) && (document.connector.postalCode.value.length > 0)){
		document.getElementById("city").style.backgroundColor 		= "#662d91";
	}
	
	if (document.connector.country.selectedIndex == 0) {
		errMsg			+= "You must select your country.\r\n"
		document.getElementById("country").style.backgroundColor 	= "#990000";
	}
	else {
		document.getElementById("country").style.backgroundColor	= "#662d91";
	}
	
	if (document.connector.email.value.length == 0) {
		errMsg			+= "You must provide your email address.\r\n"
		document.getElementById("email").style.backgroundColor	 	= "#990000";
	}
	else {
		var filter=/^.+@.+\..{2,3}$/;
		if (filter.test(document.connector.email.value)) {
			document.getElementById("email").style.backgroundColor 	= "#662d91";
		}
		else {
			errMsg			+= "You must provide a valid email address.\r\n"
			document.getElementById("email").style.backgroundColor	= "#990000";
		}
	}
	
	if (document.connector.phone.value.length != 13) {
		errMsg			+= "You must supply a valid Phone Number beginning with your area code.\r\n"
		document.getElementById("phone").style.backgroundColor 	= "#990000";
	}
	else {
		document.getElementById("phone").style.backgroundColor 	= "#662d91";
	}
	
	if (document.connector.connector.checked == false) {
		errMsg			+= "You must agree to the connector Agreement.\r\n"
		document.getElementById("connector").style.backgroundColor 	= "#990000";
	}
	else {
		document.getElementById("connector").style.backgroundColor 	= "#662d91";
	}
	
	if (document.connector.policies.checked == false) {
		errMsg			+= "You must agree to the Affiliate Agreement.\r\n"
		document.getElementById("policy").style.backgroundColor 	= "#990000";
	}
	else {
		document.getElementById("policy").style.backgroundColor 	= "#662d91";
	}
	
	if (errMsg == "")
		return true;
	else {
		alert (errMsg);
		return false;
	}
}


/********************************************************************************************
textCounter:		limits the characters in a textarea

returns:	nothing
********************************************************************************************/
function textCounter(field, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
}




/********************************************************************************************
character counter:		counts the number of characters left in an input field

********************************************************************************************/
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Steve | http://jsmadeeasy.com/ */
function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function toCount(entrance,exit,text,characters) {
  var entranceObj=getObject(entrance);
  var exitObj=getObject(exit);
  var length = characters - strCnt(entranceObj.value);
  
  if(length <= 0) {
    length=0;
    text='<span class="disable"> '+text+' </span>';
    entranceObj.value=entranceObj.value.substr(0,characters);
  }
  exitObj.innerHTML = text.replace("{CHAR}",length);
}




<!-- This script is based on the javascript code of Roman Feldblum (web.developer@programmer.net) -->
<!-- Original script : http://javascript.internet.com/forms/format-phone-number.html -->
<!-- Original script is revised by Eralper Yilmaz (http://www.eralper.com) -->
<!-- Revised script : http://www.kodyaz.com -->

var zChar = new Array(' ', '(', ')', '-', '.');
var maxphonelength = 13;
var phonevalue1;
var phonevalue2;
var cursorposition;

function ParseForNumber1(object){
	phonevalue1 = ParseChar(object.value, zChar);
}
function ParseForNumber2(object){
	phonevalue2 = ParseChar(object.value, zChar);
}

function backspacerUP(object,e) {
	if(e){
		e = e
	} 
	else {
		e = window.event
	}
	if(e.which){
		var keycode = e.which
	} 
	else {
		var keycode = e.keyCode
	}

	ParseForNumber1(object)

	if(keycode >= 48){
		ValidatePhone(object)
	}
}

function backspacerDOWN(object,e) {
	if(e){
		e = e
	} 
	else {
		e = window.event
	}
	if(e.which){
		var keycode = e.which
	} 
	else {
		var keycode = e.keyCode
	}
	ParseForNumber2(object)
}

function GetCursorPosition(){
	var t1 = phonevalue1;
	var t2 = phonevalue2;
	var bool = false
	for (i=0; i<t1.length; i++) {
		if (t1.substring(i,1) != t2.substring(i,1)) {
			if(!bool) {
				cursorposition=i
				bool=true
			}
		}
	}
}

function ValidatePhone(object){
	var p = phonevalue1

	p = p.replace(/[^\d]*/gi,"")
	
	if (p.length < 3) {
		object.value=p
	} 
	else if(p.length==3){
		pp=p;
		d4=p.indexOf('(')
		d5=p.indexOf(')')
		if(d4==-1){
			pp="("+pp;
		}
		if(d5==-1){
			pp=pp+")";
		}
		object.value = pp;
	}
	else if(p.length>3 && p.length < 7){
		p ="(" + p;
		l30=p.length;
		p30=p.substring(0,4);
		p30=p30+")"

		p31=p.substring(4,l30);
		pp=p30+p31;

		object.value = pp;

	} 
	else if(p.length >= 7){
		p ="(" + p;
		l30=p.length;
		p30=p.substring(0,4);
		p30=p30+")"

		p31=p.substring(4,l30);
		pp=p30+p31;

		l40 = pp.length;
		p40 = pp.substring(0,8);
		p40 = p40 + "-"

		p41 = pp.substring(8,l40);
		ppp = p40 + p41;

		object.value = ppp.substring(0, maxphonelength);
	}

	GetCursorPosition()

	if(cursorposition >= 0){
		if (cursorposition == 0) {
			cursorposition = 2
		} 
		else if (cursorposition <= 2) {
			cursorposition = cursorposition + 1
		} 
		else if (cursorposition <= 5) {
			cursorposition = cursorposition + 2
		} 
		else if (cursorposition == 6) {
			cursorposition = cursorposition + 2
		} 
		else if (cursorposition == 7) {
			cursorposition = cursorposition + 4
			e1=object.value.indexOf(')')
			e2=object.value.indexOf('-')
			if (e1>-1 && e2>-1){
				if (e2-e1 == 4) {
					cursorposition = cursorposition - 1
				}
			}
		} 
		else if (cursorposition < 11) {
			cursorposition = cursorposition + 3
		} 
		else if (cursorposition == 11) {
			cursorposition = cursorposition + 1
		} 
		else if (cursorposition >= 12) {
			cursorposition = cursorposition
		}

		var txtRange = object.createTextRange();
		txtRange.moveStart( "character", cursorposition);
		txtRange.moveEnd( "character", cursorposition - object.value.length);
		txtRange.select();
	}

}

function ParseChar(sStr, sChar) {
	if (sChar.length == null) {
		zChar = new Array(sChar);
	}
	else 
		zChar = sChar;

	for (i=0; i<zChar.length; i++) {
		sNewStr = "";

		var iStart = 0;
		var iEnd = sStr.indexOf(sChar[i]);

		while (iEnd != -1) {
			sNewStr += sStr.substring(iStart, iEnd);
			iStart = iEnd + 1;
			iEnd = sStr.indexOf(sChar[i], iStart);
		}
		sNewStr += sStr.substring(sStr.lastIndexOf(sChar[i]) + 1, sStr.length);

		sStr = sNewStr;
	}

	return sNewStr;
}


/********************************************************************************************
Init:		sets initial value of a form

returns:	nothing
********************************************************************************************/
function Init(){
	globalChange	= false;
	var testVar		= document['mobiPlan'].elements;
	for (var i=0;i<testVar.length;i++){
		if (testVar[i].type=='radio'||testVar[i].type=='checkbox'){
			changeCheck(testVar[i],'click',CkChange);
			testVar[i].current		= testVar[i].checked;
		}
	else {
   	changeCheck(testVar[i],'change',CkChange);
   	testVar[i].current			= testVar[i].value;
		}
	}
}


/********************************************************************************************
CkChange:	examines if form elements were changed

returns:	boolean of form change
********************************************************************************************/
function CkChange(){
	if (globalChange === false) {
		var testVar=document['mobiPlan'].elements;
		var change						= false;
		for (var i=0;i<testVar.length;i++){
			if (testVar[i].name != 'pageID') {
			if (testVar[i].type=='radio'||testVar[i].type=='checkbox'){
				if (testVar[i].checked!=testVar[i].current){
					change				= true;
					testVar[i].current=testVar[i].checked;   // only required to check every change
				}
			}
			else if (testVar[i].value!=testVar[i].current){
				testVar[i].current	= testVar[i].value;    // only required to check every change
				change					= true;
			}
			}
		}
		globalChange = change;
		
		if (change) {
			document.getElementById("topChange").innerHTML 					= "Click &quot;Save this configuration&quot; to save your changes before previewing";
			document.getElementById("topChange").style.backgroundColor		= "#ff0000";
			document.getElementById("botChange").innerHTML 					= "Click &quot;Save this configuration&quot; to save your changes before previewing";
			document.getElementById("botChange").style.backgroundColor		= "#ff0000";
		}
	}
	else
		change = globalChange;
	
	return change;	
}


/********************************************************************************************
gotoPage:		jumps to the url listed as the values in a select field

returns:	nothing
********************************************************************************************/
function gotoPage(fromVar){
	var URL 				= fromVar.options[fromVar.selectedIndex].value;
	window.location.href 	= URL;
}