
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;	
if (InternetExplorer)
				var ie=1
				else
				var ie=0


var tempX = 0
var tempY = 0
var pos= new Object()
var ii=0

function getMouseXY(e) {
	
  if (IE) { // grab the x-y pos.s if browser is IE
  if (document.documentElement)
  	{
	var theTop = document.documentElement.scrollTop;
	var theLeft = document.documentElement.scrollLeft;
	}
	else if (document.body)
	{
	var theTop = document.body.scrollTop
	var theLeft = document.body.scrollLeft
	}

    tempX = event.clientX + theLeft
    tempY = event.clientY + theTop
//	 document.getElementById('temp').innerHTML=(ii++) + "=" + theLeft
//	alert (document.body.scrollTop)
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY

  pos.x = tempX
  pos.y = tempY
//  document.Show.MouseX.value = tempX
//  document.Show.MouseY.value = tempY
  return 
}



function ajax(url,data) {
		var h;
		if(window.ActiveXObject) {
			h = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
			h = new XMLHttpRequest();
		}
		h.open(data ? 'POST' : 'GET',url,false);
		h.send(data || null);
		return h.responseText;
	}

function getartdata(absnum,show,divname, url) {
	var div = document.getElementById(divname);	
	var posspan = document.getElementById('news_c');	
	
	if(show)
	{

		div.innerHTML = ajax(url+absnum+'.html');
		posspan.style.display = 'block';
		posspan.style.top=pos.y-70 + "px"
		posspan.style.left=pos.x-265 + "px"
//		alert(myp.x)
//		div.style.top = posspan.style.top + 40 + "px;";
//		div.style.left = posspan.style.left + "px;";
		
//		alert(div.style.top);
	}
	else
	{
		posspan.style.display = 'none';
		div.innerHTML = ''
	}
}


// JavaScript Document
function timeSource(){
   x=new Date(timeNow().getUTCFullYear(),timeNow().getUTCMonth(),timeNow().getUTCDate(),timeNow().getUTCHours(),timeNow().getUTCMinutes(),timeNow().getUTCSeconds());
   x.setTime(x.getTime()+7200000);
   return x;
}
function timeNow(){
   return new Date();
}
function leadingZero(x){
   return (x>9)?x:'0'+x;
}
function displayTime(){
   document.getElementById('disp').innerHTML=eval(outputTime);
   setTimeout('displayTime()',1000);
}
var outputTime="leadingZero(timeSource().getHours())+':'+leadingZero(timeSource().getMinutes())+':'+leadingZero(timeSource().getSeconds())";

function strt()
{
	displayTime();
}

function submit_form (id){
	  document.getElementById(id).submit();
}

function s_it()
{

	var col_l = document.getElementById('grey_one');
	var col_l_cl = document.getElementById('g_c_bl_g');
	var col_l_cr = document.getElementById('g_c_br_g');
	
	var col_c = document.getElementById('blue_one');
	var col_c_cl = document.getElementById('b_c_bl_b');
	var col_c_cr = document.getElementById('b_c_br_b');

	col_c.style.height= "auto"
	col_l.style.height= "auto"
	if (!col_l||!col_c)
		return
	var h_l= col_l.offsetHeight
	var h_c= col_c.offsetHeight

	if (h_l> h_c)
		{
		col_c.style.height= h_l+ "px"
		
		col_c_cl.style.top= h_l
		col_c_cr.style.top=h_l+ "px";
		}
	else
	{
		col_l.style.height= h_c+ "px"
	}
}

// ----- Show Aux -----

function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

var it=0
for (; p; p = p.offsetParent)
  {
	  if (it<2)
	  {
    top  += p.offsetTop;
    left += p.offsetLeft;
	  }
	it++
  }

//    top  += p.offsetTop;
//    left += p.offsetLeft;

  c.style.position   = "absolute";
  c.style.top        = (top-6) +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ----- Show -----

function at_show()
{
  p = document.getElementById(this["at_parent"]);
  c = document.getElementById(this["at_child" ]);

  at_show_aux(p.id, c.id);

  clearTimeout(c["at_timeout"]);
}

// ----- Hide -----

function at_hide()
{
  c = document.getElementById(this["at_child"]);

  c["at_timeout"] = setTimeout(hideall, 333, this["at_child"]);
}

function hideall(ob) {

	document.getElementById(c.id).style.visibility = 'hidden'
  	document.getElementById('a_up').style.visibility = "hidden"
	document.getElementById('a_dn').style.visibility = "visible"
	}
// ----- Click -----

function at_click()
{
  p = document.getElementById(this["at_parent"]);
  c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible")
  	{
  	at_show_aux(p.id, c.id);
	document.getElementById('a_dn').style.visibility = "hidden"
	document.getElementById('a_up').style.visibility = "visible"
	}
  else 
  {
  c.style.visibility = "hidden";
  	document.getElementById('a_up').style.visibility = "hidden"
	document.getElementById('a_dn').style.visibility = "visible"
  }

  return false;
}

// ----- Attach -----

// PARAMETERS:
// parent   - id of visible html element
// child    - id of invisible html element that will be dropdowned
// showtype - "click" = you should click the parent to show/hide the child
//            "hover" = you should place the mouse over the parent to show
//                      the child
// position - "x" = the child is displayed to the right of the parent
//            "y" = the child is displayed below the parent
// cursor   - Omit to use default cursor or check any CSS manual for possible
//            values of this field

function at_attach(parent, child, showtype, position, cursor)
{
  p = document.getElementById(parent);
  c = document.getElementById(child);


  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onmousedown   = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
	  c.onclick     = at_click;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}

function change_it(obj) {
	p.innerHTML= obj.innerHTML
	return false
	}
	
 function picture_DoFSCommand(command, args) {
	var fscommandObj = InternetExplorer ? picture : document.picture;
document.picture.SetVariable("fs_st", 1);
if (command == "rsize") { 
	newSize(args)
	}

}

// Hook for Internet Explorer
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
 document.write('<SCRIPT LANGUAGE=VBScript\> \n');
 document.write('on error resume next \n');
 document.write('Sub picture_FSCommand(ByVal command, ByVal args)\n');
 document.write('  call picture_DoFSCommand(command, args)\n');
 document.write('end sub\n');
 document.write('</SCRIPT\> \n');
}



