var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;
function trim(str)
{
    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}
function performaction(url)
{
	window.location = url;
}
function show_div(div_id)
{
	document.getElementById(div_id).style.display = "block";
}
function hide_div(div_id)
{
	document.getElementById(div_id).style.display = "none";
}
function popup(url,top,left,width,height)
{
	window.open(url,'','menubar=no,top='+top+',left='+left+',width='+width+',height='+height+',toolbar=no');
}

function openAWindow( pageToLoad, winName, width, height, center)
{
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
	if (typeof (dmcaWin) != 'undefined') {
   		dmcaWin.close(); 
 	}
	//0 => no
	//1 => yes
    var args = "";
    	args += "width=" + width + "," + "height=" + height + ","
		+ "location=0,"
		+ "menubar=0,"
		+ "resizable=0,"
		+ "scrollbars=1,"
		+ "statusbar=false,dependent,alwaysraised,"
		+ "status=false,"
		+ "titlebar=no,"
		+ "toolbar=0,"
		+ "hotkeys=0,"
		+ "screenx=" + xposition + ","  //NN Only
		+ "screeny=" + yposition + ","  //NN Only
		+ "left=" + xposition + ","     //IE Only
		+ "top=" + yposition;           //IE Only
		//fullscreen=yes, add for full screen
    	var dmcaWin = window.open(pageToLoad,winName,args );
    	dmcaWin.focus();
    //window.showModalDialog(pageToLoad,"","dialogWidth:650px;dialogHeight:500px");
}

function reset()
{
	document.all.form.reset();
}

function onCheckAll()
{
	for( xx=0; xx < document.getElementsByTagName("*").length; xx++ )
	{		
		if( document.getElementsByTagName("*")[xx].type == 'checkbox' )
			document.getElementsByTagName("*")[xx].checked=true;
	}
}

function onClearAll()
{
	for( xx=0; xx < document.getElementsByTagName("*").length; xx++ )
	{		
		if( document.getElementsByTagName("*")[xx].type == 'checkbox' )
			document.getElementsByTagName("*")[xx].checked=false;					
	}
}

function getImageObj () {
      var bigObj = document.getElementById('bigImage');
      return (bigObj);
}
var sw ;
function OpenCenWindow (imgURL, winname, width, height) {
  var x = 0.5 *(window.screen.width - width);
  var y = 0.5 *(window.screen.height - height);
  var posStr = ", screenX=" + x + ", screenY=" + y;
  if (typeof (sw) != 'undefined')  {
                  sw.close(); 
  }
  if (document.all) {
             posStr = ", left=" + x + ", top=" + y;
  }
  var pStr = 'resizable, status=no,width=' + width + ', height=' + height + 
             ', alwaysRaised=1, addressbar=no, titlebar=no, toolbar=no, menubar=no, status=no';

  sw = window.open ("", winname,pStr +posStr );
 
  //imgSize = GetImageSize(imgURL, width, height);
  var imgStr = "<img src=\"" + imgURL.src + "\"  width=\"" + width + "\" + height=\"" + height + "\">";

  sw.document.write (imgStr);
}

function CloseWindow() {
      if (sw) { sw.close(); }
}

function modalWin(url, width, height){
	if (window.showModalDialog){
			window.showModalDialog(url,"","dialogWidth:"+height+"px;dialogHeight:"+width+"px");
	}else{
		window.open(url,'','height='+height+',width='+width+',toolbar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0 ,modal=1');
	}
} 

function popupWindow(url, width, height)
{
	xposition=0; yposition=0;
	var center = 250;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
	var args = "";
    	args += "width=" + width + "," + "height=" + height + ","
		+ "location=0,"
		+ "menubar=0,"
		+ "resizable=0,"
		+ "scrollbars=1,"
		+ "statusbar=false,dependent,alwaysraised,"
		+ "status=false,"
		+ "titlebar=no,"
		+ "toolbar=0,"
		+ "hotkeys=0,"
		+ "screenx=" + xposition + ","  //NN Only
		+ "screeny=" + yposition + ","  //NN Only
		+ "left=" + xposition + ","     //IE Only
		+ "top=" + yposition;           //IE Only
	window.open(url,'',args);
}

function clearIcon()
{
	document.getElementById('icon').innerHTML = "";
	document.getElementById('image').value = "";
}