
function navDrop(dropBox, bOx){
	var Top1 = main.offsetTop + bOx.offsetTop + bOx.offsetHeight
	var Left1 = main.offsetLeft + bOx.offsetLeft
	dropBox.style.left = Left1
	dropBox.style.top = Top1
	dropBox.style.visibility = 'visible'
}
function DropSubMenu(dropBox, bOx, mnu){
	var Top1 = main.offsetTop + bOx.offsetTop + mnu.offsetTop
	DHheight = mnu.offsetTop - 5
	var Left1 = main.offsetLeft + bOx.offsetLeft + bOx.offsetWidth
	dropBox.style.left = Left1
	dropBox.style.top = Top1
	dropBox.style.visibility = 'visible'
}
function DropSubSubMenu(dropBox, bOx, mnu){
	var Top1 = main.offsetTop + bOx.offsetTop + mnu.offsetTop + DHheight
	var Left1 = main.offsetLeft + bOx.offsetLeft + bOx.offsetWidth + bOx.offsetWidth
	dropBox.style.left = Left1
	dropBox.style.top = Top1
	dropBox.style.visibility = 'visible'
}
function navRemove(dropBox, bOx){
	dropBox.style.visibility = 'hidden'
}
function stayUp(dropBox){
	dropBox.style.visibility = 'visible'	
}

function resizeBg(){
	var width;
	var height;
	var x, y, w, h;
	
	img = document.getElementById('rbBackground');
	div = document.getElementById('rbBackgroundDiv');
	width = screen.availWidth - 21;
	height = screen.availHeight;
	
	w = img.width;
	h = img.height;
	
	if (w > h)
	{
		w = width;
		h = width * (img.height / img.width);
	}
	else
	{
		h = height;
		w = height * (img.width / img.height);
	}  
	
	img.style.width = parseInt(w) + "px";
	img.style.height = parseInt(h) + "px";
	div.style.visibility = 'visible';
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function blendimages(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).src = document.getElementById(imageid).src;
		
	//make image transparent
	changeOpac(0, imageid);
	//pausecomp(1000);
	//make new image
	document.getElementById(imageid).src = imagefile;
	document.getElementById(divid).width = document.getElementById(imageid).width;
	document.getElementById(divid).height = document.getElementById(imageid).height;
	
	

	var intTblTop = findPosTop(document.getElementById('tblSlideShow'));
	var intImgHeight= document.getElementById(imageid).height;
	//var intImgtop=intTblTop+521/2-intImgHeight/2
	var intImgtop=intTblTop + (521-intImgHeight)/2 - 10
	
	//alert(intImgtop);
	//pausecomp(1000);
	
	document.getElementById(imageid).style.top = intImgtop; //findPosTop(document.getElementById(divid));
	document.getElementById(imageid).style.left = findPosXLeft(document.getElementById(divid));
	document.getElementById(imageid).style.display = "block";
	
	var divwidth = document.getElementById(imageid).width;
	if (isIE() == true){
		divwidth = divwidth + 20;
	}
	document.getElementById('divImageMenu').style.width = divwidth;
	document.getElementById('divImageMenu').style.left = findPosXLeft(document.getElementById(divid));
	document.getElementById('divImageMenu').style.top = intImgtop+intImgHeight + 18; //document.getElementById(imageid).top
	
	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function setupSlideShow(divid, imageid, imagefile) {
	
	var intTblTop = findPosTop(document.getElementById('tblSlideShow'));
	var intImgHeight= document.getElementById(divid).height;
	//var intImgtop=intTblTop+521/2-intImgHeight/2
	var intImgtop=intTblTop + (521-intImgHeight)/2 - 10
	
	//alert(intImgtop);
	//pausecomp(1000);
	
	document.getElementById(imageid).style.top = intImgtop; //findPosTop(document.getElementById(divid));
	document.getElementById('picMainbg').style.top = document.getElementById('picMainbg').style.top - 15;
	
	document.getElementById(imageid).style.left = findPosXLeft(document.getElementById(divid));
	document.getElementById(imageid).style.display = "block";
	
	var divwidth = document.getElementById(imageid).width;
	if (isIE() == true){
		divwidth = divwidth + 20;
	}
	document.getElementById('divImageMenu').style.width = divwidth;
	document.getElementById('divImageMenu').style.left = findPosXLeft(document.getElementById(imageid));
	document.getElementById('divImageMenu').style.top = intImgtop + intImgHeight + 18;
	document.getElementById('divImageMenu').style.display = "block";
	
}

function pausecomp(millis) 
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); } 
while(curDate-date < millis);
} 

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

function findPosTop(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
	do {
		curleft += obj.offsetLeft;
		curtop += obj.offsetTop;
	} while (obj = obj.offsetParent);
	}
	return curtop;
}

function getTop(obj) {
	var curtop = 0;
	
	curtop += obj.offsetTop;
	
	return curtop;
}

function findPosXLeft(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}
function findPosYTop(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}
function isIE()
{
  return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}
