// JavaScript



var evalCode = new Array();


function openWinOnCentre(url, w, h){
	window.open(url,'_blank','top='+(window.screen.height-h)/2+',left='+(window.screen.width-w)/2+',height='+h+',width='+w+',status = no,toolbar = no,scrollbars = no,titlebar=no,directories=no,resizable=no menubar=no,location=no');
	return;
}

function gen_link(url, type) {
	window.open(url, type);
	return;
}

function addCodeToLoad(code) {
     evalCode[evalCode.length] = code;
}

function bodyOnLoad() {
     for (i=0; i<evalCode.length; i++) {
          eval(evalCode[i]);
     }
}
//addCodeToLoad("document.all.ldn.style.display='none'");
//addCodeToLoad("myFunc()");
//onLoad="bodyOnLoad()"

function xajax_call(f_name, params, m_adress) {
	if (m_adress && m_adress!=null && m_adress != '')
		xajax.setRU(m_adress);
		
	xajax.call(f_name, params, null, null, 1);
	
	if (m_adress && m_adress!=null && m_adress != '')
		xajax.resetRU();
}

// Show pop-up image window
function showPhoto(url, width, height, title) {
  var top, left;
	
  top = Math.floor((screen.height - height) / 2-14);
  left = Math.floor((screen.width - width) / 2);
  imgparam = "left="+left+",top="+top+",height="+height+",width="+width+",location=0,scrollbars=no,toolbar=no,directories=no,menubar=no,status=no,resizable=yes";
  
  wnd = window.open("", "", imgparam);
  wnd.document.writeln("<html><head><title>"+title+"</title>");
  wnd.document.writeln("<script language='JavaScript'> function myClose() { window.close(); } </script>");
  wnd.document.writeln("</head><body bgcolor='#F1F2F4' leftmargin='0' topmargin='0' rightmargin='0' bottommargin='0' marginheight='0' marginwidth='0'>");
  wnd.document.write("<table width=100% height=100% cellpadding=0 cellspacing=0 border=0><tr><td align=center valign=middle>");
  wnd.document.write("<a href='javascript: myClose();'><img src='");
  wnd.document.write(url);
  wnd.document.writeln("' border='0' alt='' onLoad='window.resizeTo(this.width+10, this.height+35)'></a></td></tr></table>");
  wnd.document.writeln("</body></HTML>");
}

// Show pop-up flash window
function showFlash(url, width, height, title, fullscreen) {
  var top, left;
	
  top = Math.floor((screen.height - height) / 2-14);
  left = Math.floor((screen.width - width) / 2);
  if (fullscreen == true) imgparam = "left=0,top=0,height="+(screen.availHeight)+",width="+(screen.availWidth)+",location=0,scrollbars=yes,toolbar=no,directories=no,menubar=no,status=no,resizable=yes";
      else imgparam = "left="+left+",top="+top+",height="+height+",width="+width+",location=0,scrollbars=no,toolbar=no,directories=no,menubar=no,status=no,resizable=no";
  
  wnd = window.open("", "", imgparam);
  wnd.document.writeln("<html><head><title>"+title+"</title>");
  wnd.document.writeln("<script language='JavaScript'> function myClose() { window.close(); } </script>");
  wnd.document.writeln("</head><body bgcolor='#F1F2F4' leftmargin='0' topmargin='0' rightmargin='0' bottommargin='0' marginheight='0' marginwidth='0'>");
  wnd.document.write("<table width=100% height=100% cellpadding=0 cellspacing=0 border=0><tr><td align=center valign=middle>");
  wnd.document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">');
  wnd.document.write('<param name=bgcolor VALUE=#FFFFFF>');
  wnd.document.write('<param name="movie" value="'+url+'">');
  wnd.document.write('<param name="quality" value="high">');
  wnd.document.write('<embed src="'+url+'" quality="high" BGCOLOR=#FFFFFF pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>');
  wnd.document.write('</object>');
  //wnd.document.write(url);
  wnd.document.writeln("</td></tr></table>");
  wnd.document.writeln("</body></HTML>");
}

// Check required fileds
function checkFields(user_form, msg) {
	for (var i = 0; i < user_form.length; i++) {
		if (user_form[i].type == "text" || user_form[i].type == "textarea" || user_form[i].type == "password") {
			if (user_form[i].id == 1 && user_form[i].value == '') {
				if (msg != '') alert(msg);
				user_form[i].focus();
				return false;
			}
		}
	}
	
	return true;
}

