var isMin=false;
var isMax=false;
addEvent( window, 'scroll', checkScroll);

function ResizeParentIFrame(frameId, divId)
{
	try
	{
		var h = framePage.scrollHeight + 10;
		parent.document.getElementById(divId).style.height = h;
		parent.document.getElementById(frameId).style.height = h;
		var dv = parent.document.getElementById(divId);
		
		dv.style.left = parseInt(parent.document.body.clientWidth) / 2 - parseInt(dv.style.width) / 2;
		dv.style.top = parseInt(parent.document.body.scrollTop) + (parseInt(parent.document.body.clientHeight) / 2 - parseInt(dv.style.height) / 2);
		parent.window.execScript('CloseMessage();');
	}
	catch(ex)
	{
	}
}

function CloseMessage()
{
	document.getElementById('MessageBox').style.display = 'none';
	window.parent.document.getElementById('DIV_SetTemplateKey1').style.display="none";
}

function CloseSetting()
{
		//alert();
	var div=document.getElementById('DIV_SetTemplateKey1');
	
	div.style.display = 'none';
	ChangePageEnablity(true);
	CloseMessage();
}	

function ChangePageEnablity(enable)
{
	var allo =window.document.body;
	var Alloo=document.getElementById('DIV_SetTemplateKey1');
	if (!enable)
	{
		allo.style.filter='progid:DXImageTransform.Microsoft.BasicImage(XRay=1, Opacity=0.25)';
	
	    Alloo.style.display='inline';
	    window.parent.document.getElementById('DIV_SetTemplateKey1').style.filter='';
	    //window.parent.document.getElementById('DIV_SetTemplateKey1').style.Border=solid 1px ;
	    window.parent.document.getElementById('DIV_SetTemplateKey1').style.zIndex="2000";
	    Alloo.style.top="200px";
	    Alloo.style.left="200px";
	    Alloo.style.zIndex=window.parent.document.body.style.zIndex;
	    Alloo.style.filter='';
	}
	else
		allo.style.filter = '';
	    //allo.disabled = !enable;
}
//--------------------------------------------------------
function initArray() {
	this.length = initArray.arguments.length;
	for (var i = 0; i < this.length; i++) {
	this[i] = initArray.arguments[i];
	}
}
var speed = 600;
var x = 0;
var color = new initArray("red","white","red","white");
function chcolor()
{ 
	(x < color.length-1) ? x++ : x = 0;
}
setInterval("chcolor()",speed);
//--------------Ajax Loading
var AjaxCounter = 0;
function getModuleContent(url,module)
{
    removeSplash();
    
    AjaxCounter++;
    getFromHttpRequest('get',url+'&AjaxLoad=1',null,showContent,[module,'1']);
    /*
    setTimeout("getFromHttpRequest('get','"+url+"&AjaxLoad=1',null,showContent,['"+module+"','1'])"
              ,4000+(AjaxCounter*1000));
    */
}
function getTableContent(tableName,num)
{
    removeSplash();
    AjaxCounter++;
    getFromHttpRequest('get','../AjaxModules/AjaxShowTable.aspx?Tbl='+tableName+'&Num='+num+'&AjaxLoad=Table',null,showContent,[tableName,'1']);
    /*
    setTimeout("getFromHttpRequest('get','../AjaxModules/AjaxShowTable.aspx?Tbl="+tableName+"&Num="+num+"&AjaxLoad=Table',null,showContent,['"+tableName+"','1'])"
                ,4000+(AjaxCounter*1000));
    */
}
function showContent()
{
    ContentName = arguments[0];
    try
    { 
        gel('iDiv'+ContentName).style.height='auto';
        gel('iDiv'+ContentName).innerHTML=result;
    }
    catch(e){}
}

colorFlag = true;
function chColorNew()
{
    colorFlag = !colorFlag;
    for(fld=0;fld<arguments.length;fld++)
        if(gel(arguments[fld]))
            gel(arguments[fld]).style.color = colorFlag? 'red' : 'white';
}

//--------------------------
function removeSplash()
{
    if(gel('splashLoading'))
        setTimeout("gel('splashLoading').style.display='none';",5000);
    document.body.style.overflow='auto';
}
removeSplash();

function RefreshPage(CMS_FacilityGroup, ShowIcon)
{
	var tempid=document.all("NahieID");
	window.navigate('ShowFramework.aspx?CMS_FacilityGroup='+CMS_FacilityGroup+'&ParentID='+tempid.value+'&ShowIcon='+ShowIcon+'&fk=1');
}
