var xcol_cur_menu = null;
var xcol_cur_submenu = null;

//serg
// стили для меню
var main_on ="mb_on";
var main_off="mb_off";
var main_act="mb_act"

var sub_on="ms_on";
var sub_off="ms_off";
var sub_act="ms_act";

var hide_table="hide_table";
var show_table="show_table";

var menu_timer = null;
var menu_delay = 2000;

var mm=null;    // пункт по-умолчанию
var sm=null;    // подпункт по-умолчанию

function _menu_over(n,s,hash) {

	clearTimeout(menu_timer);

	if (!n) {
		nc=document.getElementsByName("main_menu");
		t=document.getElementsByName("sub_menu");
		if(nc && t){
			for(i=0;i<nc.length;i++){
				nc.item(i).className=main_off;
				t.item(i).className=hide_table;
			}
		}
		return true;
	}

 	if (n) {
		nc=document.getElementsByName("main_menu");
		t=document.getElementsByName("sub_menu");
		
		if(nc && t){
			for(i=0;i<nc.length;i++){
				nc.item(i).className=main_off;
				t.item(i).className=hide_table;
			}
			nc.item(n-1).className=main_on;
			//t.item(n-1).style.left = GetElementCoords(nc.item(n-1))+10;
			t.item(n-1).className =show_table;
			if (mm) nc.item(mm-1).className=main_act;
		}
	}

	if (s) {
		sb=document.getElementsByName("sub"+n);
		if (sb)	{
			for(i=0;i<sb.length;i++) sb.item(i).className="ms_off";
			sb.item(s-1).className="ms_on";
		}
	}

	if (mm==n && s) {
		sb=document.getElementsByName("sub"+n);
		if (sb) sb.item(sm-1).className="ms_act";
	}
}

function _menu_out(delay) {	
	if (!delay) delay=menu_delay;
	menu_timer = window.setTimeout("_menu_over(mm,sm);", delay)
	window.defaultStatus = '';
}

function _menu_sub_over(obj) {
	clearTimeout(menu_timer);
	if (obj.className==sub_off) obj.className=sub_on;
}

function _menu_sub_out(obj) {
	if (obj.className==sub_on) obj.className=sub_off;
	_menu_out(menu_delay);
}


function GetElementCoords(elmnt) {
		var ret = new Array();
		var x=0;
		var y=0+elmnt.offsetHeight;
		do {
			x+=elmnt.offsetLeft;
			y+=elmnt.offsetTop;
		} while (elmnt=elmnt.offsetParent);
		ret['x'] = x;
		ret['y'] = y;
		return ret;
}

function show(id) {
	if (!isDOMcompliant()) { return; }

  var menu = document.getElementById("Menu" + id);
  var submenu = document.getElementById("submenu" + id);
	
	if (!submenu) submenu= document.getElementById("submenu_empty");

	if (submenu) {
		submenu.style.display='none';
		submenu.style.visibility = "visible";
//		submenu.style.top = 0;
//		submenu.style.top = GetElementCoords(document.getElementById("Menu0"))['y'];
		//alert(GetElementCoords(document.getElementById("Menu0"))['y']);
			if (xcol_cur_submenu == null) {
					submenu.style.display='block';
					submenu.style.visibility = "visible";
			} 
			else {
				xcol_cur_submenu.style.diplay = "none";
				xcol_cur_submenu.style.visibility = "hidden";
				submenu.style.display='block';
				submenu.style.visibility = "visible";
			}
	}


	if (xcol_cur_menu == null) {
// m3
			menu.style.color = "#00175C";
//			menu.style.backgroundColor = "#E10778";
//			menu.style.color = "#FFFFFF";
	} else {
//	m2
//			xcol_cur_menu.style.backgroundColor = "#DCDCDC";
//			xcol_cur_menu.style.color = "#E10778";
			xcol_cur_menu.style.color = "#FFFFFF";
//			menu.style.backgroundColor = '#E10778';
//			menu.style.color = '#FFFFFF';
			menu.style.color = '#00175C';
	}
	xcol_cur_menu = menu;
	xcol_cur_submenu = submenu;
}



function unshow() {
    if (!isDOMcompliant()) { return; }
    if (xcol_cur_submenu != null) {
        xcol_cur_submenu.style.visibility = "hidden";
    }
    if (xcol_cur_menu != null) {
        xcol_cur_menu.style.backgroundColor = "#036";
        xcol_cur_menu.style.color = "#FFF";
    }
    xcol_cur_submenu = null;
    xcol_cur_menu = null;
}


function isDOMcompliant() {
    return document.getElementById && document.getElementsByTagName;
}

function xcShowLoginDiv () {
    if (!document.getElementById) return true;
    var notloge = document.getElementById("NotLoggedInDiv");
    var logboxe = document.getElementById("LoginBox");
    var xcusere = document.getElementById("xc_user");
    if (!notloge || !logboxe || ! xcusere) return true;
    notloge.style.display = 'none';
    logboxe.style.display = 'block';
    xcusere.focus();
    return false;
}

var showNothing = function () { show(0) };

