// Modified by Shkodenko V. Taras 27/06/2006

/***********************************************
* Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
/*
NS6 = (document.getElementById&&!document.all); 
IE = (document.all); 
NS = (navigator.appName=="Netscape" && navigator.appVersion.charAt(0)=="4"); 

if (window.opera) { 
   IE = false; 
   NS6 = true; 
}
*/

// OPTIMIZATION  begin

function opa(a,b,c,d,e,m){
var aa = document.getElementById(a);
var bb = document.getElementById(b);
var cc = document.getElementById(c);
var dd = document.getElementById(d);
var ee = document.getElementById(e);
//alert (m);
aa.style.background = "#dadada";
bb.style.color  ="#6a6a6a";
cc.style.display = "none";
dd.style.display = "inline-block";
if (m == 1) ee.style.display = "inline-block";

}


function opb(a,b,c,d,e){
var aa = document.getElementById(a);
var bb = document.getElementById(b);
var cc = document.getElementById(c);
var dd = document.getElementById(d);
var ee = document.getElementById(e);

aa.style.background = "#da4e4f";
bb.style.color  ="#ffffff";
cc.style.display = "inline-block";
dd.style.display = "none";
ee.style.display = "none";

}

function opc(a,b,c,d,e,f,g,h){
var aa = document.getElementById(a);
var bb = document.getElementById(b);
var cc = document.getElementById(c);
var dd = document.getElementById(d);
var ee = document.getElementById(e);
var ff = document.getElementById(f);
var gg = document.getElementById(g);
var hh = document.getElementById(h);

aa.style.background="#dadada";
bb.style.display="none";
cc.style.display="inline-block";
dd.style.display="inline-block";
ee.style.color="#6a6a6a";
ff.style.background="#c90000";
gg.style.color="#ffffff";
hh.style.background="#c90000";

}

function opd(a,b,c,d,e,f,g,h){
var aa = document.getElementById(a);
var bb = document.getElementById(b);
var cc = document.getElementById(c);
var dd = document.getElementById(d);
var ee = document.getElementById(e);
var ff = document.getElementById(f);
var gg = document.getElementById(g);
var hh = document.getElementById(h);

aa.style.background="#da4e4f";
bb.style.display="inline-block";
cc.style.display="none";
dd.style.display="none";
ee.style.color="#ffffff";
ff.style.background="#dadada";
gg.style.color="#6B6B6B";
hh.style.background="#dadada";

}

function fop(a){
var aa = document.getElementById(a);
aa.style.background="#ffffff";
}
function fob(a){
var aa = document.getElementById(a);
aa.style.background="#dadada";
}
// OPTIMIZATION  end


function mnu(el,mmel,n) {

    var nel;

	var mind = document.getElementById(mmel);

	var m=n+1;
    if (navigator.appName=="Netscape") {
        nel=document.getElementsByName(el);
        nel=nel[0]; 
		nel.className=(nel.className=="vis1")?"vis2":"vis1";
        }
		
	else {
	
	for (var y=1; y<m; y++){
	var num = "qas"+y;
	ind = document.getElementById(num);
	//alert (mind+"!");
	if ((ind == mind) && (mind.style.display=="inline-block")) {mind.style.display="none"; break;}
	
	if (ind == null) break;
	
	if (ind != mind) ind.style.display="none"; 
	else {mind.style.display="inline-block";}
		//else { if (mind.style.display=="none") mind.style.display="inline-block"; else mind.style.display="none";}
	}
	
	//if (mind != null) {if (mind.style.display=="none") {mind.style.display="inline-block";} else {mind.style.display="none";}}
	}
	
    }
	

var defaultMenuWidth="80px"; //set default menu width
var defaultLeftPos  ="505"; //set default left position
var defaultTopPos   ="50px"; //set default top position

var left_pos=new Array();
var top_pos=new Array();
var m_width=new Array();
var linkset=new Array();
var it=new Array();

var defaultMenuWidtht="150px"; //set default menu width
var defaultLeftPost  ="228"; //set default left position
var defaultTopPost   ="101px"; //set default top position

var left_post=new Array();
var top_post=new Array();
var m_widtht=new Array();
var linksett=new Array();
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT
linkset[0]='';
linkset[1]='';
linkset[2]='';
linkset[3]='';
linkset[4]='';
linkset[5]='';
linkset[6]='';
linkset[7]='';
linkset[8]='';


linksett[0]='';
linksett[1]='';
linksett[2]='';
linksett[3]='';
linksett[4]='';

top_post[0]=99;
for (y=1; y<50; y++)
{
top_post[y]=top_post[y-1]+29;
}


