var ie = false;
var version = 7;
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

function qqValidate(){
	var errors = false;
	var inF = document.getElementById('quick-name');
	if(inF.value == '' || inF.value == 'Your Name'){
		inF.className = 'quick-text-failed';
		errors = true;
	} else {
		inF.className = 'quick-text';
	}
	inF = document.getElementById('quick-number');
	if(inF.value == '' || inF.value == 'Phone Number'){
		inF.className = 'quick-text-failed';
		errors = true;
	} else {
		inF.className = 'quick-text';
	}
	inF = document.getElementById('quick-email');
	if(inF.value == '' || inF.value == 'Email Address' || (inF.value.indexOf('@') < 0) || ((inF.value.charAt(inF.value.length-4) != '.') && (inF.value.charAt(inF.value.length-3) != '.'))){
		inF.className = 'quick-text-failed';
		errors = true;
	} else {
		inF.className = 'quick-text';
	}
	inF = document.getElementById('quick-details');
	if(inF.value == '' || inF.value == 'Details'){
		inF.parentNode.className = 'failed';
		errors = true;
	} else {
		inF.parentNode.className = '';
	}
	if(errors){
		return false;
	} else {
		return true;
	}
}

function qqField(field, type){
	var inF = document.getElementById(field);
	if(inF.value == '' && type == 0){
		if(field == 'quick-name'){
			inF.value = 'Your Name';
		} else if(field == 'quick-number'){
			inF.value = 'Phone Number';
		} else if(field == 'quick-email'){
			inF.value = 'Email Address';
		} else if(field == 'quick-details'){
			inF.value = 'Details';
		}
	} else if(type == 1){
		if(inF.value == 'Your Name' || inF.value == 'Phone Number' || inF.value == 'Email Address' || inF.value == 'Details'){
			inF.value = '';
		}
	}
}

// ######################## Javascript Static Tooltips ######################
var jstA = null;	var jstB = null;	var jstC = 2000;	var jstD = 100;	var jstE = null;	var jstF = 0.2;	
function FjstA(){	if(jstA.style.opacity){	jstE = jstA.style.opacity - jstF;	} else {	jstE = 1 - jstF;	}	if(jstE < 0){ jstE = 0; }	jstA.style.opacity = jstE;	jstA.style.filter = "alpha(opacity="+(jstE*100)+")";	if(jstE == 0){	clearTimeout(jstB);	jstB = null;	jstA.style.display = "none";	jstA.style.opacity = 1;	jstA.style.filter = "alpha(opacity=100)";	}	}
function FjstB(){	if(jstA){	jstB = setInterval("FjstA()", jstD);	}	return false;	}
function FjstC(jstG){	if(!jstG) return;	
jstA = document.getElementById(jstG.id+'-tooltip');	
if(ie && version == 6){
	// ie 6 fix
	jstA.style.bottom = null;
	jstA.style.width = (jstA.offsetWidth)+"px";	
	jstA.style.height = (jstA.offsetHeight)+"px";
	jstA.style.top = "-"+(jstA.offsetHeight-(jstA.offsetHeight*0.2))+"px";
}
jstA.style.display = "none";	
jstG.appendChild(jstA);	
jstA.style.position = "absolute";		jstG.onmouseover = function(ev){	if(jstB){ clearTimeout(jstB);	jstB = null; }	if(jstA && jstA.id != (this.id+'-tooltip')){			jstA.style.display = "none";	jstA.style.opacity = 1;	jstA.style.filter = "alpha(opacity=100)";	jstA = null;	}	jstA = document.getElementById(this.id+'-tooltip');	jstA.style.opacity = 1;	jstA.style.filter = "alpha(opacity=100)";	jstA.style.display = 'block';	return false;	};	jstG.onmouseout = function(ev){	if(jstA && jstB == null){ 	jstB = setTimeout('FjstB()', jstC); 	}	};	jstA.onmouseover = function(ev){	if(jstB){ clearTimeout(jstB);	jstB = null; }	return false;	};	jstA.onmouseout = function(ev){	if(jstA && jstB == null){ 	jstB = setTimeout('FjstB()', jstC); 		}	};	}