var browser = navigator.appName;
var versionInfo = navigator.appVersion;
var versionNum = parseFloat(versionInfo);
var vendor = navigator.vendor;
var IE = "Microsoft Internet Explorer";
var IE6 = "MSIE 6.0";
var IE7 = "MSIE 7.0";
var safari = "Apple Computer, Inc.";
var imagePath = "images/";
var classAttribute = classAttr();   //Get the appropriate class attribute to set. IE and Firefox use different attributes for class in the DOM.

/***** Begin preload images *****/
var origImg = new Array();	//Array of images for rollovers
origImg[0] = '';

var overImg = new Array();	// Array of images to preload
overImg[0] = '';

var preloadFlag = false;
function preloadImages() {
	for (i=0; i<overImg.length; i++) {
		var images = new Array();
		images[i] = new Image();
		images[i].src = imagePath + overImg[i];
	}
	preloadFlag = true;
}
/***** End preload images *****/

/***** Sign Up toggle *****/
function signUpOptions() {
	if($('signUp')) {
			
			
		 if($("#id_using_ti_tech_0:checked").val()) {
			 $('#currently-using-yes').css({"display":"block"});
			 $('#currently-using-no').css({"display":"none"});
		 }
		
		 if($("#id_using_ti_tech_1:checked").val()) {
			 $('#currently-using-yes').css({"display":"none"});
			 $('#currently-using-no').css({"display":"block"});
		 }
	 }
}

function signUpInit(){
	$('#id_using_ti_tech_0').click(function (){signUpOptions()});
	$('#id_using_ti_tech_1').click(function (){signUpOptions()});
}
addEvent(window, 'load', signUpInit); 
addEvent(window, 'load', signUpOptions); 
/***** Sign Up toggle *****/

/***** Begin image rollover funtion *****/
/* Function to initalize rollover */
function initRollovers(){	
	var rollovers = getElementsByClass('rollover',null,null);	//Get elements with a class of "rollover"
	
	if (rollovers.length > 0){		//If there is at least one element with a class "rollover"
		for(var i=0;i<rollovers.length;i++){	//Loop through all elements with class "rollover"
			var classValue = rollovers[i].getAttribute(classAttribute);
			
			if((versionInfo.match(IE6) != null) && (classValue.match('tpng') != null) ){ //If the browser is IE6 and a transparent png				
				addEvent(rollovers[i],'mouseover',rolloverPNG);	//Attach mouseover event
				addEvent(rollovers[i],'mouseout',rolloverPNG);	//Attach mouseout event	
			}
			else {
				addEvent(rollovers[i],'mouseover',rollover);	//Attach mouseover event
				addEvent(rollovers[i],'mouseout',rollover);	//Attach mouseout event
			}
		}		
	}
}

// This function grabs the src attribute and replaces "off" with "on" (for mouseover) or "on" with "off (for mouseout) in the attribute string. KM
function rollover(event) {
	var etype = event.type;
	var imgSrc = getObjectAttribute(this,"src");
	var newImgSrc;
	
	if (etype == 'mouseover'){
	    newImgSrc = imgSrc.replace('off.','on.','gi');
		this.setAttribute('src',newImgSrc);
	}
	
	else if (etype == 'mouseout') {
	    newImgSrc = imgSrc.replace('on.','off.','gi');
		this.setAttribute('src',newImgSrc);
	}
}

// IE 6 transparent PNG rollover function. KM
function rolloverPNG(event) {
	var etype = event.type;
	var imgSrc = getObjectAttribute(this,"name");
	var newImgSrc;
	
	if (etype == 'mouseover'){
	    newImgSrc = imgSrc.replace('off.','on.','gi');
		this.setAttribute('src',newImgSrc);
	}
	
	else if (etype == 'mouseout') {
	    newImgSrc = imgSrc.replace('on.','off.','gi');
		this.setAttribute('src',newImgSrc);
	}
}
/***** End image rollover function *****/

/***** Begin pop up functions *****/
function popWindow(href,title,sb,width,height) {
	window.open(href,title,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+ sb +',resizable=0,width='+ width +',height='+ height +',top=150,left=150');
}
/***** End pop up functions *****/

/***** Begin tab change functions *****/
function initTabbing(){	
	var tabs = getElementsByClass("tab",null,null);	//Get elements with a class of "tab"
	
	if (tabs.length > 0){		//If there is at least one element with a class "tab"
		for(var i=0;i<tabs.length;i++){	//Loop through all elements with class "tab"
			addEvent(tabs[i],"click",tabClick);	//Attach click event
			addEvent(tabs[i],"mouseover",tabHover);	//Attach over event
			addEvent(tabs[i],"mouseout",tabHover);	//Attach out event
		}		
	}
}

function tabClick(event, x){    
    var tabs = getElementsByClass("tab",null,null);	//Get tabs
    var tabSections = getElementsByClass("tab-section",null,null);   //Get tab body sections
    
	
	for(var t=0;t<tabs.length;t++){ //Loop through all tabs
	    var tabObj = tabs[t];
	    var tabSectionObj = tabSections[t];
	    	    
	    if((tabObj == this)||(t==x)){ //Change clicked tab on			//To turn on a section from a link
            tabObj.setAttribute(classAttribute, "tab selected");		//other then from its tab, use
            tabSectionObj.style.display = "block";						//onclick="tabClick('',x)" where x is
	    }																//the section number - BG
	    else {	//Change other tabs off	        
            tabObj.setAttribute(classAttribute, "tab");
            tabSectionObj.style.display = "none";		    
	    }
	}
}

function tabHover(event){ 
    var etype = event.type;
	
	if (this.getAttribute(classAttribute) != "tab selected"){
	    if (etype == "mouseover"){
		    this.setAttribute(classAttribute,"tab hover");
	    }
    	
	    else if (etype == "mouseout") {
		    this.setAttribute(classAttribute,"tab");
	    }
	}
}

/***** End tab change functions *****/