var count=0;
var win;
var cWins = new Array();

function showPackagingMaterial(url)
{
	url = "platformpage.aspx";
	pageSubMenus = $('subMenus');
	if(pageSubMenus.style.display=='none')
	{
		new Effect.Appear(pageSubMenus);
		showLoading($('contentDiv'));
		new Effect.Appear($('contentDiv'));

		new Ajax.Request(url,{
		onComplete: function(transport){
			if(200==transport.status){
				//var str = (transport.responseText).split(",");
				$('contentDiv').innerHTML = transport.responseText;
			}}});
	}
}

function showLoading(obj)
{
	obj.innerHTML = "";

	loadImg = new Image();
	loadImg.src = "images/loading.gif";
	txtnode = document.createTextNode("Loading...");

	obj.appendChild(loadImg);
	obj.appendChild(document.createElement("br"));
	obj.appendChild(txtnode);
}

function hidePackagingMaterial()
{
	subMenus = $('subMenus');
	if(subMenus.style.display=='')
	{
		new Effect.Fade(subMenus);
	}
}

function openDialog(page,pageTitle) 
{
    count++;
    

  /*  
    win = new Window( 'win'+count,{className: 'mystyle',title: pageTitle,top:40,left:70,width:700, height:400, maxWidth:960});
    win.setAjaxContent( page, { top:50,left:50, className:"mystyle",showEffect:Effect.Appear, hideEffect: Effect.SwitchOff ,method:'get'}, true, true);
    win.setDestroyOnClose(); 
    //win.show();
    win.toFront();
    */
    if(document.all)
        win = new Window('win'+count,{className: "mystyle", recenterAuto:true, title: pageTitle, top:10,left:50,width:800, height:550, url: page, showEffectOptions: {duration:1.5}})
    else
        win = new Window('win'+count,{className: "mystyle", recenterAuto:true, title: pageTitle, top:10,left:50,width:800, height:550, maxWidth:930, url: page, showEffectOptions: {duration:1.5}})
  
    win.setDestroyOnClose(); 
    win.showModal = true;

    win.showCenter(true);     
    win.toFront();   
    

}

function findPageHeight(type){
    var winWidth, winHeight, d=document;
    if (typeof window.innerWidth!='undefined') 
    {
        winWidth = window.innerWidth;
        winHeight = window.innerHeight;
    } 
    else if(d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0 ) {
        winWidth = d.documentElement.clientWidth;
        winHeight = d.documentElement.clientHeight;
    }
    else if ( d.body && typeof d.body.clientWidth!='undefined') 
    {
        winWidth = d.body.clientWidth;
        winHeight = d.body.clientHeight;
    }

if(type=="h")
    return winHeight;
else
    return winWidth;
}

function openAjaxWin(newurl){
win = new Window({id: "win1",className: "mystyle", title: "Reports", width:300, height:200, url: newurl, showEffectOptions: {duration:0.2}}) ;
win.showCenter(true);
win.show(); 
win.setDestroyOnClose(); 
cWins.push(win);
}

function windowClose()
{
	var x = 0;
    var lag=250;
	for(var i=(cWins.length-1);  i>=0;  i--) {
	  setTimeout('cWins['+i+'].hide()',(x*lag));
	  x++;
	}
	setTimeout('cWins.length=0; idx=0; cascade=0;',x*lag);

}

function windowMaximize()
{
    Windows.getWindow("win1").maximize()
}