// Is checkboxes selected
function validateCheckboxes(user_form, msg) {
	for (var i = 0; i < user_form.length; i++) {
		if (user_form[i].type == "checkbox") {
			if (user_form[i].checked == 1) return true;
		}
	}
	
	if (msg != '') alert(msg);
	return false;
}

// Check field
function validateField(field, error_message) {	
	if (field.value == '') {
		if (error_message != '') alert (error_message);
		field.focus();
		return false; 
	}
	
	return true; 
}

// Check only digits input
function onlyDigits() {
	with (window.event) {
		if (shiftKey)
			return false;
		if (
			(keyCode>=48 && keyCode<=57) ||
			keyCode == 9 ||
			keyCode == 116 ||
			keyCode == 8 ||
			keyCode == 13 ||
			keyCode == 39 ||
			keyCode == 37 ||
			keyCode == 190 ||
			keyCode == 191 ||
			keyCode == 46
			)
			return true;
		else
			return false;
	}
}

// Show DIV
function openDiv(layerID) {
	// get element by id
	if (window.document.all[layerID].style.display == 'none') {
		window.document.all[layerID].style.display = '';
	} else {
		window.document.all[layerID].style.display = 'none';
	}
}

// Show document in new window
function showDoc(filePath, width, height, title) {
	var top, left;
	top = Math.floor((screen.height - height) - (height / 2));
	left = Math.floor((screen.width - width) / 2);
	
	$fileType = filePath.substr(filePath.length - 3, 3);
	$fileType = $fileType.toLowerCase();
	
	if (!title) title = '';
	
 	switch($fileType) {
		case "swf" : 
			showFlash(filePath, width, height, title, true); 
			break
		case "gif" : 
			showPhoto(filePath, width, height, title);
			break
		case "jpg" : 
			showPhoto(filePath, width, height, title);
			break
		default:
			wparam = "left="+left+",top="+top+",height="+height+",width="+width+",location=0,scrollbars=yes,toolbar=no,directories=no,menubar=no,status=yes,resizable=yes";
			window.open(filePath, '', wparam);			
			break
	}
}

function validateRadio(user_form) {
	for (var i = 0; i < user_form.length; i++) {
		if (user_form[i].type == "radio") {
			if (user_form[i].checked == true) return true;
		}
	}
	
	return false;
}





function SetMenuPosition()
{
  if (document.body.clientWidth <= 985)
  {
    top_menu_layer.style.left = document.body.clientWidth - 550 - 200;
  }
  else
  {
    top_menu_layer.style.left = ( (document.body.clientWidth - 550 - 200) - (document.body.clientWidth - 550 - 200) % 1.15 ) / 1.15;
  }
}


function Change_Button_Image(name, id, over)
{
  if (over)
  {
	eval('document.'+name + id + '.src = document.'+name+'["o'+id+'"].src;');
  }
  else
  {
	eval('document.'+name + id + '.src = document.'+name+'['+id+'].src;');
  }

}

function onMouse(id, over, a, browser)
{
		//alert(browser)
  if (over)
  {
	Change_Button_Image('icon',id,1);
	show_hsubmenu(id, browser);
  }
  else
  {
    Change_Button_Image('icon',id,0);
	hide_hsubmenu(id);
  }
}



/*var hmenu_hide_delay = 100

function hide_hsubmenu(menu_id, hmenu_count)
{
	if (menu_id == "all")
	{
		for (i=1;i<=hmenu_count;i++)
		{
			(eval('hmenu'+i+'.style.display = \"none\";'));
		}
	}
	else
	{
		//alert('not')
		$timer_id = setTimeout("eval('hmenu"+menu_id+".style.display = \"none\";');", hmenu_hide_delay);
		//document.getElementById('hmenu'+menu_id).style.display = 'none';
	}
}*/





/*** Настройки для Всплывающего Меню ***/
/*** позиция 124x154 ширина 126 ***/
  //var hmenu_count = 7;
  var hmenu_bg_color = "#e0e0e0";
  var hmenu_top = 0;
  var hmenu_left = 154;
  var hmenu_width = 206;
  var hmenu_height = 200;
  var hmenu_hide_delay = 300;           //Задержка перед тем как убрать меню [в милисекундах]
  var hmenu_text_align = "right";
  var hmenu_text_valign = "middle";
  var hmenu_table_align = "right";
  var hmenu_table_valign = "middle";
  var $timer_id = 0;
