var DOM = (typeof(document.getElementById) != 'undefined');

function GetObj(objId){
	if(!DOM) return false;	
	return document.getElementById(objId);
}

function Trim(str){
	if(str == undefined) return;
	
	str=str.replace(/ +$/, "");
	str=str.replace(/^ +/, "");	
	return str;
}

function ShowImg(path, width, height){
	margin_left = GetScreenMargin(self.screen.width, width);
	margin_top = GetScreenMargin(self.screen.height, height);

	window.open(path, 'fullimg', 'left=' + margin_left + ',top=' + margin_top + ',width='+width+',height='+height+',menubar=no,scrollbars=no,status=no');
}

var theMapWin;
function ShowMap(path){
	width = 400;
	height = 400;

	if (theMapWin != null){
		if (!theMapWin.closed){
			theMapWin.focus();
			return;
		}
	}
	
	margin_left = GetScreenMargin(self.screen.width, width);
	margin_top = GetScreenMargin(self.screen.height, height);

	theMapWin = window.open(path, 'fullmap', 'left=' + margin_left + ',top=' + margin_top + ',width='+width+',height='+height+',menubar=no,scrollbars=no,status=no');
}

function GetScreenMargin(screen, popup){
	if(popup > screen) return 0;
	margin = screen - popup;
	margin = margin/2;
	margin = Math.round(margin);
	return margin;
}

function ShowPopup(path, width, height, name, scroll, add_param){
	if(scroll == 'undefined') scroll = 'no';
	margin_left = GetScreenMargin(self.screen.width, width);
	margin_top = GetScreenMargin(self.screen.height, height);
	param = 'left=' + margin_left + ',top=' + margin_top + ',width=' + width + ',height=' + height + ',menubar=no,scrollbars=' + scroll + ',status=no';
	if(add_param != 'undefined') param += add_param;
	window.open(path, name, param);
}

function GetAbsoluteTop(obj){
   var result = 0;
   while(obj.tagName != 'BODY'){
     result += obj.offsetTop;
     obj = obj.offsetParent;
   }
   
   return result;
}

function GetAbsoluteLeft(obj){
   var result = 0;
   while(obj.tagName != 'BODY'){
     result += obj.offsetLeft;
     obj = obj.offsetParent;
   }
   
   return result;
}

function CheckOrderMode(obj){
	if(obj.value != -1){
		GetObj('o_mode').disabled = false;
	}
	else{
		GetObj('o_mode').disabled = true;
	}
}

function DisplHideAF(id_name){
	obj = GetObj(id_name);

	if(!obj) return;
	if(obj.style.display == 'none'){
		obj.style.display = '';
	}
	else{
		obj.style.display = 'none';
	}
	
}

function GetFlash(path, width, height, link, parametr){
	if(link){
		if(parametr != ''){parametr += '&';}
		parametr += 'link='+link;
	}	
	document.open();
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="6,0,0,0" WIDTH="'+width+'" HEIGHT="'+height+'">');
	document.write('<PARAM NAME="wmode" VALUE="transparent">');	
	document.write('<PARAM NAME="movie" VALUE="' + path + '">');
	document.write('<PARAM NAME="quality" VALUE="high">');
	document.write('<PARAM NAME="FlashVars" VALUE="' + parametr + '">');
	document.write('<EMBED src="' + path + '" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" WIDTH="' + width + '" HEIGHT="' + height + '" FlashVars="' + parametr + '" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>');
	document.write('</OBJECT>');
	document.close();
}

function RefreshAntispam(path, objId){
	if(!DOM) return false;
	antispam = GetObj(objId);
	path = path + '?rnd='+Math.random();
	antispam.src=path;
}

	function printit(){ 
		if (window.print){
			window.print() ; 
		}
		else {
			var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
			document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
			WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = ""; 
		}
	}

function showFilled(Value) {
  return (Value > 9) ? "" + Value : "0" + Value;
}
function StartClock24() {
  TheTime = new Date;
  document.clock.showTime.value = showFilled(TheTime.getHours()) + ":" + showFilled(TheTime.getMinutes()) + ":" + showFilled(TheTime.getSeconds());
  setTimeout("StartClock24()",1000)
}
