/* GOOGLE ANALYTICS */

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17160871-5']);
_gaq.push(['_trackPageview']);

(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


/* ASK A QUESTION */

window.onload = function() {
	if(!document.getElementById('ask-question')) {
		return;
	}
	var question = document.getElementById('ask-question');
	var email = document.getElementById('question-email');
	var message = document.getElementById('question-message');
	var submit = document.getElementById('question-submit');
	question.style.display = "block";
	submit.style.display = "none";
	email.style.color = "#B1B1B1";
	message.style.color = "#B1B1B1";
	email.onblur = function() {
		if(this.value == '') {
			this.style.color = "#B1B1B1";
			this.value = 'me@email.com';
		}
	}
	email.onfocus = function() {
		if(this.value == 'me@email.com') {
			this.style.color = "#000";
			this.value = '';
			submit.style.display = 'block';
		}
	}
	message.onblur = function() {
		if(this.value == '') {
			this.style.color = "#B1B1B1";
			this.value = 'Ask your question here...';
		}
	}
	message.onfocus = function() {
		if(this.value == 'Ask your question here...') {
			this.style.color = "#000";
			this.value = '';
			submit.style.display = 'block';
		}
	}
}


 /* AJAX URL SUBMIT */

function ajax(type, url, params, id) {
	var ua = navigator.userAgent.toLowerCase();
	if(!window.ActiveXObject) {
		http = new XMLHttpRequest();
	} else if(ua.indexOf('msie 5') == -1) {
		http = new ActiveXObject("Msxml2.XMLHTTP");
	} else {
		http = new ActiveXObject("Microsoft.XMLHTTP");
	}
	http.onreadystatechange = function() {
		if(http.readyState == 4 && http.status == 200) {
			if(document.getElementById(id)) {
				document.getElementById(id).innerHTML = http.responseText;
			}
		}
	}
	http.open(type, url);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.send(params);
}


/* MISC JS FUNCTIONS */

function changeval(id, val) {
	if(val != "") {
		val = "/" + val;
	}
	if(document.getElementById(id)) {
		document.getElementById(id).innerHTML = val;
	}
}

function showdiv(id, action) {
	if(document.getElementById(id)) {
		document.getElementById(id).style.display = action;
	}
}

function togglediv(id) {
	if(document.getElementById(id)) {
		var elem = document.getElementById(id);
		var vis = elem.style;
		if(vis.display == '' && elem.offsetWidth != undefined && elem.offsetHeight != undefined) {
			vis.display = (elem.offsetWidth !=0 && elem.offsetHeight != 0) ? 'block' : 'none';
		}
		vis.display = (vis.display == '' || vis.display == 'block') ? 'none' : 'block';
	}
}

function testimonial(val) {
	next = test_start + val;
	if(next > test_total) {
		next = 0;
	} else if(next < 0) {
		next = test_total;
	}
	document.getElementById('test'+test_start).style.display = "none";
	document.getElementById('test'+next).style.display = "block";
	test_start = next;
}
