/////////////////////////////////////
/// Clear Text Field ///
////////////////////////
function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}
function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}


/////////////////////////////////////
/// Browser Width and Height ///
////////////////////////////////
var myWidth = 0, myHeight = 0;
if( typeof ( window.innerWidth ) == 'number' ) {
	//Non-IE
	myHeight = window.innerHeight;
	myWidth  = window.innerWidth;
} else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myHeight = document.documentElement.clientHeight;
	myWidth  = document.documentElement.clientWidth;
} else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	myHeight = document.body.clientHeight;
	myWidth  = document.body.clientWidth;
}


/////////////////////////////////////
/// Mouse Over ///
//////////////////
function move_in(img_name,img_src){document[img_name].src=img_src;}
function move_out(img_name,img_src){document[img_name].src=img_src;}


/////////////////////////////////////
/// Navigation Bar ///
//////////////////////
function nav(page){window.location=page}


//////////////////////////////////////
///// Dynamic pop_up window ///
///////////////////////////////
function openPictureWindow(source,imageWidth,imageHeight,alt,left,top){
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+50+",top="+50);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title>');
	newWindow.document.write('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0"');
	newWindow.document.write(' onBlur="self.close()">');
	newWindow.document.write('<img src="'+source+'" width='+imageWidth+' height='+imageHeight+' alt="'+alt+'">');
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}


//////////////////////////////////////
///// hidden layer effect ///
/////////////////////////////
function find_obj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=find_obj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function show_hide_layers() { 
  var i,p,v,obj,args=show_hide_layers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=find_obj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


//////////////////////////////////////
///// Validate the contact form ///
///////////////////////////////////
function validate_contact() {
	if(document.contact.name.value == '') {
		alert("Please enter Your Name.");
		document.contact.name.focus();
		return false;
	}
	else if(document.contact.email.value == '') {
		alert("Please enter Your Email Address.");
		document.contact.email.focus();
		return false;
	}
	else if(document.contact.email.value != document.contact.email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi)) {
		alert("Please enter a valid Email address.");
		document.contact.email.focus();
		return false;
	}
	else if(document.contact.number_responce.value == '') {
		alert("Please type number you see to the left.");
		document.contact.number_responce.focus();
		return false;
	}
	else {
		return true;
	}
}