


/******************************************************************************************
         sysalert.vyew.js
 ******************************************************************************************/

/*

	Usage

	vyew.SysAlert.init("/maintenance/check.systemalert.php");

	Assumes:
	Using frames on this page with id: frameset1
	See example frameset at bottom

	


	function openImageEditor(url){
        parent.document.getElementsByTagName("frameset")[0].rows = "0,43,*";
        if(url!=null) parent.document.getElementById("botframe").src=url;
    }
    function closeImageEditor(){
        parent.document.getElementsByTagName("frameset")[0].rows = "*,43,0";
    }

*/


if(typeof vyew == "undefined") var vyew = new Object();
vyew.SysAlert={};
vyew.SysAlert.url=null;
vyew.SysAlert.conf_url=null;
vyew.SysAlert.lastSysAlert_length=0;

vyew.SysAlert.init = function(config_url)
{
	if(typeof $ == "undefined") return dbg("JQuery library needed");
	if(config_url) vyew.SysAlert.conf_url=config_url;
	$(function(){ setTimeout("vyew.SysAlert.check()", 3000); });
}
vyew.SysAlert.check = function()
{
	var sa=vyew.SysAlert;
	$.post(sa.conf_url,null,
	function(rtn)
	{
		var r = eval(rtn);
		if(r.url) sa.url=r.url;
		try{ if(top.topframe.location.href.match(/acct/)) return; }catch(e){}
		if (r.ttl>1 && r.topframe == "open"){
			if (sa.lastSysAlert_length != r.len){
				sa.lastSysAlert_length = r.len;
				openTop(sa.url);
			}else{ 
				if(getCookie("hiddenSysAlert")!="1")
					openTop(true);
			}
		}else{
			openTop(false);
		}
		if(r.ttl>1)	
			setTimeout('vyew.SysAlert.check()', (r.ttl*1000));
	});
}
vyew.SysAlert.openTopFrame = function(url,height)
{
	if(!url) return;
	openTop(url,height);
}

	function dbg(x){
    	if(typeof console != "undefined" && typeof console.debug != "undefined")
    	    console.debug(x);
	}





// FOR NEW NON_FRAMES VERSION
function openBanner(url,h)
{
    if(url===false) return closeBanner();
    if(!h)h=30;
    if(url!==true && url) $("div#banner #iframebanner").attr('src',url).height(h);
    $("div#banner").height(h).show()
    $("div#main-wrapper").css('margin-top',h)
}

function closeBanner()
{
    $("div#banner").hide()
    $("div#main-wrapper").css('margin-top',0)
}

// USED FOR OLD FRAMES VERSION OF ROOM
//openTop(url) - open with url
//openTop(false) - close
//openTop(true), open, without setting url
function openTop(url,h)
{
    return openBanner(url,h)
    if(!h)h=18;
    var rw = getFramesetHeight();
    if(url==false){                         //close
        if(rw.substr(0,1)!="0"){
            rw = rw.replace(/^[^,]*/,0) //change first framerow to 0
            setFramesetHeight(rw);
        }
    }else{                                  //open
        rw = rw.replace(/^[^,]*/,h);
        setFramesetHeight(rw);
        if(url!=true) $("#topframe").attr("src",url);
    }//if url
}
function hideTopFrame()
{
    setCookie("hiddenSysAlert","1","session");
    return closeBanner()
    openTop(false);
}


