﻿/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR inline
//0 means disabled; 1 means enabled;
var inlineStatus = 0;

//loading inline with jQuery magic!
function loadinline(){
	//loads inline only if it is disabled
	if(inlineStatus==0){
		$("#backgroundinline").css({
			"opacity": "0.7"
		});
		$("#backgroundinline").fadeIn("slow");
		$("#inlineContact").fadeIn("slow");
		inlineStatus = 1;
	}
}

//disabling inline with jQuery magic!
function disableinline(){
	//disables inline only if it is enabled
	if(inlineStatus==1){
		$("#backgroundinline").fadeOut("slow");
		$("#inlineContact").fadeOut("slow");
		inlineStatus = 0;
	}
}

//centering inline
function centerinline(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var inlineHeight = $("#inlineContact").height();
	var inlineWidth = $("#inlineContact").width();
	//centering
/*	$("#inlineContact").css({
		"position": "absolute",
		"top": windowHeight/2-inlineHeight/2,
		"left": windowWidth/2-inlineWidth/2
	});
	//only need force for IE6
	
	$("#backgroundinline").css({
		"height": windowHeight
	});
*/	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING inline
	//Click the button event!
	$("#button").click(function(){
		//centering with css
		centerinline();
		//load inline
		loadinline();
	});
				
	//CLOSING inline
	//Click the x event!
	$("#inlineContactClose").click(function(){
		disableinline();
	});
	//Click out event!
	$("#backgroundinline").click(function(){
		disableinline();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && inlineStatus==1){
			disableinline();
		}
	});

});