function newSize(datoY, id) {

	if (id>0)
		var obj=id
	else
		var obj=""

		document.getElementById('miFlash' +obj).style.height = datoY+ "px";
		
		document.getElementById('ftab' +obj).style.height = datoY+ "px";
		document.getElementById('picture' +obj).style.height = datoY+ "px";
//		alert (document.getElementById('picture2'))
		if (document.getElementById('picture2' +obj))
			document.getElementById('picture2' +obj).style.height = datoY+ "px";
}
	
function  embedFlash_list(fileName, lib, tm, w, h, id)
{

/*
(c) Flash ActiveX IE fix by Ivan Turuk. http://www.newagelab.com
Put this function in external js file

fileName - path to flash file
lib - flash variables
tm - flash timestamp for anticaching
w - width
h - height
*/

var flob='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+w+'" height="'+h+'" id="picture'+id+'" align="middle">';
flob+='<param name="allowScriptAccess" value="sameDomain" />';
flob+='<param name="movie" value="'+fileName+'?' + tm + '" />';
flob+='<param name="quality" value="high" />';
flob+='<PARAM NAME=FlashVars VALUE="'+lib+'">';
flob+='<PARAM NAME=wmode VALUE="transparent">';
flob+='<param name="bgcolor" value="#eaeff4" />';
flob+='<embed src="'+fileName+'?' + tm + '" quality="high" wmode="transparent" FlashVars="'+lib+'" bgcolor="#eaeff4" width="'+w+'" height="'+h+'" name="picture2'+id+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
flob+='</object>';
document.write(flob);
}

function  embedFlash(fileName, lib, tm, w, h, id)
{

/*
(c) Flash ActiveX IE fix by Ivan Turuk. http://www.newagelab.com
Put this function in external js file

fileName - path to flash file
lib - flash variables
tm - flash timestamp for anticaching
w - width
h - height
*/
if (id=="undefined"||id==null)
id=""
var flob='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+w+'" height="'+h+'" id="picture'+id+'"  align="middle">';
flob+='<param name="allowScriptAccess" value="sameDomain" />';
flob+='<param name="movie" value="'+fileName+'?' + tm + '" />';
flob+='<param name="quality" value="high" />';
flob+='<PARAM NAME=FlashVars VALUE="'+lib+'">';
flob+='<PARAM NAME=wmode VALUE="transparent">';
flob+='<param name="bgcolor" value="#eaeff4" />';
flob+='<embed src="'+fileName+'?' + tm + '" quality="high" wmode="transparent" FlashVars="'+lib+'" bgcolor="#eaeff4" width="'+w+'" height="'+h+'" name="picture2'+id+'"  id="picture2'+id+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
flob+='</object>';
document.write(flob);
}

function sw_tab (aobj, holder) {
	
	var j=0
//	alert (document.getElementById(holder+"_"+ j))
if (typeof(aobj)=="string")
aobj = document.getElementById(aobj )
	while (document.getElementById(holder+"_"+ j)&& document.getElementById(holder+"_"+ j)!="undefined"){
		if (document.getElementById(holder+"_"+ j)!=aobj)
		{
		document.getElementById(holder+"_"+ j).className = 'mtab'
		document.getElementById(holder+"_h_"+ j).style.display = 'none'
		}
		else 
		{
			document.getElementById(holder+"_h_"+ j).style.display = 'block'
			}
		j++
		}
//	alert (aobj.id)
	aobj.className = 'mtab_s'
	aobj.blur()
//	return false
}


