

var cmsOnload = new Array();
var cmsOnunload = new Array();

function cmsAddJSevent (theType, theEvent)
{
	if (theType=="onload")
		cmsOnload.push(theEvent);
	else
		cmsOnunload.push(theEvent);	
}

window.onload = function ()
{
	for (var i=0;i<cmsOnload.length;i++)
		eval(cmsOnload[i]);
}

window.onunload = function ()
{
	for (var i=0;i<cmsOnunload.length;i++)
		eval(cmsOnunload[i]);
}

function cmsCloseSubwindows()
{
	if (window.subwindows!=null)
	{
		var wnd;
		while (window.subwindows.length>0)
		{
			wnd=window.subwindows.pop();
			if (wnd)
				wnd.close()
		}
	}
	else
	{
		window.subwindows = new Array();
	}
}

function cmsOpenSubwindow(url,wnd_name,wnd_props)
{
	var wnd=window.open(url,wnd_name,wnd_props);
	if (window.subwindows)
		window.subwindows.push(wnd);
	else
	{
		window.subwindows=new Array(wnd);
		window.subwindows.push(wnd);
	}
	return wnd;
}

function cmsPreviewImage(img_url,img_title,width,height)
{
	var win_title = "imgPreview";
	cmsCloseSubwindows();
	
	if (width==-1 || height==-1)
		subWindow = cmsOpenSubwindow("img_preview.php?imgurl="+img_url+"&img_title="+img_title,win_title,"width=100,height=100,innerWidth=100,innerHeight=100,menubar=false,alwaysRaised=true,copyhistory=false,dependent=true,directories=false,hotkeys");
	else
	{
		width+=40;
		height+=40;
		subWindow = cmsOpenSubwindow("img_preview.php?imgurl="+img_url+"&img_title="+img_title,win_title,"width="+width+",height="+height+",innerWidth="+width+",innerHeight="+height+",menubar=false,alwaysRaised=true,copyhistory=false,dependent=true,directories=false,hotkeys");
	}
}

function cmsPreviewVideo(img_url,img_title,width,height)
{
	var win_title = "videoPreview";
	cmsCloseSubwindows();
	
	if (width==-1 || height==-1)
		subWindow = cmsOpenSubwindow("video_preview.php?video="+img_url,win_title,"width=100,height=100,innerWidth=100,innerHeight=100,menubar=false,alwaysRaised=true,copyhistory=false,dependent=true,directories=false,hotkeys");
	else
	{
		subWindow = cmsOpenSubwindow("video_preview.php?video="+img_url,win_title,"width="+width+",height="+height+",innerWidth="+width+",innerHeight="+height+",menubar=false,alwaysRaised=true,copyhistory=false,dependent=true,directories=false,hotkeys");
	}
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


