 //SETTING UP OUR POPUP  
 //0 means disabled; 1 means enabled;  
 var popupStatus = 0;
 var msgPopupStatus =0;
 var callBack		 = '';
//loading popup with jQuery magic!  
function loadPopup(val, callBackFn){  
	
	callBack = callBackFn ? callBackFn : null;
	
 //loads popup only if it is disabled
 //if(val =="add_new_customer") {
 popup ="#"+val;
 var backgroundPopup ="#backgroundPopup";	
 	 
 if(popupStatus==0 || popupStatus == 1){
	 
	 if(val !="advert_search_company") {
		 var opacity;
		 if(val =='G_LOADING') {
			  opacity ="0.0";
		 }
		 else {
			 	opacity ="0.3";
		 }
		 $(backgroundPopup).css({  
			"opacity": opacity  
		 });  
		 $(backgroundPopup).fadeIn("slow");
	 }
	 else {
		 document.advert_search_company.reset();
	 }
	 $(popup).fadeIn("slow");  
	 popupStatus = 1;  
 }

 centerPopup(val);
} 

//disabling popup with jQuery magic!  
function disablePopup(){  

	try {

		$("#backgroundPopup").fadeOut("slow");
		$("#_USR_MSG").fadeOut("slow");
		
	} catch (e) {
		// do nothing --------------/
	}  
}      //disabling popup with jQuery magic!  

 //centering popup  
function centerPopup(val){
	
		var popup ="#"+val;  
    //request data for centering  
   var windowWidth = document.documentElement.clientWidth;
   //alert(windowWidth);
   var windowHeight = document.documentElement.clientHeight;
   //alert(windowHeight);
   
   var popupHeight = $(popup).height();  
   var popupWidth = $(popup).width();
    //alert(popupHeight);
	//alert(popupWidth);
		
	
	if(popupHeight < 1) {
		var top = 300;
	} else {
		var top = windowHeight/2-popupHeight/2;
	}
	
	if (window.pageYOffset)
		var sTop = window.pageYOffset;
	else
		var sTop =(document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
		
	top	= top+sTop;

   //centering  
   $(popup).css({  
   "position": "absolute",  
   "top": top,
   "left": (windowWidth/2-popupWidth/2)-85 
   });  
   //only need force for IE6  
     
  $("#backgroundPopup").css({  
  "height": windowHeight  
   });  
} 

$(document).ready(function(){  
 //following code will be here
 	//CLOSING POPUP  
	//Click the x event!  
	
}); 
 

//This function is to show and hide success and warning messages
function showHideMessage(act, msg) {
	popup ='show_messages';
	//var popup =popup;
	if(act =='show') {
		//alert('here1');	
		//if(msgPopupStatus ==0) {
			$("#"+popup).html(msg);
			$("#"+popup).fadeIn("slow");
			centerPopup(popup);
			msgPopupStatus = 1;
			//eval("setTimeout('showHideMessage(\"hide\", "+popup+")',10000);");
			setTimeout("showHideMessage('hide', '"+popup+"')",5000);
		//}
	}
	else if(act =='hide') {
		alert('here too');
		//if(msgPopupStatus ==1) {
			$("#"+popup).fadeOut("slow");
			$("#"+popup).html('');
			msgPopupStatus = 0;
		//}
	}
	
}