// JavaScript Document
function lit(id){
	var theId = document.getElementById(id);
	if(theId.className == "formField"){ theId.className = "formFieldFocus"; } else { theId.className = "formField"; }
}

function trimString (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function formatPhone(type) {
	switch(type) {
		case "1":
		if(document.getElementById("txtPhone1").value.length == 3){ document.getElementById("txtPhone2").focus() }
		break;
		case "2": 
		if(document.getElementById("txtPhone2").value.length == 3){ document.getElementById("txtPhone3").focus() }
		break;
	}
}

function enableSubmit() {
	var s = document.getElementById("btnSubmit");
	if(s.disabled == "") {s.disabled = "disabled"; } else {s.disabled = "";}
}

function checkDeclaration() {
	var s = document.getElementById("notagree");
	if( document.getElementById("notagree").checked ) {
		if(confirm("You have chosen to not to agree to the application terms.\nClick OK to return to Tom Lee Music main page or cancel to return to application form.")){
			window.location.href = 'http://www.tomleemusic.ca/';
			return false;
		} else {
			return false;
		}
	}
	return true;
}

function checkEmail(form, ctrl, value) {
	if (value == "" || value.indexOf ('@', 1) == -1 || value.indexOf ('.', 3) == -1) {
		return (false);
	} else {
		return (true);
	} 
}

var popUpWin = 0;
function popUpWindow(URLStr, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 	'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height);
}

function showHide(id,s) {
	var l = document.getElementById(id);
	var ls = document.getElementById(s);
	if (l.style.display == 'none') {
		l.style.display = "";
		ls.innerHTML = "[-]";
	} else {
		l.style.display = "none";
		ls.innerHTML = "[+]";		
	}
}

function printthis(){
	document.getElementById("Print").style.display = "none";
	window.print();
	setTimeout('document.getElementById("Print").style.display = ""',1000);
}
