// JScript File

function PortalStartup(){
	startBlink();
	LoaderFunction();
	ShowMessages();
}

function doBlink(){
	var blink = document.getElementsByTagName("BLINK")
	for (var i = 0; i < blink.length; i++) 
		blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : ""
}

function startBlink(){
	if (document.all) 
		setInterval("doBlink()", 1000)
}


/* Session timeout ile ilgili işlemler. */

// request variable
var request_var;

// Request object method wrapper function
function request_object(){
	// Gecko / IE7
	if (typeof(XMLHttpRequest) != 'undefined') 
		return new XMLHttpRequest();
	
	// IE6
	try {
		return new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (e) {
	}
	
	// IE5
	try {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} 
	catch (e) {
	}
}

// Call the request object method wrapper function
request_var = request_object();

if (!request_var) {
	alert("Bilgisayarınızdan ajax işlemleri yapılamıyor.");
}

function ResponseCompleted(){
	if (!request_var) 
		return;
	if (request_var == undefined) 
		return;
	if (!request_var.readyState) 
		return;
	if (request_var.readyState == 4) {
		var resp = request_var.responseText;
		if (resp.substr(0, 6) == '<html>') 
			return;
		if (resp.length == 0) 
			return;
		try {
			eval(resp);
		} 
		catch (e) {
		}
	}
}

function SessionManagerRedirectPage(NewUrl){
	window.open(NewUrl, "_top");
}

var SessionManagerTimeoutDislaying = false;

function ShowTimeout(SessionHandlerURL){
	if (SessionManagerTimeoutDislaying) 
		return;
	SessionManagerTimeoutDislaying = true;
	//window.open(SessionHandlerURL,"SessionTimerWindow","width=300,height=300, center=yes,scrollbars=no,location=no,status=no,dependent=yes");
	showDialog(SessionHandlerURL, null, "width=300,height=300, center=yes,scrollbars=no,location=no,status=no,dependent=yes");
}

function CheckServerForSession(ReqUrl){
	if (request_var) {
		request_var.open("GET", ReqUrl, true);
		request_var.onreadystatechange = ResponseCompleted;
		request_var.send(null);
	}
}


function SessionTimer(AshxUrl, CheckState){
	var ReqUrl = AshxUrl + "?CheckState=" + CheckState;
	CheckServerForSession(ReqUrl);
}




/*
 History Bar ile ilgili fonksiyonlar
 */
var HistoryBars = new Array();

function RegisterHistoryBar(HistoryBarId){
	HistoryBars.push(HistoryBarId);
}

function SetHistory(NewHistory){
	for (var i = 0; i < HistoryBars.length; i++) {
		var HistBar = document.getElementById(HistoryBars[i]);
		if ((HistBar != undefined) && (HistBar != null)) {
			HistBar.innerHTML = NewHistory;
		}
	}
}


/*
 Navigation Bar ile ilgili fonksiyonlar
 */
var NavigationBars = new Array();

function RegisterNavigationBar(NavigationBarId){
	NavigationBars.push(NavigationBarId);
}

function SetNavigation(NewNavigation){
	for (var i = 0; i < NavigationBars.length; i++) {
		var NavBar = document.getElementById(NavigationBars[i]);
		if ((NavBar != undefined) && (NavBar != null)) {
			NavBar.innerHTML = NewNavigation;
		}
	}
}


// Mesaj Gösterim, Sayfa Kapatım, ClientSide Yönlendirme vesair işler.

var MessageList = new Array();
var CommandQueue = new Array();


function SetMessage(MessageId, Message, MesajTip){
	MessageList.push(new Array(MessageId, Message, MesajTip));
}

function ExecCommand(cmd){
	CommandQueue.push(cmd);
}

function ShowMessages(){
	if (MessageList.length > 0) {
		var msg = MessageList.pop();
		if ((msg[0] != '') && (msg[2].toLowerCase() != 'belirsiz')) {
			var MsgUrl = "";
			if (appPath == undefined) {
				MsgUrl = "/";
			}
			else {
				MsgUrl = appPath;
			}
			MsgUrl = MsgUrl + 'Controls/MsgGoster.aspx?MsgId=' + escape(msg[0]) + '&Msg=' + escape(msg[1]) + "&MesajTip=" + escape(msg[2]);
			showDialog(MsgUrl, ShowMessages, "left=300;top:300;height=200;width=300;location=no;statusbar=no;menubar=no;scrollbars=yes;resizable=yes;titlebar=no;");
		}
		else {
			alert(msg[1]);
			ShowMessages();
		}
	}
	else {
		while (CommandQueue.length > 0) {
			var cmd = CommandQueue.pop();
			try {
				window.eval(cmd);
			} 
			catch (e) {
				alert(e.message);
			}
		}
	}
}

/* Yardım ile ilgili fonksiyonlar 
 */
function Yardim(YardimUrl){

	var DocUrl = window.location.href;
	var Alternate = window.location.href;
	
	var Frames = document.getElementsByTagName('IFRAME');
	if (Frames.length > 0) {
		for (var i = 0; i < Frames.length; i++) {
			if (Frames[i].id.search(/frmWorkArea/gi) >= 0) {
				DocUrl = Frames[i].contentWindow.location.href;
			}
		}
	}
	
	var Features = "height=580, width=900, left=0, top=0, location=no, menubar=no, resizable=yes, scrollbars=yes,status=no, toolbar=no";
	
	if ((YardimUrl == undefined) || (YardimUrl != null) || (YardimUrl == '')) {
		if (appPath != undefined) {
			window.open(appPath + "Yardim/default.aspx?URL=" + escape(DocUrl), "_blank", Features);
		}
		else {
			window.open(appPath + "Yardim/default.aspx?URL=" + escape(DocUrl), "_blank", Features);
		}
	}
	else {
		window.open(YardimUrl + "?URL=" + escape(DocUrl) + "&Alternate=" + escape(Alternate), "_blank", Features);
	}
}

/*
 Menü ile ilgili fonksiyonlar...
 */
function CollapseExpand(elm){
	var prn = elm.parentNode;
	var title = null;
	var container = null;
	
	var divs = prn.getElementsByTagName('DIV');
	for (var i = 0; i < divs.length; i++) {
		if ("partContainer" == divs[i].className) 
			container = divs[i];
		if ("Title" == divs[i].className) 
			title = divs[i];
	}
	
	if (null != container) {
		if ("true" != elm.getAttribute("collapsed")) {
			elm.setAttribute("collapsed", "true");
			elm.className = "rolldn";
			container.style.visibility = "hidden";
			
			var PaddingValue = title.clientHeight - parseInt(getStyle(prn, "padding-top")) - parseInt(getStyle(prn, "padding-bottom"));
			
			prn.style.height = PaddingValue.toString() + "px";
			prn.style.minHeight = title.style.height;
			prn.style.maxHeight = title.style.height;
			prn.style.overflow = "hidden";
		}
		else {
			elm.setAttribute("collapsed", "false");
			elm.className = "rollup";
			container.style.visibility = "visible";
			prn.style.height = "auto";
			prn.style.minHeight = "";
			prn.style.maxHeight = "";
			prn.style.overflow = "visible";
		}
	}
}

/*
 Açılışla ilgili Fonksiyonlar
 */
function LoaderFunction(){
	try {
		eval("bodyonload();");
	} 
	catch (e) {
	
	}
}

function SetLanguage(LangCode){
	var eventTarget = document.getElementById('__EVENTTARGET');
	var eventArgument = document.getElementById('__EVENTARGUMENT');
	if ((eventTarget != undefined) && (eventTarget != null)) {
		eventTarget.value = LangCode;
		document.forms[0].submit();
	}
}


function SubmitFunction(){
	try {
		eval("formonsubmit();");
		eval("form1onsubmit();");
	} 
	catch (e) {
	
	}
}

// Get the computed css property
function getStyle(element, cssRule){
	if (document.defaultView && document.defaultView.getComputedStyle) {
		var fn = function(match, char){
			return "-" + char.toLowerCase();
		};
		var value = document.defaultView.getComputedStyle(element, '').getPropertyValue(cssRule.replace(/[A-Z]/g, fn));
	}
	else {
		if (element.currentStyle) {
			var value = element.currentStyle[RuleToProperty(cssRule)];
		}
		else {
			var value = false;
		}
	}
	return value;
}

// Set a style property
function setStyle(element, cssRule, value){
	var original = getStyle(element, cssRule);
	if (!element.styleHistory) 
		element.styleHistory = new Array();
	if (!element.styleHistory[cssRule]) 
		element.styleHistory[cssRule] = new Array();
	element.styleHistory[cssRule].push(original);
	element.style[cssRule] = value;
	return value;
}

// Undo a style property change
function undoSetStyle(element, cssRule){
	if (this.styleHistory &&
	this.styleHistory[cssRule] &&
	this.styleHistory[cssRule].length) {
		var oldValue = this.styleHistory[cssRule].pop();
		this.style[cssRule] = oldValue;
	}
}

// Revert one or more style properties
function revertStyle(element, cssRules){
	var stylesChanged = 0;
	if (element.styleHistory) {
		if (cssRules == '*') {
			cssRules = new Array();
			for (var a in element.styleHistory) 
				cssRules.push(a);
		}
		else 
			if (typeof cssRules != "Array") 
				cssRules = Array(cssRules);
		
		for (var a = 0; a < cssRules.length; a++) {
			var cssRule = cssRules[a];
			if (element.styleHistory[cssRules[a]] &&
			element.styleHistory[cssRules[a]][0]) {
				element.style[cssRules[a]] = element.styleHistory[cssRules[a]][0];
				element.styleHistory[cssRules[a]] = new Array();
				stylesChanged++;
			}
		}
	}
	return stylesChanged;
}

// Add push() and pop() if necessary
if (typeof Array.prototype.push == 'undefined') {
	Array.prototype.push = function(element){
		this[this.length] = element;
	}
}

if (typeof Array.prototype.pop == 'undefined') {
	Array.prototype.pop = function(){
		var last = this[this.length - 1];
		this.length--;
		return last;
	}
}


function RuleToProperty(txt){
	var result = txt;
	var pos = result.indexOf("-");
	
	while ((-1) != pos) {
		result = result.substr(0, pos) + result.substr(pos + 1, 1).toUpperCase() + result.substr(pos + 2, result.length - pos - 2);
		pos = result.indexOf("-");
	}
	return result;
}


window.setResult = function(value){
	if (!window.DialogParam) {
		window.DialogParam = window.opener.DParam;
	}
	window.DialogParam.returnValue = value;
}


//----------------------------------------
// MODAL dialog gösterme fonksiyonları
//----------------------------------------
/*
 Kullanımı şu şekilde :
 
 1. Yöntem
 --------------------------
 function DetayEkle(){
 showDialog("Detay.aspx?Id=-1",SayfayiTazele, "left=10, top=10, width=300, height=300");
 }
 
 function SayfayiTazele(){
 document.forms[0].submit();
 }
 
 
 2. Yöntem
 -----------------------
 function DetayGoster(Id){
 ShowDialog("Detay.aspx?Id=" + (Id).toString(),null);
 }
 
 */
window.onunload = myOnClose;

document.ChildCloser = null;
document.WindowCB = null;
document.OnMouseDown = null;
document.OnMouseUp = null;
document.OnClick = null;

function ChildClosed(){
	if (window.onfocus != null) {
		window.onfocus = null;
		document.onmousedown = document.OnMouseDown;
		document.onmouseup = document.OnMouseUp;
		document.onclick = document.OnClick;
		
		document.OnMouseDown = undefined;
		document.OnMouseUp = undefined;
		document.OnClick = undefined;
	}
	if (null != document.WindowCB) {
		document.WindowCB(window.DParam.returnValue);
		document.WindowCB = undefined;
	}
}

function myOnClose(e){
	CheckChildWindow();
	if ((undefined != document.Window) && (null != document.Window)) {
		document.Window.close();
	}
};

function CheckChildWindow(){
	if (undefined != document.Window) {
		if (null != document.Window) {
			var Closed = true;
			try {
				Closed = document.Window.closed;
			} 
			catch (e) {
			};
			
			if (Closed) {
				ChildClosed();
				document.Window = null;
				return false;
			}
			window.setTimeout("javascript:CheckChildWindow();", 200);
		}
	}
	return false;
};

function FocusChildWindow(){
	if (undefined != document.Window) {
		if (null != document.Window) {
			var Closed = true;
			try {
				Closed = document.Window.closed;
			} 
			catch (e) {
			};
			
			if (!Closed) {
				document.onmousedown = FocusChildWindow;
				document.onmouseup = FocusChildWindow;
				document.onclick = FocusChildWindow;
				window.onfocus = FocusChildWindow;
				
				document.Window.focus();
			}
		}
	}
	return false;
}

function showDialog(URL, CB, Params){
	if (undefined == CB) 
		CB = null;
	
	Params = SetupParams(Params);
	
	try {
		document.Window = window.open(URL, "_blank", Params, true);
	} 
	catch (e) {
		alert("Şu anda kullanmakta olduğunuz tarayıcı popup pencereleri bloke ediyor. Eğer windows XP kullanıyorsanız pencerenin üst kısmında yeralan sarı banda farenin sağ butonuyla tıklayın ve açılan menüden bu sitede popuplara izin ver seçeneğini seçin. Eğer google toolbar, msn toolbar gibi programlar kullanıyorsanız bu sitede işlem yaparken bu toolbar programlarının ayarlarından popup blocker özelliğini iptal ettirin.");
		return
	}
	if (document.Window == undefined) {
		alert("Şu anda kullanmakta olduğunuz tarayıcı popup pencereleri bloke ediyor. Eğer windows XP kullanıyorsanız pencerenin üst kısmında yeralan sarı banda farenin sağ butonuyla tıklayın ve açılan menüden bu sitede popuplara izin ver seçeneğini seçin. Eğer google toolbar, msn toolbar gibi programlar kullanıyorsanız bu sitede işlem yaparken bu toolbar programlarının ayarlarından popup blocker özelliğini iptal ettirin.");
		return
	}
	if (document.Window == null) {
		alert("Şu anda kullanmakta olduğunuz tarayıcı popup pencereleri bloke ediyor. Eğer windows XP kullanıyorsanız pencerenin üst kısmında yeralan sarı banda farenin sağ butonuyla tıklayın ve açılan menüden bu sitede popuplara izin ver seçeneğini seçin. Eğer google toolbar, msn toolbar gibi programlar kullanıyorsanız bu sitede işlem yaparken bu toolbar programlarının ayarlarından popup blocker özelliğini iptal ettirin.");
		return
	}
	
	try {
		var dummy = document.Window.title;
	} 
	catch (e) {
		alert("Şu anda kullanmakta olduğunuz tarayıcı popup pencereleri bloke ediyor. Muhtemel problem YAHOO toolbar olabilir. Başka popup blocker eklentileri de bu soruna yolaçabilmektedir. Lütfen bu sitede işlem yaparken popupblocker veya tarayıcı kapatın. Kapattıktan sonra yeni bir tarayıcıdan (blocker olmadan) sayfayı açın.");
		return
	}
	
	window.DParam = {
		returnValue: ""
	};
	document.WindowCB = CB;
	
	document.Window.DialogParam = window.DParam;
	
	document.OnMouseDown = document.onmousedown;
	document.OnMouseUp = document.onmouseup;
	document.OnClick = document.onclick;
	
	document.onmousedown = FocusChildWindow;
	document.onmouseup = FocusChildWindow;
	document.onclick = FocusChildWindow;
	
	window.onfocus = FocusChildWindow;
	window.setTimeout("javascript:CheckChildWindow();", 300);
};

function SetupParams(Params){
	if (undefined == Params) {
		Params = "";
	}
	Params = Params.replace(/dialogHeight:/gi, "height=");
	Params = Params.replace(/dialogWidth:/gi, "width=");
	Params = Params.replace(/dialogTop:/gi, "top=");
	Params = Params.replace(/dialogLeft:/gi, "left=");
	//Params = Params.replace(/scrollBars:/gi,"scroll=");
	Params = Params.replace(/:/gi, "=");
	Params = Params.replace(/;/gi, ",");
	
	if (-1 == Params.toLowerCase().indexOf("height")) {
		var h = window.screen.height / 2;
		Params = "height=" + h.toString() + (("" == Params) ? "" : ",") + Params;
	}
	
	if (-1 == Params.toLowerCase().indexOf("status")) 
		Params = "status=no," + Params;
	if (-1 == Params.toLowerCase().indexOf("resizable")) 
		Params = "resizable=yes," + Params;
	if (-1 == Params.toLowerCase().indexOf("menubar")) 
		Params = "menubar=no," + Params;
	if (-1 == Params.toLowerCase().indexOf("toolbar")) 
		Params = "toolbar=no," + Params;
	
	
	if (-1 == Params.toLowerCase().indexOf("width")) {
		var w = window.screen.width / 2;
		Params = "width=" + w.toString() + (("" == Params) ? "" : ",") + Params;
	}
	
	
	Params = "modal=yes, dialog=yes, dependent=yes" + (("" == Params) ? "" : ",") + Params;
	
	return Params;
}


/***************************
 WorkArea management.....
 ****************************/
var WorkAreaList = new Array();

function RegisterWorkArea(FrameId){
	WorkAreaList.push(FrameId);
}

function ShowInWorkArea(NavUrl){
	if (WorkAreaList.length == 0) {
		window.open(NavUrl, "_top");
	}
	else {
		ShowInFrame(WorkAreaList[0], NavUrl);
	}
}

function HasWorkAreaRegistered(){
	return (WorkAreaList.length > 0);
}

function ShowInWorkAreaOrPopup(NavUrl){
	if (WorkAreaList.length == 0) {
		window.open(NavUrl, "_blank");
	}
	else {
		ShowInFrame(WorkAreaList[0], NavUrl);
	}
}


/**********************************
 Portal Page Accept
 **********************************/
function PortalPageAccept(TabloAdi, Referans, Baslik){
	showDialog("/Guvenlik/PortalPageAccept.aspx?TabloAdi=" + TabloAdi + "&Referans=" + Referans + "&Baslik=" + Baslik, null, "dialogHeight:375px;dialogWidth:537px;center:1;resizable:no;");
}


/*************************************
 Browser versiyon kontrol objesi
 **************************************/
function BrowserDefinition(){
	var w = window;
	var d = w.document;
	var ua = navigator.userAgent.toLowerCase();
	this.ie = w.VBArray;
	this.ie5 = (this.ie && (!d.createEventObject || !d.namespaces));
	this.ie55 = (this.ie && !d.implementation);
	this.ie6 = (this.ie && d.implementation);
	this.ie7 = (this.ie && w.XMLHttpRequest);
	if (this.ie7==undefined) this.ie7 = false;
	if (this.ie6) this.ie6 = true;
	if (d.documentMode) { // document mode specific to IE8 ...
		this.ie8 = (d.documentMode == 8);
		this.ie7 = (d.documentMode == 7);
	}
	else {
		this.ie8 = false;
	}
	this.opera = w.opera;
	this.gecko = (w.netscape && !this.opera);
	this.khtml = (ua.indexOf("safari") + 1 || ua.indexOf("konqueror") + 1);
}

var Browser = new BrowserDefinition();


// Nesnelerin içerisine Bekleme iconu koyar.
function SetLoadingIcon(ObjectName, information){
	var mob = document.getElementById(ObjectName)
	mob.style.verticalAlign = "middle";
	mob.style.textAlign = "center";
	var myData = '<img src="../Images/Loading.gif" />';
	if ((information != undefined) && (information != '')) {
		myData += '<br style="clear:both"/>' + information;
	}
	mob.innerHTML = myData;
}

// Nesnelerin içerisine Uyarı iconu koyar.
function SetWarningIcon(ObjectName, information){
	var mob = document.getElementById(ObjectName)
	mob.style.verticalAlign = "middle";
	mob.style.textAlign = "center";
	var myData = '<img src="../Images/WarningBlack.png" width="64px" height="64px" />';
	if ((information != undefined) && (information != '')) {
		myData += '<br style="clear:both"/>' + information;
	}
	mob.innerHTML = myData;
}

// Nesnelerin içerisinden ikonları kaldirir.
function ClearIcons(ObjectName){
	var mob = document.getElementById(ObjectName)
	mob.style.verticalAlign = "top";
	mob.style.textAlign = "left";
	mob.innerHTML = "";
}

//Comboun SelectedValue Değerini Verir
function SelectedValue(obj){
	return obj.options[obj.selectedIndex].value;
}

//Combonun istenilen öğesini seçer.
function setComboValue(Obj, Value){
	for (var i = 0; i < Obj.options.length; i++) {
		if (Obj.options[i].value == Value) {
			Obj.selectedIndex = i;
			break;
		}
	}
}


var WorkareaMaximizers = new Array();
function RegisterWorkareaMaximizer(objId, minTitle, minText, maxTitle, maxText, minIcon, maxIcon){
	var obj = {
		id: objId,
		title_min: minTitle,
		title_max: maxTitle,
		text_min: minText,
		text_max: maxText,
		icon_min: minIcon,
		icon_max: maxIcon,
		elm: document.getElementById(objId)
	
	};
	WorkareaMaximizers.push(obj);
}

function MaximizeMinimizeWorkArea(){
	var printArea = document.getElementById('printArea');
	if ((printArea == undefined) || (printArea == null)) 
		return;
	
	if (printArea.enlarged == undefined) {
		printArea.enlarged = false;
	}
		
	var toolBar = document.getElementById('PortalToolbar');
	if (printArea.enlarged) {
		printArea.enlarged = false;
	  if ((!Browser.ie8) && (!Browser.ie7) &&(Browser.ie6)) {
		  window.detachEvent("onresize", IE6Resize);
	  }
		MinimizeWorkArea(printArea, toolBar);
	  
		SetWindowEnlargementState(false);
		
		for (var i=0;i<WorkareaMaximizers.length;i++){
		  WorkareaMaximizers[i].elm.title= WorkareaMaximizers[i].title_min;
		  WorkareaMaximizers[i].elm.alt= WorkareaMaximizers[i].title_min;
		  WorkareaMaximizers[i].elm.childNodes[0].alt= WorkareaMaximizers[i].title_min;
		  WorkareaMaximizers[i].elm.childNodes[1].title= WorkareaMaximizers[i].title_min;
		  WorkareaMaximizers[i].elm.childNodes[1].innerText= WorkareaMaximizers[i].text_min;
      WorkareaMaximizers[i].elm.childNodes[0].src=WorkareaMaximizers[i].icon_min;
  	}
    var paFlash=printArea.getElementsByTagName("OBJECT");
    for (var i=0;i<paFlash.length;i++){
      paFlash[i].ThisIsInPrintArea = true;  
    }
        
  	var flashObjects=document.getElementsByTagName("OBJECT");
  	for(var i=0;i<flashObjects.length;i++){
  	  if(!flashObjects[i].ThisIsInPrintArea) {
        flashObjects[i].style.visibility=flashObjects[i].oldVisibility;
  	  }
  	}
	}
	else {
		printArea.enlarged = true;
		SetWindowEnlargementState(true);
		
		MaximizeWorkArea(printArea, toolBar);
		if ((!Browser.ie8) && (!Browser.ie7) && (Browser.ie6)) {
		  window.attachEvent("onresize", IE6Resize);
	  }
		
		for (var i=0;i<WorkareaMaximizers.length;i++){
		  WorkareaMaximizers[i].elm.title= WorkareaMaximizers[i].title_max;
		  WorkareaMaximizers[i].elm.alt= WorkareaMaximizers[i].title_max;
		  WorkareaMaximizers[i].elm.childNodes[0].alt= WorkareaMaximizers[i].title_max;
		  WorkareaMaximizers[i].elm.childNodes[1].title= WorkareaMaximizers[i].title_max;
		  WorkareaMaximizers[i].elm.childNodes[1].innerText= WorkareaMaximizers[i].text_max;
      WorkareaMaximizers[i].elm.childNodes[0].src=WorkareaMaximizers[i].icon_max;
  	}

    var paFlash=printArea.getElementsByTagName("OBJECT");
    for (var i=0;i<paFlash.length;i++){
      paFlash[i].ThisIsInPrintArea = true;  
    }
        
  	var flashObjects=document.getElementsByTagName("OBJECT");
  	for(var i=0;i<flashObjects.length;i++){
  	  if(!flashObjects[i].ThisIsInPrintArea) {
  	    flashObjects[i].oldVisibility=flashObjects[i].style.visibility;
  	    flashObjects[i].style.visibility='hidden';
  	  }
  	}  	
	}
}

function MinimizeWorkArea(Frm, toolbar){
	popStyleInfo(Frm.ownerDocument.documentElement);
	popStyleInfo(Frm);
	if (toolbar != null) {
		popStyleInfo(toolbar);
	}
}

function MaximizeWorkArea(Frm, toolbar){
	pushStyleInfo(Frm.ownerDocument.documentElement);
	pushStyleInfo(Frm);
	Frm.hasToolbar = false;
	
	if (toolbar != null) {
		Frm.hasToolbar = true;
		pushStyleInfo(toolbar);

		toolbar.style.zIndex = "10000" ;
		toolbar.style.position = 'fixed';
		toolbar.style.padding = "0px 0px 0px 0px";
		toolbar.style.margin = "0px 0px 0px 0px";
		toolbar.style.top = "0px";
		toolbar.style.left = "0px";
  	if ((!Browser.ie8) && (!Browser.ie7) && (Browser.ie6)) {
  	  toolbar.style.width = Frm.ownerDocument.documentElement.clientWidth.toString() + 'px';
    }
    else {
      toolbar.style.width = "100%";
    }
		toolbar.style.height = "20px";
		toolbar.style.backgroundColor = "white";
		toolbar.style.textAlign = 'right';
	}
	
	Frm.ownerDocument.documentElement.style.overflow = "hidden";
	Frm.ownerDocument.documentElement.scrollTop = 0;
	Frm.ownerDocument.documentElement.scrollLeft = 0;

  Frm.style.overflowX = "auto";
  Frm.style.overflowY = "auto";
  Frm.style.overflow = "auto";
	Frm.style.zIndex = "9998"  ;
	
	Frm.style.position = 'absolute';
	Frm.style.padding = "0px 0px 0px 0px";
	Frm.style.margin = "0px 0px 0px 0px";
	
	if ((!Browser.ie8) && (!Browser.ie7)  && (Browser.ie6)) {
	  // IE 6 specific
	
	  //Frm.style.removeAttribute("HEIGHT");
	
		if (Frm.hasToolbar){
			Frm.style.top = '20px';
		}
		else {
			Frm.style.top = '0px';
		}
		Frm.style.left = '0px';
		
		if (Frm.hasToolbar) {
			Frm.style.height = (Frm.ownerDocument.documentElement.clientHeight-20).toString() + 'px';
		}
		else {
			Frm.style.height = Frm.ownerDocument.documentElement.clientHeight.toString() + 'px';
		}
		Frm.style.width = Frm.ownerDocument.documentElement.clientWidth.toString() + 'px';
		
		Frm.style.backgroundColor = 'white';
	  return;	
	}
	if ((!Browser.ie8) && (Browser.ie7)) {
	  // IE 7 specific
	  var styleAddition=";";
  
    styleAddition += "left:0px !important;";
    if (Frm.hasToolbar){
      styleAddition += "top:20px !important;";
    }
    else {
      styleAddition += "top:0px !important;";
    }

    styleAddition += "right:0px !important;";
    styleAddition += "bottom:0px !important;";
    styleAddition += "width:auto !important;";
    styleAddition += "width:auto !important;";
    
    styleAddition += "background-color:white !important;";
    
    Frm.style.cssText += styleAddition;
    
	  return;
	}
	
	if (Frm.style.setProperty) {
	  // FFX specific
		  Frm.style.left = '0px';
		  if (Frm.hasToolbar){
		    Frm.style.top = '20px';
		  }
		  else {
		    Frm.style.top = '0px';
		  }
  		
		  Frm.style.right = '0px';
		  Frm.style.bottom = '0px';
		  Frm.style.setProperty("width","auto","important");
		  Frm.style.setProperty("height","auto","important");
		  Frm.style.backgroundColor = 'white';
  }
  
  // IE 8 and other browsers
    
  var styleAddition=";";
  
  styleAddition += "left:0px !important;";
  if (Frm.hasToolbar){
    styleAddition += "top:20px !important;";
  }
  else {
    styleAddition += "top:0px !important;";
  }
	
  styleAddition += "right:0px !important;";
  styleAddition += "bottom:0px !important;";
  styleAddition += "width:auto !important;";
  styleAddition += "height:auto !important;";		
  styleAddition += "background-color:white !important;";
  
  Frm.setAttribute("style",Frm.getAttribute("style") + styleAddition);
	
}

function IE6Resize(){
	var printArea = document.getElementById('printArea');
	if ((printArea == undefined) || (printArea == null)) 
		return;

  if (printArea.enlarged == undefined) {
		printArea.enlarged = false;
	}
	
	if (!printArea.enlarged) return;

	printArea.style.width = printArea.ownerDocument.documentElement.clientWidth.toString() + 'px';
	if (printArea.hasToolbar){
	  printArea.style.height = (printArea.ownerDocument.documentElement.clientHeight-20).toString() + 'px';
	  //printArea.style.height = (document.body.clientHeight-20).toString() + 'px';
	  
	  var toolBar = document.getElementById('PortalToolbar');
	  toolBar.style.width = printArea.ownerDocument.documentElement.clientWidth.toString() + 'px';
	}
	else {
	  printArea.style.height = printArea.ownerDocument.documentElement.clientHeight.toString() + 'px';
	  //printArea.style.height = document.body.clientHeight.toString() + 'px';
	}
	//window.status="Last resized:" + (new Date()).toString();
}


function pushStyleInfo(elm){
	if (elm.StyleLoaded) 
		return;
	elm.StyleSaved = true;
	elm.oldStyle = new Object();
	elm.oldStyle.zIndex = elm.style.zIndex;
	elm.oldStyle.position = elm.style.position;
	elm.oldStyle.padding = elm.style.padding;
	elm.oldStyle.margin = elm.style.margin;
	elm.oldStyle.top = elm.style.top;
	elm.oldStyle.bottom = elm.style.bottom;
	elm.oldStyle.left = elm.style.left;
	elm.oldStyle.right = elm.style.right;
	elm.oldStyle.width = elm.style.width;
	elm.oldStyle.height = elm.style.height;
	elm.oldStyle.backgroundColor = elm.style.backgroundColor;
	elm.oldStyle.mozOpacity = elm.style.mozOpacity;
	elm.oldStyle.filter = elm.style.filter;
	elm.oldStyle.khtmlOpacity = elm.style.khtmlOpacity;
	elm.oldStyle.opacity = elm.style.opacity;
	elm.oldStyle.textAlign = elm.style.textAlign;
	elm.oldStyle.overflow = elm.style.overflow;
	elm.oldStyle.overflowY = elm.style.overflowY;
	elm.oldStyle.overflowX = elm.style.overflowX;
}

function popStyleInfo(elm){
	if (!elm.StyleSaved) 
		return;
	elm.StyleLoaded = true;
	elm.style.zIndex = elm.oldStyle.zIndex;
	elm.style.position = elm.oldStyle.position;
	elm.style.padding = elm.oldStyle.padding;
	elm.style.margin = elm.oldStyle.margin;
	elm.style.top = elm.oldStyle.top;
	elm.style.bottom = elm.oldStyle.bottom;
	elm.style.left = elm.oldStyle.left;
	elm.style.right = elm.oldStyle.right;
	elm.style.width = elm.oldStyle.width;
	elm.style.height = elm.oldStyle.height;
	elm.style.backgroundColor = elm.oldStyle.backgroundColor;
	elm.style.mozOpacity = elm.oldStyle.mozOpacity;
	elm.style.filter = elm.oldStyle.filter;
	elm.style.khtmlOpacity = elm.oldStyle.khtmlOpacity;
	elm.style.opacity = elm.oldStyle.opacity;
	elm.style.textAlign = elm.oldStyle.textAlign;
	elm.style.overflow = elm.oldStyle.overflow;
	elm.style.overflowY = elm.oldStyle.overflowY;
	elm.style.overflowX = elm.oldStyle.overflowX;	
}


function SetWindowEnlargementState(status){
  var pageurl = window.location.pathname;
  document.cookie=pageurl + "=" + status.toString() + ";"
  //alert(document.cookie);
}

function CheckWindowEnlargement(){
  
  var pageurl = window.location.pathname;  
  var check = pageurl + "=true;"
  var p=document.cookie.indexOf(check);
  //alert("cookie:" + document.cookie + " --> Check:" + check + " --> idx:" + p.toString());
  if (p>=0) {
    MaximizeMinimizeWorkArea();
  }
}

window.setTimeout("javascript:CheckWindowEnlargement()",400);

