var j = Class.extend({
	width : '500',
	height : '500',
	name : '',
	contentOption : '',
	contentURL:'',
	content:'',
	scroll : '',
	loaderDiv : null,
	windDiv : null,
	
	createLoader : function() {
		win.loaderDiv = document.body.appendChild(document.createElement("DIV"));
		with(win.loaderDiv.style) { display = "none"; }
		win.loaderDiv.className = "browserGridLoader";
		win.loaderDiv.zIndex = "180";
	},
	
	create : function() {
		if (win.loaderDiv == null) win.createLoader();
		win.loaderDiv.innerHTML = "";
		win.loaderDiv.style.display = "";
		
		var posX = Math.round((parseInt(screen.availWidth)-win.width)/2);
		var posY = (Math.round((parseInt(screen.availHeight)-win.height)/2)-100) + document.body.scrollTop;
		
		win.winDiv = document.body.appendChild(document.createElement("DIV"));
		win.loaderDiv.style.height = win.getPageSize()[1];
		var cWinWidth = (core.browser=="ie") ? "100%" : (win.width-10);
		var cWinHeight = (core.browser=="ie") ?  (win.height-40) : (win.height-40);
		var winStr = "";
		
		winStr += "<div id=\"winModalContainer\" style=\"width:"+win.width+"px; height:"+win.height+"px; top:"+posY+"px; left:"+posX+"px; position:absolute; background:#ffffff; z-index:181; border:3px outset #8cc8fa;\">"+
			"<div style=\"white-space:nowrap; padding:5px;\">"+
				"<span style=\"width:15px; line-height:30px; display:-moz-inline-box; display:inline-block;\"><img src=\"images/s.gif\" width=\"15\" height=\"15\" class=\"winHeader\"></span>"+
				"<span style=\"width:"+(win.width-40)+"px; line-height:20px; font:bold 11px georgia; padding-bottom:3px; padding-left:3px; display:-moz-inline-box; display:inline-block;\">"+win.name+"</span>"+
				"<span  style=\"width:15px; line-height:30px; display:-moz-inline-box; display:inline-block;\"><img src=\"images/s.gif\" width=\"15\" height=\"15\" class=\"winCloser\" onmouseover=\"this.style.backgroundPosition='-15px 0px';\" onmouseout=\"this.style.backgroundPosition='0px 0px';\" onclick=\"win.close();\"></span>"+
			"</div>"+
			"<div style=\"padding:5px; width:"+cWinWidth+"px; height:"+cWinHeight+"px;";
		winStr += (win.contentOption!="iframe") ? "overflow:auto;" : "";
		winStr += "\" id=\"winModalContent\">";
		
		if (win.contentOption == "iframe") {
			winStr += "<iframe frameborder=\"0\" name=\"winFrame\" width=\""+cWinWidth+"\" height=\""+cWinHeight+"\" src=\""+win.contentURL+"\"></iframe>";
		} else if (win.contentOption == "ajax") {
			
		} else {
			winStr += win.content;
		}
			
		winStr += "</div>"+
			"</div>";
		
		win.winDiv.innerHTML = winStr;
		
		if (win.contentOption == "ajax") {
			var aj = new ajax(win.contentURL);
			aj.write("winModalContent");
			aj.setAfterLoad("core.init();");
		}
	},
	
	close : function() {
		document.body.removeChild(win.winDiv);
		win.loaderDiv.style.display = "none";
	},
	
	getPageSize : function() {
	
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else {
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight) {
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { 
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		if(yScroll < windowHeight) pageHeight = windowHeight; else pageHeight = yScroll;
		if(xScroll < windowWidth) pageWidth = windowWidth; else pageWidth = xScroll;
	
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
		return arrayPageSize;
	}
});

var win = new j();
win.width = 500;
win.height = 500;
win.name = "Emre was here";