// Javascript File

// Generic Get Object

function getObject(objName){
	if(document.getElementById(objName)){return document.getElementById(objName)}
	else{return null}
}

// Browser Check

function browserType(){
	var browser = navigator.appName;
	
	if(browser == "Netscape"){browser = "OTHER"}
	if(browser == "Microsoft Internet Explorer"){browser = "IE"}
	
	return browser;
}

// Event Functions

function inputChangeColor(evt){
	var obj = nodeType(evt, "INPUT");
	var onOffSwitch = obj.className;
	
	if(onOffSwitch == "red_button"){obj.className = "red_button active"}
	else{obj.className = "red_button"}
}

// Event Listeners

function evtLits(elementID){
	var inputObj = getObject(elementID);
	if(inputObj != null){
		var currentBrowser = browserType();
		if(currentBrowser == "OTHER"){
			inputObj.addEventListener("mouseover", inputChangeColor, true);
			inputObj.addEventListener("mouseout", inputChangeColor, true);
		}
		else if(currentBrowser = "IE"){
			inputObj.attachEvent("onmouseover", inputChangeColor);
			inputObj.attachEvent("onmouseout", inputChangeColor);
		}
	}
	else{alert("incorrect HTML element ID")}
}

function evtLitsConst(){
	var inputObj = getObject("submit_keyword");
	if(inputObj != null){
		var currentBrowser = browserType();
		if(currentBrowser == "OTHER"){
			inputObj.addEventListener("mouseover", inputChangeColor, true);
			inputObj.addEventListener("mouseout", inputChangeColor, true);
		}
		else if(currentBrowser = "IE"){
			inputObj.attachEvent("onmouseover", inputChangeColor);
			inputObj.attachEvent("onmouseout", inputChangeColor);
		}
	}
	else{alert("incorrect HTML element ID")}
}

function evtLitsEnq(){
	var inputObj = getObject("submit_keyword_enq");
	if(inputObj != null){
		var currentBrowser = browserType();
		if(currentBrowser == "OTHER"){
			inputObj.addEventListener("mouseover", inputChangeColor, true);
			inputObj.addEventListener("mouseout", inputChangeColor, true);
		}
		else if(currentBrowser = "IE"){
			inputObj.attachEvent("onmouseover", inputChangeColor);
			inputObj.attachEvent("onmouseout", inputChangeColor);
		}
	}
	else{alert("incorrect HTML element ID")}
}




function evtLitsHols(){
	var inputObj = getObject("submit_holiday");
	if(inputObj != null){
		var currentBrowser = browserType();
		if(currentBrowser == "OTHER"){
			inputObj.addEventListener("mouseover", inputChangeColor, true);
			inputObj.addEventListener("mouseout", inputChangeColor, true);
		}
		else if(currentBrowser = "IE"){
			inputObj.attachEvent("onmouseover", inputChangeColor);
			inputObj.attachEvent("onmouseout", inputChangeColor);
		}
	}
	else{alert("incorrect HTML element ID")}
}

function evtLitsSearch(){
	var inputObj = getObject("submit_search");
	if(inputObj != null){
		var currentBrowser = browserType();
		if(currentBrowser == "OTHER"){
			inputObj.addEventListener("mouseover", inputChangeColor, true);
			inputObj.addEventListener("mouseout", inputChangeColor, true);
		}
		else if(currentBrowser = "IE"){
			inputObj.attachEvent("onmouseover", inputChangeColor);
			inputObj.attachEvent("onmouseout", inputChangeColor);
		}
	}
	//else{alert("incorrect HTML element ID")}
}

// Input Node Finder

function nodeType(evt, type){
	var node = "";
	var currentBrowser = browserType();
	
	if(currentBrowser == "OTHER"){node = evt.target}
	else if(currentBrowser == "IE"){node = evt.srcElement}
	
	while(node){
		if(node.nodeType == 1 && node.nodeName == type){return node}
		node = node.parentNode;
	}
	
	return null;
}

// End of Javascript File