
		
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);
}

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";
}

function showPopUp(el) {
var cvr = document.getElementById("cover")
var dlg = document.getElementById(el)

var divimg = dlg.getElementsByTagName("img")[0];

var coverheight;

cvr.style.display = "block"

dlg.style.top = "0px";
dlg.style.left = "0px";

dlg.style.width = "100%";

coverheight = document.documentElement.clientHeight + "px";
	
dlg.style.height = coverheight;

//alert(screen.width + "px");

dlg.style.display = "block"
	
	
}

function showPopUpImage(el, imageid) {
var cvr = document.getElementById("cover")
var dlg = document.getElementById(el)

var divimg = document.getElementById("popimage");
var coverheight;

divimg.src = galleryimages[imageid];
document.getElementById("caption_label").innerHTML = gallerycaptions[imageid];
document.getElementById("array-index").value = imageid;
cvr.style.display = "block"

dlg.style.top = "0px";
dlg.style.left = "0px";

dlg.style.width = "100%";
//document.height=window.innerHeight;
//dlg.style.height = "100%";

coverheight = document.documentElement.clientHeight + "px";
	
dlg.style.height = coverheight;
	
//dlg.style.height = window.innerHeight;
document.body.style.overflow = "hidden";

//alert(screen.width + "px");

dlg.style.display = "block"
	
	
}

function showPopUpImage2(el, imagefile) {
var cvr = document.getElementById("cover")
var dlg = document.getElementById(el)

var divimg = document.getElementById("popimage");
var coverheight;

divimg.src = imagefile;
cvr.style.display = "block"

dlg.style.top = "0px";
dlg.style.left = "0px";

dlg.style.width = "100%";
//document.height=window.innerHeight;
//dlg.style.height = "100%";

coverheight = document.documentElement.clientHeight + "px";
	
dlg.style.height = coverheight;
	
//dlg.style.height = window.innerHeight;
document.body.style.overflow = "hidden";

//alert(screen.width + "px");

dlg.style.display = "block"
	
	
}
function moveLeft() {

var arrayindex = document.getElementById("array-index").value
var divimg = document.getElementById("popimage");

if(arrayindex <= 0) {
} else {
	
	document.getElementById("array-index").value = (arrayindex - 1);
	divimg.src = galleryimages[arrayindex - 1];
	document.getElementById("caption_label").innerHTML = gallerycaptions[arrayindex - 1];
	
}
	
}

function moveRight() {

var arrayindex = document.getElementById("array-index").value

arrayindex = parseInt(arrayindex);

var divimg = document.getElementById("popimage");
var topindex = galleryimages.length - 1;
if(arrayindex >= topindex) {
} else {
	arrayindex = arrayindex + 1;
	document.getElementById("array-index").value = (arrayindex);
	divimg.src = galleryimages[arrayindex];
	document.getElementById("caption_label").innerHTML = gallerycaptions[arrayindex];
	
}
	
}

function closePopUp(el) {
var cvr = document.getElementById("cover")
var dlg = document.getElementById(el)
cvr.style.display = "none"
dlg.style.display = "none"
document.body.style.overflow = "auto";
}

