/*-----------------------------------------------------------------------------
Primary Benchmark QA Javascript

version:   1.0
author:    Weston Shaw
e-mail:     info@avallo.com
website:   http://www.avallo.com
-----------------------------------------------------------------------------*/
/*=Image Rollover
-----------------------------------------------------------------------------*/

function navImageChange(){
	if (!document.all && !document.getElementById) return false;
	//get root
	var nav = document.getElementById('nav');
	//define list items
	var services = document.getElementById('services');
	var roi = document.getElementById('roi');
	var about = document.getElementById('about');
	var resources = document.getElementById('resources');
	var delivery = document.getElementById('delivery');
	var news = document.getElementById('news');
	var contact = document.getElementById('contact');
	var qa = document.getElementById('qa');
	//get images
	var image = nav.getElementsByTagName('IMG');
	for (i=0; i<image.length; i++){
	//change iimage and display menu on mouse over
		services.onmouseover = function(){image[0].src=image[0].src.replace("_n","_x"); this.className=" over"; }
		services.onmouseout = function(){image[0].src=image[0].src.replace("_x","_n"); this.className=""; }
		roi.onmouseover = function(){image[1].src=image[1].src.replace("_n","_x"); this.className=" over"; }
		roi.onmouseout = function(){image[1].src=image[1].src.replace("_x","_n"); this.className=""; }
		about.onmouseover = function(){image[2].src=image[2].src.replace("_n","_x"); this.className=" over"; }
		about.onmouseout = function(){image[2].src=image[2].src.replace("_x","_n"); this.className=""; }
		resources.onmouseover = function(){image[3].src=image[3].src.replace("_n","_x"); this.className=" over"; }
		resources.onmouseout = function(){image[3].src=image[3].src.replace("_x","_n"); this.className=""; }
		delivery.onmouseover = function(){image[4].src=image[4].src.replace("_n","_x"); this.className=" over"; }
		delivery.onmouseout = function(){image[4].src=image[4].src.replace("_x","_n"); this.className=""; }
		news.onmouseover = function(){image[5].src=image[5].src.replace("_n","_x"); this.className=" over"; }
		news.onmouseout = function(){image[5].src=image[5].src.replace("_x","_n"); this.className=""; }
		contact.onmouseover = function(){image[6].src=image[6].src.replace("_n","_x"); this.className=" over"; }
		contact.onmouseout = function(){image[6].src=image[6].src.replace("_x","_n"); this.className=""; }
		qa.onmouseover = function(){image[7].src=image[7].src.replace("_n","_x"); this.className=" over"; }
		qa.onmouseout = function(){image[7].src=image[7].src.replace("_x","_n"); this.className=""; }
	}
}

/* =Load Functions
-----------------------------------------------------------------------------*/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(writeFlash);
addLoadEvent(preloader);
addLoadEvent(navImageChange);
addLoadEvent(doNewWin);


/* =preload nav
-----------------------------------------------------------------------------*/
function preloader(){
	// counter
	var i = 0;
	// create object
	imageObj = new Image();
	// set image list
	image = new Array();
	image[0]="images/nav-services_x.gif"
	image[1]="images/nav-roi_x.gif"
	image[2]="images/nav-about_x.gif"
	image[3]="images/nav-resources_x.gif"
	image[4]="images/nav-delivery_x.gif"
	image[5]="images/nav-news_x.gif"
	image[6]="images/nav-contact_x.gif"
	image[7]="images/nav-qa_x.gif"
	// start preloading
	for(i=0; i<image.length; i++){
		imageObj.src=image[i];
	}
}
/* =Open a new window
-----------------------------------------------------------------------------*/
function doNewWin() {
  if (!document.getElementsByTagName) return false;
  var links=document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
	if (links[i].className.match("newwin")) {
    	links[i].onclick=function() {window.open(this.href);return false;
    	}
  	}
  }
}


/* write flash
-----------------------------------------------------------------------------*/
function writeFlash(){
	if(document.getElementById("flash")){
		var flash = document.getElementById("flash");
		var flashContent = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="687" height="240" title="intro">'+
		'<param name="movie" value="intro.swf" />'+
		'<param name="quality" value="high" />'+
		'<param name="wmode" value="transparent" />'+
		'<embed src="intro.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="687" height="240"></embed>'+
		'</object>';
		
		flash.innerHTML=flashContent;
	}
}