var popupStatus = 0;
function loadPopup(){
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#menu").css("z-index","0");
		$("#backgroundPopup").fadeIn("normal");
		$("#popupReport").fadeIn("normal");
		$("#popupConfirm").fadeIn("normal");
		if($.browser.msie && parseInt($.browser.version) <= 7){
			$(".stage").css("position","static");
			$("#menu").css("z-index","1");
			$("#backgroundPopup").css({"width":document.documentElement.clientWidth,
				"height":document.body.clientHeight});
			
		}	 
		popupStatus = 1;
	}
}

function disablePopup(){
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("normal");
		$("#popupReport").fadeOut("normal");
		$("#popupConfirm").fadeOut("normal");
		$("#menu").css("z-index","111111");
		if($.browser.msie && parseInt($.browser.version) <= 7){
			$(".stage").css("position","relative");
		}	 
		popupStatus = 0;
	}
}

function centerPopup(index){
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var repHeight = document.getElementById("button"+index).offsetTop;
	
	if(navigator.appName=="Microsoft Internet Explorer"){
		windowHeight = document.body.clientHeight;
	}
	var popupHeight = $("#popupReport").height();
	var popupWidth = $("#popupReport").width();
	if(navigator.appName=="Microsoft Internet Explorer"){
		popupHeight = popupHeight + 7;
		repHeight = 0;
		repHeight = (600 + 62) + (index * 100);
		}

	$("#popupReport").css({
		"position": "absolute",
		"top": repHeight - 62,
		"left": (windowWidth/2-popupWidth/2)-100,
		"height": popupHeight + 23
	});
	
	$("#backgroundPopup").css({
		"height": windowHeight,
		"width" : windowWidth
	});
	
	$("#popupBtmbrdr").css({
		"top": popupHeight + 47
	});
	$("#popupMidbrdr").css({
		"height": popupHeight + 47
	});
}

$(document).ready(function(){
	$("#popupContactClose").click(function(){
		disablePopup();
	});
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
	$("input.txtBox").mouseover(function(){ $("input.txtBox").addClass("txtBoxHover"); });
	$("input.txtBox").mouseover(function(){ $("input.txtBox").removeClass("txtBoxDefault"); });
	$("input.txtBox").click(function(){ $("input.txtBox").addClass("txtBoxClick"); });
	$("input.txtBox").mouseout(function(){ $("input.txtBox").addClass("txtBoxDefault"); });
	$("input.txtBox").mouseout(function(){ $("input.txtBox").removeClass("txtBoxHover"); });
	$("input.txtBox").click(function(){ $("textarea.txtBox").removeClass("txtBoxClick"); });
	$("textarea.txtBox").click(function(){ $("input.txtBox").removeClass("txtBoxClick"); });
	$("textarea.txtBox").click(function(){ $("textarea.txtBox").addClass("txtBoxClick"); });
	$("textarea.txtBox").mouseover(function(){ $("textarea.txtBox").addClass("txtBoxHover"); });
	$("textarea.txtBox").mouseover(function(){ $("textarea.txtBox").removeClass("txtBoxDefault"); });
	$("textarea.txtBox").mouseout(function(){ $("textarea.txtBox").addClass("txtBoxDefault"); });
	$("textarea.txtBox").mouseout(function(){ $("textarea.txtBox").removeClass("txtBoxHover"); });
});

function changeState(id, enable) {
        $(id).attr('disabled', !enable);
} 
function changeStateb(id, enable) {
        $(id).attr('disabled', enable);
}
