function getAnchorPosition( anchorname ) {
	var useWindow = false;
	var coordinates = new Object();
	var x = 0;
	var y = 0;
	var use_gebi = false;
	var use_css = false;
	var use_layers = false;
	if( document.getElementById )
	{
		use_gebi = true;
	}
	else if( document.all )
	{
		use_css = true;
	}
	else if( document.layers )
	{
      use_layers = true;
	}
	if( use_gebi && document.all )
	{
		var o = document.getElementById( anchorname );
		x = AnchorPosition_getPageOffsetLeft( document.all[ anchorname ] );
      	y = AnchorPosition_getPageOffsetTop( document.all[ anchorname ] );
      	/*if ( br.is_ie6 || br.is_ie5 ) {
      		y = o.offsetTop;
      	} /*/
   }
	else if( use_gebi )
	{
		var o = document.getElementById( anchorname );
  	   if(o != null) {
			x = o.offsetLeft;
			y = o.offsetTop;
		}
	}
	else if( use_css )
	{
		x = AnchorPosition_getPageOffsetLeft( document.all[ anchorname ] );
		y = AnchorPosition_getPageOffsetTop( document.all[ anchorname ] );
	}
	else if( use_layers )
	{
		var found = 0;
		for( var i = 0; i < document.anchors.length; i++ )
		{
			if( document.anchors[ i ].name == anchorname )
			{
				found = 1;
				break;
			}
		}
		if( found == 0 )
		{
			coordinates.x = 0;
			coordinates.y = 0;
			return coordinates;
		}
		x = document.anchors[ i ].x;
		y = document.anchors[ i ].y;
	}
	else
	{
		coordinates.x = 0;
		coordinates.y = 0;
		return coordinates;
	}

	coordinates.x = x;
	coordinates.y = y;
	return coordinates;
}

function getAnchorWindowPosition( anchorname ) {
	var coordinates = getAnchorPosition( anchorname );
	var x = 0;
	var y = 0;
	if( document.getElementById )
	{
		if( isNaN( window.screenX ) )
		{
			x = coordinates.x - document.body.scrollLeft + window.screenLeft;
			y = coordinates.y - document.body.scrollTop + window.screenTop;
		}
		else
		{
			x = coordinates.x + window.screenX + ( window.outerWidth - window.innerWidth ) - window.pageXOffset;
			y = coordinates.y + window.screenY + ( window.outerHeight - 24 - window.innerHeight ) - window.pageYOffset;
		}
	}
	else if( document.all )
	{
		x = coordinates.x - document.body.scrollLeft + window.screenLeft;
		y = coordinates.y - document.body.scrollTop + window.screenTop;
	}
	else if( document.layers )
	{
		x = coordinates.x + window.screenX + ( window.outerWidth - window.innerWidth ) - window.pageXOffset;
		y = coordinates.y + window.screenY + ( window.outerHeight - 24 - window.innerHeight ) - window.pageYOffset;
	}
	coordinates.x = x;
	coordinates.y = y;
	return coordinates;
}

function AnchorPosition_getPageOffsetLeft( el ) {
	if( el )
	{
		var ol = el.offsetLeft;
		while( ( el = el.offsetParent ) != null )
		{
			ol += el.offsetLeft; 
		}
		return ol;
	}
	return 0;
}

function AnchorPosition_getWindowOffsetLeft( el ) {
	var scrollamount = document.body.scrollLeft;
	return AnchorPosition_getPageOffsetLeft( el ) - scrollamount;
}	

function AnchorPosition_getPageOffsetTop( el ) {
	if( el )
	{
		var ot = el.offsetTop;
		while( ( el = el.offsetParent ) != null )
		{ 
			ot += el.offsetTop; 
		}
		return ot;
	}
	return 0;
}

function AnchorPosition_getWindowOffsetTop( el ) {
	var scrollamount = document.body.scrollTop;
	return AnchorPosition_getPageOffsetTop( el ) - scrollamount;
}