function sw_rtab (aobj, holder) {

	
	var j=0
//	alert (document.getElementById(holder+"_"+ j))
if (typeof(aobj)=="string")
aobj = document.getElementById(aobj )
	while (document.getElementById(holder+"_"+ j)&& document.getElementById(holder+"_"+ j)!="undefined"){
		if (document.getElementById(holder+"_"+ j)!=aobj)
		{
		document.getElementById(holder+"_"+ j).className = 'rtab'
		document.getElementById(holder+"_h_"+ j).style.display = 'none'
		}
		else 
		{
			document.getElementById(holder+"_h_"+ j).style.display = 'block'
			}
		j++
		}
//	alert (aobj.id)
	var hobj=document.getElementById("ms_2")
if (aobj.id=="ms_2_0")
	hobj.className = 'mtab_holder_l'
else	
	hobj.className = 'mtab_holder_r'
//	aobj.className = 'rtab_s'
	aobj.blur()
//	return false
}

function item_show (aobj, holder) {
	var j=0
	var was = document.getElementById(holder+"_"+ aobj + "_but").className
	while (document.getElementById(holder+"_"+ j) && document.getElementById(holder+"_"+ j) != "undefined"){
		if (document.getElementById(holder+"_"+ j + "_img"))	
			document.getElementById(holder+"_"+ j + "_img").style.display = 'none'
		if (document.getElementById(holder+"_"+ j + "_header"))	
			document.getElementById(holder+"_"+ j + "_header").style.display = 'none'
		if (document.getElementById(holder+"_"+ j + "_but"))	
			document.getElementById(holder+"_"+ j + "_but").className = 'butt_p'
		j++	
	}

	if (was=="butt_p") {
		var ob_l =document.getElementById(holder+"_"+ aobj + "_but")
		var ob_im =document.getElementById(holder+"_"+ aobj + "_img")
		var ob_head =document.getElementById(holder+"_"+ aobj + "_header")
		if (ob_l) ob_l.className="butt_m"
		if (ob_im) ob_im.style.display = 'block'
		if (ob_head) ob_head.style.display = 'block'
	}
	var ob_l =document.getElementById(holder+"_"+ aobj + "_but").blur()
	return false
}

function item_show_arr(aobj, holder, arr) {
	var j=1

	var was = document.getElementById(holder+"_"+ arr[aobj] + "_but").className;

	while (document.getElementById(holder+"_"+ arr[j]) && document.getElementById(holder+"_"+ arr[j]) != "undefined"){
		if (document.getElementById(holder+"_"+ arr[j] + "_img"))	
			document.getElementById(holder+"_"+ arr[j] + "_img").style.display = 'none'
		if (document.getElementById(holder+"_"+ arr[j] + "_header"))	
			document.getElementById(holder+"_"+ arr[j] + "_header").style.display = 'none'
		if (document.getElementById(holder+"_"+ arr[j] + "_but"))	
			document.getElementById(holder+"_"+ arr[j] + "_but").className = 'butt_p'
		j++	
	}

	if (was=="butt_p") {
		var ob_l =document.getElementById(holder+"_"+ arr[aobj] + "_but")
		var ob_im =document.getElementById(holder+"_"+ arr[aobj] + "_img")
		var ob_head =document.getElementById(holder+"_"+ arr[aobj] + "_header")
		if (ob_l) ob_l.className="butt_m"
		if (ob_im) ob_im.style.display = 'block'
		if (ob_head) ob_head.style.display = 'block'
	}
	var ob_l =document.getElementById(holder+"_"+ arr[aobj] + "_but").blur()
	return false
}

function sw_tab_arr (aobj, holder, arr) {
	var j=0;
	while (document.getElementById(holder+"_"+ arr[j])&& document.getElementById(holder+"_"+ arr[j])!="undefined"   ) {
		if (document.getElementById(holder+"_"+ arr[j]) != aobj) {
			document.getElementById(holder+"_"+ arr[j]).className = 'mtab'
			document.getElementById(holder+"_"+ arr[j]+"_cont").style.display = 'none'
		} else {
			document.getElementById(holder+"_"+ arr[j]+"_cont").style.display = 'block'
		}
		j++;
	}
	aobj.className = 'mtab_s'
	aobj.blur()
	return false
}


