try {
 document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

function upload_new_file_e(url){
	var myRef = window.open(url, 'uploadwin', 'left=20,top=20,width=730,height=480,toolbar=0,resizable=1,scrollbars=1');
}

//Event.observe(window, 'load', function(){
//checkwidth();
//})

//Event.observe(window, 'resize', function(){
//checkwidth();
//})

function checkwidth(minwidth){
	pagewidth = document.viewport.getWidth(); 
	//$('backgroundholder').getWidth();
	try{ 
		if(pagewidth<minwidth){
			$('backgroundholder').setStyle({width:minwidth + 'px'});
		} else {
			$('backgroundholder').setStyle({width:'100%'});
		} 
	}
	catch(e) {}
}

function boxcheck(classname, flag, downflag)
{
	//1 - turn all to on
	//0 - turn all to off
	//2 - swap
	//dot = skipdot ? '' : '.' ;
	$$('.' + classname).each(function(e2){
		if(downflag)
		{
			e = e2.down('input');
		} else {
			e = e2;
		}

		checkval = e.checked;
		switch(flag)
		{
		case 0:
			e.checked=false;
			if(checkval && e.onchange) e.onchange();
			break;
		case 1:
			e.checked=true;
			if(!checkval && e.onchange) e.onchange();
			break;
		case 2:
			newval = e.checked ? false : true ;
			e.checked = newval;
			if(e.onchange) e.onchange();
			break;
		}
	});
}

function boxcheck_list(classname)
{
	values = new Array();
	$$('.' + classname).each(function(e2){
		if(e2.checked){
			values.push(e2.value);
		}
	});
	return values;
}

function togglecheckbox(idname){
	var elem = $(idname);
	if(elem)
	{
		var checkval = elem.checked ? 0 : 1 ;
		elem.checked = checkval;
		elem.onchange();
	}
}

/* Scripts/Ajax for the home page by Mithun */

function activateTagByFilter(classname,idname)
{
	$$('.' + classname).each(
			function(e){
				tmpid = e.identify();
				e.className = classname;
				if(tmpid == idname){
					e.addClassName('active');
				} else {
					e.addClassName('inactive');
				}
			}
	);
}

function cleartiny()
{
	if(tinyMCE){
		tinyMCE.init();
	}
}

function stoplinks(classname)
{
	$$('.' + classname ).each(
			function(e)
			{
				e.update('--');
				e.onclick=function(){return false;};
			}
	)
}

function openRptWindow(url, width, height){
	return openNewWindow(url, width, height)
}

function openNewWindow(url, width, height){
	var w = width || 1000;
	var h = height || 700;
	var ref = window.open(url, 'uploadwin', 'left=20,top=20,width=' + w + ',height=' + h + ',toolbar=0,resizable=1,scrollbars=1');
	return ref;
}

function saveAndClose(){
	window.close();
}

function closeWindow(){
	window.close();
}

function hideflash(){
    $$('.assetpreview').each(function(el){tmpal = parseInt(el.getStyle('left'));if(isNaN(tmpal)||tmpal>=0){new Effect.Move(el, { x: -15000, y: 0, mode: 'relative' });}});
}
function showflash(){
    $$('.assetpreview').each(function(el){tmpal = parseInt(el.getStyle('left'));if(tmpal<0){new Effect.Move(el, { x: 15000, y: 0, mode: 'relative' });}});
}

