var scrollCell, scrollCell2, contentHeight, contentHeight2, timer, timer2, lefttime, topStop, topStop2, theTimer;

/* TOP NAVIGATION DROP DOWN MENUS */
function hideMenu(whichMenu){
	//alert(whichMenu);
	divtohide=document.getElementById(whichMenu);
	divtohide.style.display = 'none';
}

function hideAllMenus(doNotHideMenu){
	document.getElementById('menu1').style.display = 'none';
	document.getElementById('menu2').style.display = 'none';
}

function changeBack(whichMenu, dropMenuAnchor){
	theTimer = setTimeout("hideMenu('"+whichMenu+"')", 1);
	document.getElementById(dropMenuAnchor).style.backgroundPosition = 'top right';
	if(page == 'homepage'){
		document.getElementById('flashContainer').style.display = 'block';
	}
} 

function showMenu(whichMenu, whichAnchor, positionx, positiony){	
	hideAllMenus(whichMenu);
	clearTimeout(theTimer);
	positionMenu(whichMenu, whichAnchor, positionx, positiony);
	document.getElementById(whichMenu).style.display = 'block';
	document.getElementById(whichAnchor).style.backgroundPosition = 'bottom right';
	if(page == 'homepage'){
		document.getElementById('flashContainer').style.display = 'none';
	}
}

function positionMenu(whichMenu, whichAnchor, positionx, positiony){
	var c = getAnchorPosition(whichAnchor);
	//alert("X = "+c.x+" , Y = "+c.y);
	if (document.getElementById) {
		var o = document.getElementById(whichMenu);
		//alert(o.style.left);
		if (o.style) {
			o.style.left = (c.x + positionx) + 'px';
			o.style.top = (c.y + positiony) + 'px';
		}
	}
}

function highlight(id){
	document.getElementById(id).style.backgroundImage = 'url(images/common/sidenav_hover.jpg)';
}

function unhighlight(id){
	document.getElementById(id).style.backgroundImage = '';
}

// Show Hint Code
var horizontal_offset="9px" //horizontal offset of hint box from anchor link

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox
//  End show hint code

// getAnchorPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the page.
function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	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;
	}

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
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;
	}

// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
}

function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
}	

function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
}

function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
}

var currentDiv = '#1';

function paginationFadeInOut(){
	$(".photo-pagination").find("a").click( function () {
		$(this).blur();
		var href = $(this).attr("href"); //alert(href);
		
		$(currentDiv).fadeOut("medium", function(){
			$(href).fadeIn('medium');
			currentDiv = href;
		})																				 
 });
}

function checkForm(){
	var passedCheck = true;
	
	if(document.getElementById('name').value == ''){
		passedCheck = false;
		document.getElementById('nameField').style.color = 'red';
		document.getElementById('nameField').style.fontStyle = 'italic';
		document.getElementById('nameField').style.fontWeight = 'bold';
	}else{
		document.getElementById('nameField').style.color = 'black';
		document.getElementById('nameField').style.fontStyle = 'normal';
		document.getElementById('nameField').style.fontWeight = 'normal';
	}
	
	if(document.getElementById('email').value == ''){
		passedCheck = false;
		document.getElementById('emailField').style.color = 'red';
		document.getElementById('emailField').style.fontStyle = 'italic';
		document.getElementById('emailField').style.fontWeight = 'bold';
	}else{
		document.getElementById('emailField').style.color = 'black';
		document.getElementById('emailField').style.fontStyle = 'normal';
		document.getElementById('emailField').style.fontWeight = 'normal';
	}
	
	if(!passedCheck){
		alert('Please correct errors in RED');
	}
	
	return passedCheck; }

function checkForm2(){
	var passedCheck = true;
	
	if(document.getElementById('first').value == ''){
		passedCheck = false;
		document.getElementById('firstField').style.color = 'red';
		document.getElementById('firstField').style.fontStyle = 'italic';
		document.getElementById('firstField').style.fontWeight = 'bold';
	}else{
		document.getElementById('firstField').style.color = 'black';
		document.getElementById('firstField').style.fontStyle = 'normal';
		document.getElementById('firstField').style.fontWeight = 'normal';
	}
	
	if(document.getElementById('last').value == ''){
		passedCheck = false;
		document.getElementById('lastField').style.color = 'red';
		document.getElementById('lastField').style.fontStyle = 'italic';
		document.getElementById('lastField').style.fontWeight = 'bold';
	}else{
		document.getElementById('lastField').style.color = 'black';
		document.getElementById('lastField').style.fontStyle = 'normal';
		document.getElementById('lastField').style.fontWeight = 'normal';
	}
	
	if(document.getElementById('email').value == ''){
		passedCheck = false;
		document.getElementById('emailField').style.color = 'red';
		document.getElementById('emailField').style.fontStyle = 'italic';
		document.getElementById('emailField').style.fontWeight = 'bold';
	}else{
		document.getElementById('emailField').style.color = 'black';
		document.getElementById('emailField').style.fontStyle = 'normal';
		document.getElementById('emailField').style.fontWeight = 'normal';
	}
	
	if(!passedCheck){
		alert('Please correct errors in RED');
	}
	
	if(passedCheck) document.getElementById('action').value = 'hI5wLupoath2Azl7zleprieg';
	
	return passedCheck; }

$(document).ready(function(){
	$('#photo-gallery a').lightBox();
	paginationFadeInOut();
});