/* !!!NEW!!! */
  var menu_font_family = "arial";
  var menu_font_style = "normal";
  var menu_font_weight = "normal";
  var menu_font_size = "11";
  var menu_font_color = "#a4b4cd";
  var menu_font_over_color = "#eb3d00";
  var menu_font_decoration = "none";
  var hover_menu_font_decoration = "none";
/* !!! END OF NEW!!! */
/***************************************/

for (i=1; i<=hmenu_count; i++)
{
  eval("HSubMenu"+i+" = new Array;");
}



function build_hmenu_style()
{
  hmenu_style = "<style>\n";
  hmenu_style += "#hmenu1";
  for (i=2;i<=hmenu_count;i++)
  {
    hmenu_style += ", #hmenu"+i;
  }  
  hmenu_style += "\n  {\n";
  hmenu_style += "    position : absolute;\n";
  hmenu_style += "    top : 0;\n";
  hmenu_style += "    width : " + hmenu_width + ";\n";
  hmenu_style += "    height : " + hmenu_height + ";\n";
  hmenu_style += "    z-index : "+(10*i)+";\n";
  hmenu_style += "    alfa : 50;\n";
  hmenu_style += "    display : none;\n";
  hmenu_style += "    text-align : " + hmenu_text_align + ";\n";
  hmenu_style += "  }\n\n";

  hmenu_style += ".hmenu_link, hmenu_link:activ, hmenu_link:visited\n";
  hmenu_style += "  {\n";
  hmenu_style += "    font-family : "+ menu_font_family+";\n";
  hmenu_style += "    font-style : "+menu_font_style+";\n";
  hmenu_style += "    font-weight : "+menu_font_weight+";\n";
  hmenu_style += "    font-size : "+menu_font_size+";\n";
  hmenu_style += "    text-decoration : "+menu_font_decoration+";\n";
  hmenu_style += "    color : "+menu_font_color+";\n";
  hmenu_style += "  }\n\n";

  hmenu_style += ".hmenu_link:hover\n";
  hmenu_style += "  {\n";
  hmenu_style += "    color : "+menu_font_over_color+";\n";
  hmenu_style += "    text-decoration : "+hover_menu_font_decoration+";\n";
  hmenu_style += "  }\n\n";
  hmenu_style += "</style>\n";
  document.write(hmenu_style);
}

function hide_hsubmenu(menu_id)
{
  if (menu_id == "all")
      {
        for (i=1;i<=hmenu_count;i++)
        {
          eval('hmenu'+i+'.style.display = \"none\";');
        }
      }
      else
      {
        $timer_id = setTimeout("eval('hmenu"+menu_id+".style.display = \"none\";');", hmenu_hide_delay);
      }
}




function show_hsubmenu(menu_id, browser)
{
	  hide_hsubmenu("all");
      if ($timer_id) { clearTimeout($timer_id); }
//      left_pos = ((document.body.clientWidth - 750) / 2) + 150 + ((menu_id - 1)*(hmenu_height+12));
      left_pos = (document.body.clientWidth - 200) - hmenu_width;
      top_pos = 280 + (menu_id - 1)*32 - hmenu_height;

//alert(browser)
if(browser=='ie')
	arr=[0, 75, 110, 145, 175, 230, 265, 270] //ie
else
	arr=[0, 75, 110, 140, 170, 222, 258, 250] // opera



	  if (menu_id == 4)
	  {
		top_pos += 6;
	  }
	  else
	    if (menu_id > 4)
    	  {
			top_pos += 17;
	      }

      eval('hmenu'+menu_id+'.style.left = left_pos;');
      eval('hmenu'+menu_id+'.style.top = arr['+menu_id+'];');
      eval('hmenu'+menu_id+'.style.display = "inline";');
}

function stop_hide()
{
  clearTimeout($timer_id);
}