top_pos[0]=defaultTopPos;
top_pos[1]=defaultTopPos;
top_pos[2]=defaultTopPos;
top_pos[3]=defaultTopPos;
top_pos[4]=defaultTopPos;
top_pos[5]=defaultTopPos;
top_pos[6]=defaultTopPos;
top_pos[7]=defaultTopPos;
/*
it[0]=482;
it[1]=389;
it[2]=296;
it[3]=203;
it[4]=110;
*/
it[0]=106;
it[1]=214;
it[2]=322;
it[3]=430;
it[4]=538;
it[5]=646;
it[6]=754;
it[7]=862;
it[8]=970;
it[9]=1078;
it[10]=1186;

left_pos[0]=470;
left_pos[1]=570;
left_pos[2]=688;
left_pos[3]=783;
left_pos[4]=878;
left_pos[5]=955;



////No need to edit beyond here
var ie5=document.all && !window.opera;
var ns6=document.getElementById;

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body;
}

if (ie5||ns6)
{
var draw_div = '<div id="popitmenu" style="position: absolute; left: 415px; top: 451px; z-index:10" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>';
 // alert(draw_div);
 document.write(draw_div);
}

function showmenu(e, which, t, bidman, optWidth)
{
/*
alert('e: '+e+', which: '+which+', optWidth: '+optWidth+', t: '+t+', left_pos['+t+']: '+left_pos[t]);
*/
//alert("Number: "+bidman);
if (!document.all&&!document.getElementById) return;
clearhidemenu();
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu");
menuobj.innerHTML=which;
menuobj.style.width=(typeof optWidth!="undefined")? m_width[t] : defaultMenuWidth;
//alert (document.body.clientWidth);
menuobj.style.left=(typeof t!="undefined")? (document.body.clientWidth-((bidman*110+103)-it[t])) : defaultLeftPos;
menuobj.style.top=(typeof t!="undefined")? top_pos[t] : defaultTopPos;
menuobj.contentwidth=menuobj.offsetWidth;
menuobj.contentheight=menuobj.offsetHeight;
eventX=ie5? event.clientX : e.clientX;
eventY=ie5? event.clientY : e.clientY;
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX;
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY;
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
{
 //move the horizontal position of the menu to the left by it's width
 // menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px";
}
else
{
  //position the horizontal position of the menu where the mouse was clicked
  // menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px";
}
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
{
 // menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px";
}
else
{
 // menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px";
}
menuobj.style.visibility="visible";
return false;
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------------------------------------------
function showmenu1(e, which, t, bidman, spartanci, da, db, optWidth)
{
//var mem=0;
//if (da == 1) mem = 9;
//if (da == 2) mem = 24;
//if (da > 2) da = 36;
//if (db == 1) db = 30;
//lert('e: '+e+', which: '+which+', optWidth: '+optWidth+', t: '+t+', left_pos['+t+']: '+left_pos[t]);

//alert (spartanci);
if (!document.all&&!document.getElementById) return;
clearhidemenu();
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu");
menuobj.innerHTML=which;
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidtht;
menuobj.style.left= defaultLeftPost;
menuobj.style.top=(typeof t!="undefined")? (bidman*23+150+(t)*21 + (da*6) + db*9) : defaultTopPost;
menuobj.contentwidth=menuobj.offsetWidth;
menuobj.contentheight=menuobj.offsetHeight;
eventX=ie5? event.clientX : e.clientX;
eventY=ie5? event.clientY : e.clientY;
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX;
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY;
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
{
 //move the horizontal position of the menu to the left by it's width
 // menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px";
}
else
{
  //position the horizontal position of the menu where the mouse was clicked
  // menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px";
}
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
{
 // menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px";
}
else
{
 // menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px";
}
menuobj.style.visibility="visible";
return false;
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------------------------------------------

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.menuobj) menuobj.style.visibility="hidden";
}

function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement)) hidemenu();
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget)) hidemenu();
}

function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500);
}

/*
function delaystr(){
delayhide=setTimeout("hidestr()",500);
}
function hidestr(haid){
var ee = document.getElementById(haid);
if (window.menuobj) ee.style.visibility="hidden";
}
*/


function clearhidemenu(){
if (window.delayhide) clearTimeout(delayhide);
}

// Added by Shkodenko V. Taras 27/06/2006
// Auto set left position of left menu in float tables
function t_auto_set_left_pos() {
  for(var i=0;i<top_pos.length;i++) {
    left_pos[i] = parseInt(defaultLeftPos);
    if(i>0) {
        for(var j=i; j>0; j--) {
            eval("left_pos["+i+"] += parseInt(document.getElementById('t"+j+"').offsetWidth)+5;");
        }
    }
  }
  
  for(var i=0;i<top_post.length;i++) {
	left_post[i] = parseInt(defaultLeftPost);
    if(i>0) {
        for(var j=i; j>0; j--) {
			eval("left_post["+i+"] += parseInt(document.getElementById('t"+j+"').offsetWidth);");
        }
    }
  }
  for(var t=0; t<left_pos.length; t++)
   left_pos[t] = left_pos[t]+"px";
  for(var t=0; t<left_post.length; t++)
   left_post[t] = left_post[t]+"px";

}

if (ie5||ns6)
document.onclick=hidemenu;