//start div popup
var obj_div_erorrs ;
var obj_div_over_erorrs  ;
function popup_div_erorrs(obj_id,erorrs_popup_id,msg,erorrs_popup_title_id,title)
{
	var obj = document.getElementById(obj_id);
	//obj.style.position = "fixed";
	if(obj)
	{
		obj_div_erorrs = document.getElementById(obj_id);
		//title
		var erorrs_popup_title = document.getElementById(erorrs_popup_title_id);
		if(erorrs_popup_title)
		{
			erorrs_popup_title.innerHTML = title;
		}
		//msg
		var obj_erorrs_popup = document.getElementById(erorrs_popup_id);
		if(obj_erorrs_popup)
		{
			obj_erorrs_popup.innerHTML = msg;
		}
		if(obj!=null)
		{
			//set_postion_erorrs(obj);
			//obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';			
	
			set_postion_erorrs(obj);
			if(obj.style.visibility == 'visible')
			{
				//hide the pop up
				obj.style.visibility = 'hidden';
				hideAlertLayerErorrs();
			}
			else
			{
				//show the pop up
				showAlertLayerErorrs();
				obj.style.visibility = 'visible';
				obj.style.zIndex = 1001;			
			}
   			
			Cufon.replace('.fontsize_11, .list_checkbox label, .title td, .search_form a, .fontsize_12, .title_news, .menu a.active, .title_project_detail, .title_off_pro, .title_popup_field_office, .title_contact, .admin, .title_popup, .title_popup_field', { fontFamily: 'Nudista'});
		}
		else
		{
			alert(obj_id + ' popup is null');
		}
	}
	
	return false;
}
function set_postion_erorrs(obj)
{		
	if(obj)
	{
		var div_width = obj.offsetWidth		
		var div_height = obj.offsetHeight;		
	
		var theLeft = 0, theTop =0;
		if(screen.width)
		{		
			var theLeft = 0;
			var theTop = 0;
			var isMozilla = document.getElementById&&!document.all;
			if(isMozilla)
			{
				theLeft = (window.innerWidth - div_width) / 2;;
				theTop = (window.innerHeight - div_height) / 4;	
			}
			else
			{
				theLeft = (document.body.offsetWidth - div_width) / 2;
				theTop = (document.body.offsetHeight - div_height) / 4;	
			}
			
		}
		if (theLeft < 0) theLeft = 0;
		if (theTop < 0) theTop = 0;	
		//theTop = 80;
		obj.style.left = theLeft + 'px' ;
		obj.style.top = theTop+ $().scrollTop() + 'px' ;	
	}
}
function popup_postion_div_errors(obj_id, theLeft, theTop)
{
	var obj = document.getElementById(obj_id);
	if(obj!=null)
	{
		if(theLeft > 0 && theTop > 0)
		{
			obj.style.left = theLeft + 'px' ;
			obj.style.top = theTop + 'px' ;	
		}
		obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';			
	}
	else
	{
		alert(obj_id + ' popup is null');
	}
	return false;
}

//start popup window
function OpenBoxErrors(winWidth, winHeight, fileSrc, scrollbars)
{		
	if(screen.width)
	{
		var winl = (screen.width - winWidth) / 2;
		var wint = (screen.height - winHeight) / 2;
	}
	else
	{
		winl = 0; wint =0;
	}
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;	
	var props = 'top='+wint+',left='+winl+',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars='+scrollbars+',resizable=no,width='+winWidth+',height='+ winHeight;		
	window.open(fileSrc, 'FullScreen', props);			
}
function getPageSizeErrors()
{
	//alert(document.body.scrollLeft);
	arrayPageSize = new Array(document.body.clientWidth+document.body.scrollLeft,document.body.clientHeight+$().scrollTop()) 
	return arrayPageSize;
}

function showAlertLayerErorrs()
{
	var arrayPageSize = getPageSizeErrors();

	// setup the dividers
	var BodyObject = document.getElementsByTagName("body").item(0);	

	// setup bg alert layer	
	var OverlayObject = document.getElementById('da_overlay_erorrs');
	if (!OverlayObject)
		OverlayObject = document.createElement("div");
	obj_div_over_erorrs = OverlayObject;
	OverlayObject.setAttribute('id','da_overlay_erorrs');
	OverlayObject.style.width = arrayPageSize[0] + "px";
	OverlayObject.style.height = (arrayPageSize[1]) + 'px';
	OverlayObject.style.left = '0px';
	OverlayObject.style.top = '0px';
	OverlayObject.style.position = "absolute";
	OverlayObject.style.backgroundColor = "#ffffff";
	//OverlayObject.style.backgroundColor = "#000000";
	OverlayObject.style.zIndex = 1000;
	OverlayObject.style.filter = "alpha(opacity=65)";
	OverlayObject.style.mozOpacity = ".65";
	OverlayObject.style.opacity = ".65";
	OverlayObject.style.display = "block";

	// setup content alert layer
	
	BodyObject.appendChild(OverlayObject);
	
}		

function hideAlertLayerErorrs()
{
	var OverlayObject = document.getElementById('da_overlay_erorrs');
	if(OverlayObject)
	{
		OverlayObject.style.width = "0px";
		OverlayObject.style.height = "0px";
		OverlayObject.style.left = '0px';
		OverlayObject.style.top = '0px';
		OverlayObject.style.backgroundColor = "#000000";
		OverlayObject.style.zindex = "0";
		OverlayObject.style.filter = "alpha(opacity=0)";
		OverlayObject.style.mozOpacity = ".0";
		OverlayObject.style.opacity = ".0";
		OverlayObject.style.display = "none";
	}
}