//if (window.attachEvent) window.attachEvent("onload", showNothing);
//if (window.addEventListener) window.addEventListener("load", showNothing, false);

































// стили для меню
var PhotoBig=null;

/////////////////////

function fMakePopUpWindow(handler,url,windowName,width,height,toolbar,location,directories,status,menubar,scrollbars,resizable,top,left) {
	if (!handler) var handler=null;
	if (!windowName) title='no_windowName';
	if (!width) width=400;
	if (!height) height=400;

  var x=(typeof(left)=='undefined')?(screen.availWidth - width)/2   : left;
  var y=(typeof(top) =='undefined')?(screen.availHeight - height)/2 : top;

	var windowFeatures = "width=" +width+ ",height=" +height+ ",screenX=" +x+ ",screenY=" +y+ ",top=" +y+ ",left=" +x+ ",toolbar="+toolbar+",location="+location+",directories="+directories+",status="+status+",menubar="+menubar+",scrollbars="+scrollbars+",resizable="+resizable;
	handler=window.open(url,windowName,windowFeatures);
	handler.focus();
	return handler;
}

function fShowScreenShots(type,content_id) {
	fMakePopUpWindow(JavaSShots,'/java_screens.php?type='+type+'&serial='+content_id,'ScreenShots',560,160,0,0,0,0,0,1,1);
}

function splitString (stringToSplit,separator) {
   arrayOfStrings = stringToSplit.split(separator)
   document.write('<P>The original string is: "' + stringToSplit + '"')
   document.write('<BR>The separator is: "' + separator + '"')
   document.write("<BR>The array has " + arrayOfStrings.length + " elements: ") 

   for (var i=0; i < arrayOfStrings.length; i++) {
      document.write (arrayOfStrings[i] + " / ")
   }
} 

function fChangeLanguage(lang_id) { 	// lang fix
	var temp_array = document.cookie.split('; ');
	var temp_string='';
  for (var i=0; i < temp_array.length; i++) {
		//if (temp_array[i].indexOf('lang=') != -1) { temp_array.splice(i, 1); i--; }
		if (temp_array[i].indexOf('lang=') != -1) temp_array[i]='';
		
		//if (temp_array[i].indexOf('lang=')== -1) temp_string=concat(temp_string,temp_array[i],'; ');
	}
	var temp_string=temp_array.join("; ");
	document.cookie=temp_string;
	//
	deleteCookie('lang');
	SetCookie('lang',lang_id,365);
	top.location.reload();
}



function FitPic() {
	var NS=document.all;

	window.moveTo(0, 0)

	var left_border=12;
	var top_border=51;

	maxWidth=screen.width-left_border;
	maxHeight=screen.height-top_border;

	iWidth = (!NS)?window.innerWidth:document.body.clientWidth; 
	iHeight = (!NS)?window.innerHeight:document.body.clientHeight; 

	imageWidth = document.images[0].width; 
	imageHeight = document.images[0].height; 

	var newWidth= (imageWidth >maxWidth)?maxWidth :imageWidth;
	var newHeight=(imageHeight>maxHeight)?maxHeight : imageHeight;

	//var newWidth	=(imageWidth >(maxWidth-left_border)?maxWidth :imageWidth +left_border)+(imageHeight>(maxHeight-top_border) ?scroll_bar:0);
	//var newHeight =(imageHeight>(maxHeight-top_border)?maxHeight:imageHeight+top_border) +(imageWidth >(maxWidth -left_border)?scroll_bar:0);		

	window.resizeTo(newWidth+left_border, newHeight+top_border); 

	if (!NS) { 
		window.moveTo((self.screen.width - self.outerWidth)/2, (self.screen.height - self.outerHeight)/2);
	} 
	else {
		self.moveTo((self.screen.width-document.body.clientWidth)/2, (self.screen.height-document.body.clientHeight)/2);
	} 
	self.focus();
}

function OnPhotoClick(photo) {
	width=400;
	height=400;
	//width=(photo.width<document.body.clientWidth?photo.width:600);
	//height=(photo.height<document.body.clientHeight?photo.height:500);
	if (PhotoBig) PhotoBig.close();
	PhotoBig=fMakePopUpWindow(PhotoBig,'about:blank','Photo',width,height,0,0,0,0,0,0,1);
//	PhotoBig=fMakePopUpWindow(PhotoBig,'/photos_fullview.php?photo_src='+escape(photo.src),'PhotoViewer',width,height,0,0,0,0,0,1,1,0,0);
	PhotoBig.document.write("<html><head><SCRIPT language='JavaScript' src='js/menu.js' type='text/javascript'></SCRIPT></head><body topmargin='0' bottommargin='0' leftmargin='0' rightmargin='0' marginheight='0' marginwidth='0' bgcolor='#ffffff' onload='FitPic();'><center><img id='photo' src=upload/"+photo+" onclick='window.close()' style='cursor:hand'></center></body></html>");
	PhotoBig.document.close();
}

var PhotoBig=null;

// photos
function mo(o) { o.className=='sx'?o.className='so': o.className=o.className; }
function mx(o) { o.className=='so'?o.className='sx': o.className=o.className; }
function mc(o) { o.className='sc'; }
//