function  embedFlash_video(fileName, lib, tm, h) {
		if (h=="undefined"||h=='')
		 h=400
		var flob='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="'+h+'" id="vid" align="middle">';
		flob+='<param name="allowScriptAccess" value="sameDomain" />';
		flob+='<param name="movie" value="'+fileName+'?' + tm + '" />';
		flob+='<PARAM NAME=FlashVars VALUE="file='+lib+'">';
		flob+='<param name="quality" value="high" />';
		flob+='<param name="wmode" value="window" />';
		flob+='<param name="bgcolor" value="#ffffff" />';
		flob+='<embed src="'+fileName+'?' + tm + '" quality="high" FlashVars="file='+lib+'" bgcolor="#ffffff" wmode="transparent" width="100%" height="'+h+'" name="vid" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		flob+='</object>';

		document.write(flob);
	}
	
	function show_friend() {
	var f_div = document.getElementById('friend');
	f_div.style.display = 'block';
}

function testMailAndPopup(email, msg){
	var splitted = email.match("^(.+)@(.+)$");
	if(splitted == null) {
		alert(msg);
		return false;
	}
	if(splitted[1] != null) {
		var regexp_user=/^\"?[\w-_\.]*\"?$/;
		if(splitted[1].match(regexp_user) == null) {
			alert("{%$phrase.errors.emailhost%}");
			return false;
		}
	}
	if(splitted[2] != null) {
		var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
		if(splitted[2].match(regexp_domain) == null) {
			var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
			if(splitted[2].match(regexp_ip) == null) {
				alert("{%$phrase.errors.emailhost%}");
				return false;
			}
		}
		var w = 260;
		var h = 180;
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		if (navigator.appName=="Netscape") {
			winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',toolbar=no,' +
			'location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
		} else {
			winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',toolbar=no,' +
			'location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no';
		}
		win = window.open( 'about:blank', 'popup', winprops);
		document.forms['sendform'].target = 'popup';
		return true;
	}
	alert(msg);
	return false;
}



// Function to set a cookie.
//---------------------------------------------------------------------
function SetCookie( name, value )
{
    var argv    = SetCookie.arguments;
    var argc    = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path    = (argc > 3) ? argv[3] : null;
    var domain  = (argc > 4) ? argv[4] : null;
    var secure  = (argc > 5) ? argv[5] : false;

    document.cookie =
        name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}

function GetCookie (name)
{
    var arg  = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i    = 0;

    while (i < clen)
    {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
          return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}
//---------------------------------------------------------------------
// Function to get a cookie.
//---------------------------------------------------------------------
function getCookieVal( offset )
{
    var endstr = document.cookie.indexOf (";", offset);

    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function mkhttp(url, data, handler) {
	var x;
	if(window.ActiveXObject) {
		x = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		x = new XMLHttpRequest();
	}
	x.open(data?'POST':'GET', url, (typeof(handler) != 'undefined' && handler)?true:false);
	x.send(typeof(data) != 'undefined'? data : null);
	if(handler) {
		if(typeof(x.onload) != 'undefined') {
			x.onload = function(ev) { handler(x); }
		} else {
			x.onreadystatechange = function() { if(x.readyState == 4) handler(x); }
		}
	}
	return x;
}

function update_comments(sock) {
	document.getElementById('comment_canvas').innerHTML = sock.responseText;
}

function set_comments_order(or,url) {
	document.cookie = 'c_or='+or+'; expires = Mon, 31 Dec 2026 23:59:59 UTC';
	mkhttp(url, null, update_comments);
}


function swich_submenu(absnum)
{
	/*if (absnum==null or absnum==0)
		absnum = 1;*/
	//alert(absnum);	
	var is_checked  = document.getElementById('submenu'+absnum).style.display;
	if (is_checked=='none')
		document.getElementById('submenu'+absnum).style.display = 'block';
	else
		document.getElementById('submenu'+absnum).style.display = 'none';
	return false;
}

function Popup(url,w,h){
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	if (navigator.appName=="Netscape") {
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',toolbar=no,' +
		'location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
	} else {
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',toolbar=no,' +
		'location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no';
	}
	win = window.open( url, 'popup', winprops);
	win.focus();
	return true;
}

function show_header(header_id,show) {
     var div = document.getElementById('to_inn');     
     var posspan = document.getElementById('news_c');     
     
     if(show)
     {

          div.innerHTML = document.getElementById(header_id).innerHTML;
          posspan.style.display = 'block';
          posspan.style.top=pos.y-70 + "px"
          posspan.style.left=pos.x-265 + "px"
//          alert(myp.x)
//          div.style.top = posspan.style.top + 40 + "px;";
//          div.style.left = posspan.style.left + "px;";
          
//          alert(div.style.top);
     }
     else
     {
          posspan.style.display = 'none';
          div.innerHTML = ''
     }
}
