var __WindowW=0;
var __WindowH=0;
windowSize();
function Waiting(){
	var __TableWidth=400;
	DefaultWaitMessageContainer=_CreateElement({'Name':'DefaultWaitMessageContainer','TagName':'DIV','StyleName':{'width':__TableWidth}});
	DefaultWaitMessageContainer.style.display='none';	
	var _CurrentOpacity=50;
        var __HTML="";  
            __HTML += "<table style='background-color:#FFFFFF;' align=center cellspacing=1 cellpadding=1 width='"+__TableWidth+"'>";
			__HTML += "<tr><td class='ReservationHeader' style='background-color:#EAEAEA;' align=center valign=middle>CarPort</td></tr>";
			__HTML += "<tr><td class='ReservationHeader' style='color:#000000;' align=center valign=middle>İşleminiz Yapılıyor</td></tr>";
			__HTML += "<tr><td class='ReservationHeader' style='color:#000000;' align=center valign=middle></td></tr>";
			__HTML += "<tr><td class='ReservationHeader' style='color:#000000;' align=center valign=middle>Lütfen Bekleyiniz</td></tr>";
            __HTML += "</table>";	
			
	DefaultWaitMessageContainer.innerHTML=__HTML;
	document.body.appendChild(DefaultWaitMessageContainer);
	
        ModalPopup('DefaultWaitMessageContainer',{
                         BackgroundColor: '#333333',  
                         BackgroundOpacity: _CurrentOpacity,
                         BackgroundCursorStyle: 'pointer',
                         Zindex: 100,
                         AddLeft: 0
        });	
	
	}

function windowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  __WindowW=myWidth;
  __WindowH=myHeight;
}
ModalPopup = function (elem,options) {
	//option default settings
	options = options || {};
	var HasBackground = (options.HasBackground!=null)?options.HasBackground:true;
	var BackgroundColor = options.BackgroundColor || '#000000';
	var BackgroundOpacity = options.BackgroundOpacity || 60; // 1-100
	BackgroundOpacity = (BackgroundOpacity > 0) ? BackgroundOpacity : 1;
	var BackgroundOnClick = options.BackgroundOnClick || function(){};
	var BackgroundCursorStyle = options.BackgroundCursorStyle || "default";
	var Zindex = options.Zindex || 90000;
	var AddLeft = options.AddLeft || 0; //in px
	var AddTop = options.AddTop || 0; //in px
	

	function _Convert(val) {
		if (!val) {return;}
		val = val.replace("px","");
		if (isNaN(val)) {return 0;}
		return parseInt(val);
	}
	var popup = $(elem);
	if (!popup) {return;}
	//set the popup layer styles
	var winW = __WindowW
	var winH = __WindowH
	if(winH==0 && winW==0){
	    windowSize()
	    winH=__WindowH;
	    winW=__WindowW;	    
	}
	//display the popup layer
	popup.style.display = "block";
	popup.style.visibility = "visible";
	var currentStyle;
	if (popup.currentStyle)	{ 
		currentStyle = popup.currentStyle; 
	}
	else if (window.getComputedStyle) {
		currentStyle = document.defaultView.getComputedStyle(popup, null);
	} else {
		currentStyle = popup.style;
	}

	var elemW = popup.offsetWidth -
		_Convert(currentStyle.marginLeft) -
		_Convert(currentStyle.marginRight) -
		_Convert(currentStyle.borderLeftWidth) -
		_Convert(currentStyle.borderRightWidth);

	var elemH = popup.offsetHeight -
		_Convert(currentStyle.marginTop) -
		_Convert(currentStyle.marginBottom) -
		_Convert(currentStyle.borderTopWidth) -
		_Convert(currentStyle.borderBottomWidth);

	popup.style.position = (UsedBrowser.Type==0 && UsedBrowser.Explorer==7)?"fixed":"absolute";
	popup.style.left = (winW/2 - elemW/2 + AddLeft) + "px";	
	popup.style.top = (winH/2 - elemH/2 + AddTop - 10) + "px";
	popup.style.zIndex = Zindex + 1;
	
	if (HasBackground) {		
		if (!ModalPopup._BackgroundDiv) {
			ModalPopup._BackgroundDiv = document.createElement('div');
			ModalPopup._BackgroundDiv.style.display = "none";
			ModalPopup._BackgroundDiv.style.width = "100%";
			ModalPopup._BackgroundDiv.style.position = "absolute";
			ModalPopup._BackgroundDiv.style.top = "0px";
			ModalPopup._BackgroundDiv.style.left = "0px";
			document.body.appendChild(ModalPopup._BackgroundDiv);
		}
		ModalPopup._BackgroundDiv.onclick =  BackgroundOnClick;
		ModalPopup._BackgroundDiv.style.background = BackgroundColor;	
		ModalPopup._BackgroundDiv.style.height = document.all ? Math.max(Math.max(document.documentElement.offsetHeight, document.documentElement.scrollHeight), Math.max(document.body.offsetHeight, document.body.scrollHeight)) : (document.body ? document.body.scrollHeight : ((document.documentElement.scrollHeight != 0) ? document.documentElement.scrollHeight : 0)) + "px";
		ModalPopup._BackgroundDiv.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + BackgroundOpacity +")";
		ModalPopup._BackgroundDiv.style.MozOpacity = BackgroundOpacity / 100;
		ModalPopup._BackgroundDiv.style.opacity = BackgroundOpacity / 100;
		ModalPopup._BackgroundDiv.style.zIndex = Zindex;
		ModalPopup._BackgroundDiv.style.cursor = BackgroundCursorStyle;

		//Display the background
		ModalPopup._BackgroundDiv.style.display = "";
	}

}

ModalPopup.Close = function(id) {
	if (id) {
		$(id).style.display = "none";
		$(id).style.visibility = "hidden";		
		window.document.body.removeChild($(id));
		_AlertPopUp=null;
	} 
	if  (ModalPopup._BackgroundDiv) {
		ModalPopup._BackgroundDiv.style.display = "none";
	}
}




