stdBrowser = (document.getElementById) ? true : false

function toggleMenuOver(currElem,id) {
			
	var mainimage = document.getElementById(id);
			
			var h = mainimage.offsetHeight;
			var w = mainimage.offsetWidth;
			
			var x = getElementLeft(mainimage);
			var y = getElementTop(mainimage);
			
			//alert('x: '+x+' y:'+y);
			
			menuObj = (stdBrowser) ? document.getElementById(currElem).style : eval("document." + currElem)
			menuObj.top = (y + h) + "px";
			menuObj.left = x + "px";
			menuObj.visibility = "visible"
			
			
	}
		
function toggleMenuOut(currElem,topPos,leftPos) {

			menuObj = (stdBrowser) ? document.getElementById(currElem).style : eval("document." + currElem)
			menuObj.top = (stdBrowser) ? topPos + "px" : topPos
			menuObj.left = (stdBrowser) ? leftPos + "px" : leftPos
			menuObj.visibility = "hidden"
}
		
		
function getElementLeft(elm) {
    var x = 0;

    //set x to elm’s offsetLeft
    x = elm.offsetLeft;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
    {
        x = parseInt(x) + parseInt(elm.offsetLeft);
        elm = elm.offsetParent;
    }
    return x;
}

function getElementTop(elm) {
    var y = 0;

    //set x to elm’s offsetLeft
    y = elm.offsetTop;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
    {
        y = parseInt(y) + parseInt(elm.offsetTop);
        elm = elm.offsetParent;
    }

    return y;
}

var win = null;

function newWindow(mypage,myname,w,h,scroll){
	
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=yes';
	win = window.open(mypage,myname,settings);
}


// On Screen Pop-up Window
function showPopUp(el) {
var cvr = document.getElementById('cover')
var dlg = document.getElementById(el)

var divimg = dlg.getElementsByTagName('img')[0];

cvr.style.display = 'block'

dlg.style.top = '0px';
dlg.style.left = '0px';

dlg.style.width = '100%';
dlg.style.height = '100%';

//alert(screen.width + 'px');
dlg.style.display = 'block'

}
function closePopUp(el) {
var cvr = document.getElementById('cover')
var dlg = document.getElementById(el)
cvr.style.display = 'none'
dlg.style.display = 'none'
document.body.style.overflowY = 'scroll'
}



// Show You-Tube Pop Up Window
function showPopUpYouTube(el, youtubesrc, youtubewidth, youtubeheight) {
var cvr = document.getElementById('cover')
var dlg = document.getElementById(el)
var youtubevideo = document.getElementById('youtubevideo');

youtubevideo.innerHTML = "<object style='width:" + youtubewidth + "px; height:" + youtubeheight + "px; border:solid 1px #000;'><param name='movie' value='http://www.youtube.com/" + youtubesrc + "'><param name='allowFullScreen' value='true'><param name='allowScriptAccess' value='always'><embed src='http://www.youtube.com/" + youtubesrc + "' type='application/x-shockwave-flash' allowfullscreen='true' allowScriptAccess='always' width='" + youtubewidth + "' height='" + youtubeheight + "'></object>";
			
cvr.style.display = 'block'

dlg.style.top = '0px';
dlg.style.left = '0px';

dlg.style.width = '100%';
dlg.style.height = '100%';

youtubevideo.style.width = youtubewidth;
youtubevideo.style.height = youtubeheight;

dlg.style.display = 'block'

}
// Close You-Tube Video Window
function closePopUpYouTube(el) {
var cvr = document.getElementById('cover')
var dlg = document.getElementById(el)
cvr.style.display = 'none'
dlg.style.display = 'none'
document.body.style.overflowY = 'scroll'
youtubevideo.innerHTML = "";
}


// Show Video Pop Up Window
function showPopUpVideo(el, videosrc, videowidth, videoheight) {
var cvr = document.getElementById('cover')
var dlg = document.getElementById(el)
var videocontainer = document.getElementById('videocontainer');

videocontainer.innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' ' width='" + videowidth + "' height='" + videoheight + " id='FLVPlayer'><param name='movie' value='FLVPlayer_Progressive.swf' /><param name='quality' value='high' /><param name='wmode' value='opaque' /><param name='scale' value='noscale' /><param name='salign' value='lt' /><param id='FlashVars' name='FlashVars' value='&amp;MM_ComponentVersion=1&amp;skinName=Clear_Skin_3&amp;streamName=images/swf/" + videosrc + "&amp;autoPlay=true&amp;autoRewind=false' /><param name='swfversion' value='8,0,0,0' /><param name='expressinstall' value='scripts/expressInstall.swf' /><object type='application/x-shockwave-flash' data='FLVPlayer_Progressive.swf' ><param name='quality' value='high' /><param name='wmode' value='opaque' /><param name='scale' value='noscale' /><param name='salign' value='lt' /><param id='FlashVars' name='FlashVars' value='&amp;MM_ComponentVersion=1&amp;skinName=Clear_Skin_3&amp;streamName=images/swf/&amp;autoPlay=true&amp;autoRewind=false' /><param name='swfversion' value='8,0,0,0' /><param name='expressinstall' value='scripts/expressInstall.swf' /></object></object>";
			
cvr.style.display = 'block'

dlg.style.top = '0px';
dlg.style.left = '0px';

dlg.style.width = '100%';
dlg.style.height = '100%';

videocontainer.style.width = videowidth;
videocontainer.style.height = videoheight;

dlg.style.display = 'block'
	
}
// Close Video Pop Up Window
function closePopUpVideo(el) {
var cvr = document.getElementById('cover')
var dlg = document.getElementById(el)
cvr.style.display = 'none'
dlg.style.display = 'none'
document.body.style.overflowY = 'scroll'
videocontainer.innerHTML = "";
}





var DDSPEED = 7;
var DDTIMER = 10;

function showMenu(id, d) {
	//var dlg = document.getElementById(id);
	//dlg.style.display = "block";
	var h = document.getElementById(id);
	var c = document.getElementById(id);
	clearInterval(c.timer);
	
	if(d == 1){
    	clearTimeout(h.timer);
		if(c.maxh && c.maxh <= c.offsetHeight){
			c.style.display = 'block';
		  	return;
		}
		else if(!c.maxh){
		  c.style.display = 'block';
		  c.style.height = 'auto';
		  c.maxh = c.offsetHeight;
		  c.style.height = '0px';
		} else {
		
			c.style.display = 'block';
			
		}
			
    	c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
	}else{
    	c.timer = setTimeout(function(){ddCollapse(c)},50);
  	}
}

function cancelHide(id){
  var h = document.getElementById(id);
  var c = document.getElementById(id);
  clearTimeout(h.timer);
  clearInterval(c.timer);
  if(c.offsetHeight < c.maxh){
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }
}

function ddCollapse(c){
  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}

function ddSlide(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = (Math.round((c.maxh - currh) / DDSPEED));
  }else{
    dist = (Math.round(currh / DDSPEED));
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) + 'px';
  c.style.opacity = currh / c.maxh;
  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  if((currh < 4 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
    clearInterval(c.timer);
	if(currh <= 3) {
		c.style.display = 'none';
	}
  } else {
	  //alert(currh);
  }
}

function hideMenu(el) {
	var dlg = document.getElementById(el);
	dlg.style.display = "none";
}