var xmlHttp

$(document).ready(function(){
	$("#contactLink").click(function(){
		if ($("#contactForm").is(":hidden")){
			$("#contactForm").slideDown("slow");
		}
		else{
			$("#contactForm").slideUp("slow");
		}
	});

});

function closeForm(a){
	if (a) {
		$("#contactForm").slideUp("slow");
	} else {
		$("#messageSent").show("slow");
		setTimeout('$("#messageSent").hide();$("#contactForm").slideUp("slow")', 2000);
	}
}
function refer() {
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	}
	var msg=escape(document.refer.message.value)
	var url="http://www.infinitewebprojects.com/refer.php"
	url=url+"?email="+document.refer.email.value+"&remail="+document.refer.remail.value+"&message="+msg
	function stateChanged() {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
			document.getElementById("messageSent").innerHTML=xmlHttp.responseText
			if(xmlHttp.responseText=="Your message has been sent successfully!") closeForm()
		}
	}
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function GetXmlHttpObject() {
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		//Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function windowHeight() {
	var myHeight = 0;

	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}

	return myHeight;
}
function windowWidth() {
	var myWidth = 0;

	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}

	return myWidth;
}

function fixPortfolioPageHeight() {
	var thisWindowHeight = windowHeight();
	
	var contentDiv = document.getElementById("content");
	
	if (contentDiv) {
		contentDiv.style.height = (thisWindowHeight-52)+"px";
	}
	
}