function build_hsubmenu()
{
  for (i=1; i<=hmenu_count; i++)
  {
    hmenu  = '<div id=\"hmenu'+i+'\" align=\"' + hmenu_table_align + '\" valign=\"' + hmenu_table_valign + '\">\n';
    hmenu += '<table width=\"100%\" height=\"100%\">\n';
    hmenu += '<tr>\n';
//  hmenu += '  <td align=\"' + hmenu_text_align + '\" valign=\"' + hmenu_text_valign + '\" bgcolor=\"'+hmenu_bg_color+'\" onMouseOver=\"stop_hide()\" onMouseOut=\"hide_hsubmenu('+i+')\">\n';
    hmenu += '  <td align= valign=\"' + hmenu_text_valign + '\" onMouseOver=\"stop_hide()\" onMouseOut=\"hide_hsubmenu('+i+')\">\n';






/* *************************************************************** */
/* *************************************************************** */

    hmenu += '<table width="200" border="0" cellspacing="0" cellpadding="0">\n';
    hmenu += '  <tr>\n';
    hmenu += '    <td height="15" align="left" valign="top" style="background-image : url(\'../images/design/submenu/top_border.gif\'); background-position : top; background-repeat : repeat-x;" bgcolor="25415D"><img src="../images/design/submenu/top_left_corner.gif"></td>\n';
    hmenu += '    <td align="right" valign="top" style="background-image : url(\'../images/design/submenu/top_border.gif\'); background-position : top; background-repeat : repeat-x;" bgcolor="25415D"><img src="../images/design/submenu/top_right_corner.gif" width="24" height="5"></td>\n';
    hmenu += '    <td width="5" rowspan="3" align="right" valign="middle"><img src="../images/design/submenu/right.gif"></td>\n';
    hmenu += '  </tr>\n';
    hmenu += '  <tr>\n';
    hmenu += '    <td align="center" colspan="2" style="background-image : url(\'../images/design/submenu/left_border.gif\'); background-position : left; background-repeat : repeat-y;" bgcolor="25415D">\n';
    hmenu += '    <div style="margin-left : 12px; margin-right : 8px; color : #ffffff;">\n';
    hmenu += '<table width="175" border="0" cellspacing="0" cellpadding="0" bgcolor="25415D" style="background-image : url(\'../images/design/submenu/menu_bg.gif\'); background-position : top; background-repeat : repeat-y; color : #ffffff; font-size : 12px;">\n';
    hmenu += '  <tr>\n';
    hmenu += '    <td align="center" valign="bottom"><img src="../images/design/submenu/menu_top.gif"></td>\n';
    hmenu += '  </tr>\n';

/* */
/* *************************************************************** */   

    hmenu += '  <tr>\n';
    hmenu += '    <td align="center">' + eval("HSubMenu"+i+"[1]") + '</td>\n';
    hmenu += '  </tr>\n';

/* *************************************************************** */

/* *** */
/* *************************************************************** */

    hsubmenu_len = eval("HSubMenu"+i+".length");
    for(j=2;j<hsubmenu_len;j++)
    {
      hmenu += '  <tr>\n';
      hmenu += '    <td align="center"><img src="../images/design/submenu/menu_spliter.gif"></td>\n';
      hmenu += '  </tr>\n';
      hmenu += '  <tr>\n';
      hmenu += '    <td align="center">' + eval("HSubMenu"+i+"["+j+"]") + '</td>\n';
      hmenu += '  </tr>\n';
    }


/* *************************************************************** */
/* *** */

/* *************************************************************** */
    hmenu += '  <tr>\n';
    hmenu += '            <td align="center" valign="top"><img src="../images/design/submenu/menu_bottom.gif"></td>\n';
    hmenu += '  </tr>\n';
    hmenu += '</table>\n';
//  hmenu += '\n';
    hmenu += '    </div>\n';
    hmenu += '  </td>\n';
    hmenu += '  </tr>\n';
    hmenu += '  <tr>\n';
    hmenu += '    <td height="16" align="left" valign="bottom" style="background-image : url(\'../images/design/submenu/bottom_border.gif\'); background-position : bottom; background-repeat : repeat-x;" bgcolor="25415D"><img src="../images/design/submenu/bottom_left_corner.gif"></td>\n';
    hmenu += '    <td align="right" valign="bottom" style="background-image : url(\'../images/design/submenu/bottom_border.gif\'); background-position : bottom; background-repeat : repeat-x;" bgcolor="25415D"><img src="../images/design/submenu/bottom_right_corner.gif" width="25" height="7"></td>\n';
    hmenu += '  </tr>\n';
    hmenu += '</table>\n';

/* *************************************************************** */
/* *************************************************************** */



    hmenu += '  </td>\n';
    hmenu += '</tr>\n';
    hmenu += '</table>\n';
    hmenu += '</div>\n';
    //document.write(hmenu);
	//alert(hmenu)
  }
}


