// DROP DOWN

var timeout	= 0;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose;



// VMPOPUP
function vmpopup(image,nWidth,nHeight,sTilte,nColor,nMargin)
{
	if (nColor=="") {
		nColor="#FFFFFF";
	}
	var adj=10;
	var w = screen.width;
	var h = screen.height;
var agent=navigator.userAgent.toLowerCase();
if(agent.indexOf("opera") != -1){
w = document.body.clientWidth;
h = document.body.clientHeight;
}
	var byFactor=1;
	if(w<740){
		var lift=0.90;
	}
	if(w>=740 & w<835){
	var lift=0.91;
	}
 if(w>=835){
var lift=0.93;
}
if (nWidth>w){
byFactor = w / nWidth;
nWidth = w;
nHeight = nHeight * byFactor;
}
if (nHeight>h-adj){
byFactor = h / nHeight;
nWidth = (nWidth * byFactor);
nHeight = h; 
}

var scrWidth = w-adj;
var scrHeight = (h*lift)-adj;
 
if (nHeight>scrHeight){
nHeight=nHeight*lift;
nWidth=nWidth*lift;
}
var posLeft=0;
var posTop=0;
if (nMargin < 0){nMargin=0}
nMargin*=2;
var nTemp = parseInt(nHeight) + nMargin;
if (nTemp < scrHeight) {
scrHeight = nTemp;
} 
nTemp = parseInt(nWidth) + nMargin;
if (nTemp < scrWidth) {
scrWidth = nTemp;
}
if (scrHeight<100){scrHeight=100;}
if (scrWidth<100){scrWidth=100;}
posTop =  ((h-(scrHeight/lift)-adj)/2);
posLeft = ((w-(scrWidth)-adj)/2);
if (nHeight > (h*lift)-adj || nWidth > w-adj){
nHeight=nHeight-adj;
nWidth=nWidth-adj;
}
posTop = parseInt(posTop);
posLeft = parseInt(posLeft);		
scrWidth = parseInt(scrWidth); 
scrHeight = parseInt(scrHeight);
newWindow = window.open("","","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
newWindow.document.open();
newWindow.document.write('<html><title>'+sTilte+'</title>'); 
newWindow.document.write('<meta http-equiv="imagetoolbar" content="false">');
newWindow.document.write('<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+nColor+' onBlur="self.close()" onClick="self.close()">'); 
newWindow.document.write('<table width='+nWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
newWindow.document.write('<img src="'+image+'" width='+nWidth+' height='+nHeight+' alt="Click to close window" >');
newWindow.document.write('</td></tr></table></body></html>');
newWindow.document.close();
newWindow.focus();
return false;
}


// Google Analytics Code (new June 2010)
var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-550381-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();