win = null;

function setWidth()
{
	// test if this is IE
	// and do this workaround only for IE
	browser_version= parseInt(navigator.appVersion);
	browser_type = navigator.appName;
	
	if(browser_type == "Microsoft Internet Explorer")
	{
		var browser_width = 0;
		if( document.documentElement && document.documentElement.clientWidth ) {
		    //IE 6+ in 'standards compliant mode'
		    browser_width = document.documentElement.clientWidth;
		  } else if( document.body && document.body.clientWidth) {
		    //IE 4 compatible
		    browser_width = document.body.clientWidth;
		  }
  
		// var w=document.getElementById('toppanel').offsetWidth;
		mw = (browser_width > 1024 )? 1024 : ((browser_width < 800) ? 800 : browser_width);
		document.getElementById('content').style.width = mw;
		
		// var w1=document.getElementById('main').offsetWidth;
		//mw1 = (browser_width > 1024 )? 1024 : ((browser_width < 800) ? 800 : browser_width);
		//document.getElementById('main').style.width = mw1;
	}
	
	window.status = "Welcome to Farfence Software";
}

// Scanning. Check document every so often until it has finished loading. Do
// nothing until the 'content' div arrives, then stop scanning.

var minmax_SCANDELAY= 500;

var minmax_scanner;

function minmax_scan() {
	if (!document.getElementById('content')) return;
	window.clearInterval(minmax_scanner);
	setWidth();
}

minmax_scan();
minmax_scanner= window.setInterval(minmax_scan, minmax_SCANDELAY);

function exitPage()
{
	// if there is any popups that has been opened, close it
	if(win !=  null)
    	{
    		if(!win.closed)
    		{
    			win.close();
    		}
    	}
}

function checkEnter(e)
{
		var characterCode;
			 var code;
			 if (!e) var e = window.event;
			 if (e.keyCode) code = e.keyCode;
			 else if (e.which) code = e.which;
			 	 
			 if(code == 13){
		 	 encryptLoginPassword(document.forms['loginform']);
		 	 return false;
			 }
		return true;
}

function checkEnterAddMod(e)
{
	var characterCode;
 	var code;
 	if (!e) var e = window.event;
 	if (e.keyCode) code = e.keyCode;
 	else if (e.which) code = e.which;
 	 
 	if(code == 13){
 	 	document.forms['emailalert'].submit();
	return false;
 }
	return true;
}

function checkEnterSearch(e)
{
	var code;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
		 	 
	if(code == 13){
		document.forms['search'].submit();
		return false;
	}
	
	return true;
}
