var vo=false;
var flashi=0;
var flashar = new Array();
var gali=0;
var doplaygal=true;
document.oncontextmenu = function() { return false }
flashar[0]= new Array ('images/stage/9.jpg');
flashar[1]= new Array ('images/stage/1.jpg');
flashar[2]= new Array ('images/stage/2.jpg');
flashar[3]= new Array ('images/stage/3.jpg');
flashar[4]= new Array ('images/stage/4.jpg');
flashar[5]= new Array ('images/stage/5.jpg');
flashar[6]= new Array ('images/stage/6.jpg');
flashar[7]= new Array ('images/stage/7.jpg');
flashar[8]= new Array ('images/stage/8.jpg');
flashar[9]= new Array ('images/stage/10.jpg');
flashar[10]= new Array ('images/stage/11.jpg');
flashar[11]= new Array ('images/stage/12.jpg');
flashar[12]= new Array ('images/stage/13.jpg');
flashar[13]= new Array ('images/stage/14.jpg');
flashar[14]= new Array ('images/stage/15.jpg');
flashar[15]= new Array ('images/stage/16.jpg');
flashar[16]= new Array ('images/stage/17.jpg');
flashar[17]= new Array ('images/stage/18.jpg');
var timertimeout=false;
function OpenWin(url)  {
helpWin = 
window.open(url,'HelpWin','dependent=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=800,screenX=10,screenY=10,Left=10,Top=10');
 helpWin.focus();
};


function clearnav () {
document.getElementById ('HomeNav').style.display='none';
document.getElementById ('AboutNav').style.display='none';
document.getElementById ('ProgramsNav').style.display='none';
document.getElementById ('StudentNav').style.display='none';
document.getElementById ('GalleryNav').style.display='none';
document.getElementById ('RegistrationNav').style.display='none';
}
function showlnav (obj) {
clearnav();
Set_Cookie('menu', obj, '9970', '/', '', '' );
document.getElementById (obj+'Nav').style.display='';
}
function showhome () {
if (timertimeout == true) 
{
clearnav();
timertimeout=false;
Delete_Cookie('menu', '/', '')
document.getElementById ('HomeNav').style.display='';
}
}
function doresthome () {
if (timertimeout==false)
{
restorehome();
timertimeout=true;
}
}
function restorehome() {
// alert (timertimeout);
if (timertimeout == true) 
{
showhome();
}
else {
timerID=setTimeout("restorehome()",30000);
}
}

function flashslide () {
if (Get_Cookie('flashp')){
	flashi=Get_Cookie('flashp');
}
if (flashi >=18) {flashi=0};
document.getElementById ('flash_img').src=flashar[flashi];
flashi++;
Set_Cookie('flashp', flashi, '', '/', '', '' );
timerID=setTimeout("flashslide()",30000);
}
function showflash (fname, fdesc) {
document.getElementById ('flash_img').src=fname;
desc_id = document.getElementById ('flash_desc');
desc_child = desc_id.firstChild;
    if (desc_child)
      desc_id.removeChild(desc_child);
desc_value = document.createTextNode(fdesc);
desc_id.appendChild(desc_value);
}

function startup () {
clearnav();
timertimeout=false;
document.getElementById ('HomeNav').style.display='';
}

function AddDash(obj) {
 var tmpV=obj.value;
 var tmpN=obj.name;
 if (tmpV.length == 3 && tmpV.charCodeAt(tmpV.length) != 45 && tmpV.charCodeAt(tmpV.length - 1) != 45)
 {
   obj.value = tmpV+"-";
 }
 if (tmpV.length == 7 && tmpV.charCodeAt(tmpV.length) != 45 && tmpV.charCodeAt(tmpV.length - 1) != 45)
 {
   obj.value = tmpV+"-";
 }
};

function upperCaseFirst(obj) {
 var tmpV=obj.value;
 var tmpN=obj.name;
 if (tmpV.length == 1)
 {
   tmpV=tmpV.toUpperCase();
   obj.value = tmpV;
 }
};

