//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;
function Popup(msg) {
	$("#show-name").html(msg);
	loadPopup();
	centerPopup();
}
//loading popup with jQuery magic!
function loadPopup(){
//loads popup only if it is disabled
	if(popupStatus==0) {
		$("#backgroundPopup").css({"opacity": "0.7"});
		$("#backgroundPopup").fadeIn("slow");
		$("#popup").fadeIn("slow");
		$("#floatdiv").css({zIndex:-1});
		popupStatus = 1;
	}
}
//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popup").fadeOut("slow");
		popupStatus = 0;
		$("#floatdiv").css({zIndex:0});
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var popup = $("#popup");
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var scroll = 0;
	if($.browser.msie)
		scroll = document.body.parentNode.scrollTop;
	else
		var scroll = window.scrollY;
	var popupHeight = popup.height();
	var popupWidth = popup.width();
	//centering
	var left = windowWidth/2-popupWidth/2;
	var top = (windowHeight/2-popupHeight/2) + scroll;
	popup.css({
		"position": "absolute",
		"top": top,
		"left": left});
	//only need force for IE6
	$("#backgroundPopup").css({	"height": windowHeight});
}

$(document).ready(function(){
//following code will be here
	//LOADING POPUP
	//Click the button event!
	$("#button").click(function(){//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
		//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});


//  Developed by Roshan Bhattarai 
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use

function PopupMessage(id,msg){
    //getting height and width of the message box
    var obj = $("#" + id);
    var popup = $('#popup_message');
    popup.html(msg);
    var height = popup.height();
    var width = popup.width();
    //calculating offset for displaying popup message
    var leftVal=obj.offset().left+(width/3)+"px";
    var topVal=obj.offset().top+(height/3)+"px"; 
    popup.css({left:leftVal,top:topVal}).show(100);
    //show the popup message and hide with fading effect
}

 function PopupMessageClose() {
	var popup = $('#popup_message');
 	popup.fadeOut(1500);
}


