function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}
$(document).ready(function() {
	jQuery.fn.centerScreen = function(loaded) {
	  var popup = this
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var scroll = 0;
		if($.browser.msie){
			//alert("document hieght: " + document.documentElement.clientHeight + " scroll top: "+ document.body.parentNode.scrollTop)
			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": ($.browser.msie ? getDocHeight() : windowHeight)});
		  return(this);
	}
	jQuery.fn.loadPopup = function() {
		var a = this;
		var background = $("#backgroundPopup");
		if(background.length == 0){
			background = $("<div id='backgroundPopup'></div>");
			$("body").append(background);
		}
		background.css({"opacity": "0.7","zIndex":1});
		background.fadeIn("slow");
		background.click( function() {
			a.close();
		});
		$("body").append(this);
		this.addClass("jquery-popup");
		this.fadeIn("slow");
		this.css({"zIndex":100,"display":"block"});
		
		
		return(this);
	}
	jQuery.fn.loadAndCenter = function() {
		this.loadPopup();
		this.centerScreen();
		
	}
	jQuery.fn.Popup = function(){
		this.loadAndCenter();
	}
	jQuery.fn.hidePopup = function() {
		$("#backgroundPopup").fadeOut("slow");
		this.fadeOut("slow");
	}
	jQuery.fn.close = function() {
		this.hidePopup();
		
	}
})
//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");
	s
}

$(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);
}