function browserCheck() {
	this.br = navigator.appName.toLowerCase();
	this.version = navigator.appVersion.toLowerCase();
	this.agent = navigator.userAgent.toLowerCase();
	this.platform = navigator.platform.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.is_opera = (this.agent.indexOf('opera') != -1);
	this.is_ns = (this.br == 'netscape' && !this.is_opera);
	this.is_ie = (this.br == 'microsoft internet explorer' && !this.is_opera);
	this.is_ns4 = (this.is_ns && this.major == 4 && !this.is_opera);
	this.is_ns6 = (this.is_ns && this.major == 5 && !this.is_opera);
	this.is_ie4 = (this.version.indexOf('msie 4.0') != -1 && !this.is_opera);
	this.is_ie5 = (this.version.indexOf('msie 5.0') != -1 && !this.is_opera);
	this.is_ie6 = (this.version.indexOf('msie 6.0') != -1 && !this.is_opera);
	this.is_windows = (this.platform.indexOf('win') != -1);
	this.is_mac = (this.agent.indexOf('mac') != -1);
	this.is_linux = (this.platform.indexOf('linux') != -1 || this.platform.indexOf('x11') != -1) ? true:false;
	this.is_dom = (document.getElementById) ? true:false;
	this.is_firefox = (this.agent.indexOf('firefox') != -1 );
	this.is_mozilla = (this.agent.indexOf('gecko') != -1 && !this.is_firefox );
}

br = new browserCheck();
//window.alert( br.is_mozilla + ' --- ' + br.is_dom + ':' + br.is_opera + ':' + br.is_ns + ':' + br.is_ie + ':' + br.is_ns4 + ':' + br.is_ns6 + ':' + br.is_ie4 + ':' + br.is_ie5 + ':' + br.is_ie6 );

function show() {
	this.css.visibility = (br.is_ns4)? 'show' : 'visible';
}

function hide() {
	this.css.visibility = 'hidden';
}

function clipTo(n, e, s, w) {
	if(br.is_ns4) {
		if(n != null) this.css.clip.top = n;
		if(e != null) this.css.clip.right = e;
		if(s != null) this.css.clip.bottom = s;
		if(w != null) this.css.clip.left = w;
	} else {
		if(n != null) this.css.clip = 'rect(' + n + ' ' + e + ' ' + s + ' ' + w + ')';
	}
}

function moveTo(x,y) {
   if(x != null) {
		this.x = x;
		this.css.left = this.x+"px";
	}
	if(y != null) {
		this.y = y;
        this.css.top = this.y+"px";
   }
}
	

function layer(id, ref) {
	var ss = '';
	if(ref) ss = ref;
	this.name = id;
   this.elm = (br.is_ns4)? eval(ss + 'document.layers[\'' + id + '\']') : (br.is_ie4)? document.all[id] : (br.is_dom)? document.getElementById(id) : null;
   this.css = (br.is_ns4)? this.elm : (br.is_ie4)? this.elm.style : (br.is_dom)? this.elm.style : null;
   this.x = this.css.left;
	this.y = this.css.top;
}

layer.prototype.show = show;
layer.prototype.hide = hide;
layer.prototype.clipTo = clipTo;
layer.prototype.moveTo = moveTo;

function window_dims() {
	window_height = (br.is_ie && !br.is_opera) ? document.body.offsetHeight : window.innerHeight;
	window_width = (br.is_ie && !br.is_opera) ? document.body.offsetWidth -20 : window.innerWidth;
	window_width = (br.is_ie) ? window_width:window_width;
}

var window_height, window_width;

var divsubmenu = new Array();

var loaded = false;

function init() {
	window_dims();
	moveSubmenusToTheirPlaces();
	loaded = true;
	if( self.initProds )
	{
		initProds();
	}
}

onload = init;

var timeri = 0;
function start_hideNavi() {
	if(timeri) clearTimeout(timeri);
	if(loaded) {
		timeri = setTimeout('hideNavi()', 200);
	}
}
	
function hideNavi() {
	if(timeri) clearTimeout(timeri);
	if(loaded) {
		for (var i in divsubmenu) {
			divsubmenu[i].hide();
		}
	}
}

function moveSubmenusToTheirPlaces() {
	for (var i in divsubmenu) {
		coords = getAnchorPosition('posit' + i);
		if (br.is_ns4) {
			lisay = 1;
		} else if (br.is_ie) {
			lisay = 4;
		} else {
			lisay = 3;
		}
		// lisay = (br.is_ns4) ? 1 : 4;
		lisax = (br.is_ns4) ? -3 : 0;
		divsubmenu[i].moveTo(coords.x + lisax, coords.y + lisay);
   }
}

function dopops( id ) {
   if( loaded && divsubmenu[ id ] ) {
		hideNavi();
		divsubmenu[ id ].show();
	}
	else {
		return false;
	}
}

onresize = init;
