// JavaScript Document
//function clearBox(box) {
	// 	 if(box.value==box.defaultValue) {
	 	// 	 box.value = "";
	 	// }
	 	//}
	//	function checkEnter(box) {
	//if(box.value==="") {
	//	box.value = box.defaultValue;
	//}
//}
		function externalLinks() {
  if (!document.getElementsByTagName) return false;
  var links=document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("external")) {
      links[i].onclick=function() {
      // Next two lines should be on one line
        window.open(this.href, "","toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=800,height=600'");
        return false;
      }
    }
  }
}
window.onload=externalLinks;

function initHighlight() {

    if (!document.getElementsByTagName){ return; }

    var allfields = document.getElementsByTagName("input");



    // loop through all input tags and add events

    for (var i=0; i<allfields.length; i++){

        var field = allfields[i];

        if ((field.getAttribute("type") == "text") || (field.getAttribute("type") == "password") ) {

            field.onfocus = function () {

                this.style.backgroundColor = '#F6D8D8';
          	 	 if(this.value==this.defaultValue) {

          	 	 	 this.value = "";

          	 	 }

            }

            field.onblur = function (){

              this.style.backgroundColor = '#FFF';

            	if(this.value==="") {

            		this.value = this.defaultValue;

            	}

            }

        }

    }

}



// Nifty function to add onload events without overwriting

// ones already there courtesy of the lovely and talented

// Simon Willison http://simon.incutio.com/

function addLoadEvent(func) {   

    var oldonload = window.onload;

    if (typeof window.onload != 'function'){

        window.onload = func;

    } else {

        window.onload = function(){

        oldonload();

        func();

        }

    }

}



addLoadEvent(initHighlight);
		
		function validEmail(email) {
			invalidChars = " /:,;"
	
			if (email == "") {
				return false
			}
			for (i=0; i<invalidChars.length; i++) {
				badChar = invalidChars.charAt(i)
				if (email.indexOf(badChar,0) > -1) {
					return false
				}
			}
			atPos = email.indexOf("@",1)
			if (atPos == -1) {
				return false
			}
			if (email.indexOf("@",atPos+1) > -1) {
				return false
			}
			periodPos = email.indexOf(".",atPos)
			if (periodPos == -1) {
				return false
			}
			if (periodPos+3 > email.length)	{
				return false
			}
			return true
		}
		
		function submitMail(carForm) {
			if (!validEmail(carForm.email.value)) {
				alert("Please enter a valid email address")
				carForm.email.focus()
				carForm.email.select()
				return false
			}
			return true
		}
		
		function submitIt(carForm) {
			if (!validEmail(carForm.email.value ) || carForm.email.value==carForm.email.defaultValue) {
				alert("Please enter a valid email address")
				carForm.email.focus()
				carForm.email.select()
				return false
			}
			if (carForm.name.value=="" || carForm.name.value==carForm.name.defaultValue){
				alert("Please enter you name")
				return false
			}
			if (carForm.subject.value=="" || carForm.subject.value==carForm.subject.defaultValue){
				alert("Please enter a subject for your message")
				return false
			}
	
			return true
		}
		

/*****

Image Cross Fade Redux
Version 1.0
Last revision: 02.15.2006
steve@slayeroffice.com

Please leave this notice intact. 

Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html


*****/


window.addEventListener?window.addEventListener("load",so_init,false):window.attachEvent("onload",so_init);

var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init() {
	if(!d.getElementById || !d.createElement)return;
	
	css = d.createElement("link");
	css.setAttribute("href","http://www.neovirtua.com/includes/xfade2.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	d.getElementsByTagName("head")[0].appendChild(css);
	
	imgs = d.getElementById("bannerContainer").getElementsByTagName("img");
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = "block";
	imgs[0].xOpacity = .99;
	
	setTimeout(so_xfade,5000);
}

function so_xfade() {
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;
	nOpacity = imgs[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;
	
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	
	if(cOpacity<=0) {
		imgs[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,5000);
	} else {
		setTimeout(so_xfade,30);
	}
	
	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
	
}