function checkforvals (obj) {
	for (var i =0; i < obj.length; i++)    {
			var tmpV = obj[i].value;
			var tmpN = obj[i].name;
		if ((document.getElementById('calendar').checked==true || document.getElementById('application').checked==true) && tmpN == "Phone" && tmpN == "phone" && tmpV.length >0 )	 {
			for (var ii =0; ii < tmpV.length; ii++)    {
   				var c = tmpV.charCodeAt(ii); 
				//dashes && numbers only
				if ( (c > 57 || c < 48) && c != 45)        
				{
					alert("Allowed text for this field\ndigits 0-9\nPlease Re-enter");
					obj[i].focus();
					return false;
				}
			}
		}
		if ((document.getElementById('calendar').checked==true || document.getElementById('application').checked==true) && tmpN == "Phone" && tmpV.length < 12 ){
			alert("Please Complete The Phone Number With Area Code");
			obj[i].focus();
			return false;
		}
		if (tmpV.length == 0 && tmpN !="Phone" && tmpN !="phone" && tmpN !="address" && tmpN !="Country" && tmpN !="city" && tmpN !="postal" && tmpN !="" && tmpN != "Address_Suite" && tmpN != "addressOne"  && tmpN != "addressTwo" && tmpN != "province" && tmpN != "postalCode" && tmpN != "Prov/state" && tmpN != "heardThrough" && tmpN != "customField3" && tmpN != "agreement" && tmpN != "Notes" && tmpN !="Would+Like+Brochure" && tmpN !="Would+Like+Application")	 {
			alert("This field must be filled out the "+ tmpN +".\nPlease Complete");
			obj[i].focus();
			return false;
		}
		if ((document.getElementById('calendar').checked==true || document.getElementById('application').checked==true) && tmpV.length == 0 && (tmpN =="address" || tmpN =="Country" || tmpN =="phone" || tmpN =="city" || tmpN =="postal" || tmpN == "addressOne"  || tmpN == "province" || tmpN == "postalCode" || tmpN == "Prov/state" || tmpN == "customField3")) {
			alert("This field must be filled out the "+ tmpN +".\nPlease Complete");
			obj[i].focus();
			return false;
		}
	}
		isoky = false;
	if (obj["agreement"].checked)	{
		return true;
	}
	else	{
		alert("Please confirm that you want Complections Staff to Contact you!");
		obj["agreement"].focus;
		return false;
	}
} 

function nextgal () {
if (gali >= maxgal-1) {
gali=0;
}
else {
gali++;
}
showflash (document.getElementById ('gal'+gali).src,document.getElementById ('gal'+gali).alt);
}
function backgal () {
if (gali == 0) {
gali=maxgal-1;
}
else {
gali--;
}
showflash (document.getElementById ('gal'+gali).src,document.getElementById ('gal'+gali).alt);
}
function playgal () {
if (doplaygal == true) {
nextgal();
galtimerID=setTimeout("playgal()",10000);
}
}
function pausegal() {
	if (doplaygal ==true) {
		doplaygal=false;
	}
	else {
		doplaygal=true;
		playgal();
	}
}

function clearmovie (obj){
if (obj.checked==false) {
Set_Cookie('movie', 'no', '9999', '/', '', '' );
}
else {
Set_Cookie('movie', 'yes', '9999', '/', '', '' );
}
}

function showvid () {
	if (Get_Cookie('movie') !='no') {
		Videobox.open('http://test.affordhost.com/complections/complectionspromolg.swf','<input type=checkbox checked onclick=\'clearmovie(this)\;\'> Show movie next time I view this site','vidbox 952 536');
	}
}
function showvideo (vid) {
Videobox.open(vid,'','vidbox 952 536');
}
function Vidclose () {
Videobox.close();
if (vo==true) {
	vo=false;
}
else {
timerID=setTimeout("Vidclose()",1000);
	vo=true;
}
}
