/* Yorkshire's Great Houses, Castles and Gardens Core Javascript */

// Navigation bar fade function provided by the legend Jonathan Snook (http://www.snook.ca)
// Standing on the shoulders of the giant Dave Shea (mezzoblue) from his A List Apart article: 
// 					http://alistapart.com/articles/sprites2
// Thanks for sharing with the world guys!
$(function(){
	$('ul#ulMenu a')
		.css( {backgroundPosition: "0 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-200px 0)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-300px 0)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "0 0"})
			}})
		})
});

/* Courtesy of the beautiful jQuery Cycle Images Project:
		http://malsup.com/jquery/cycle/download.html
   This code provides the image cycling which you see in the top right hand
   corner of every page.  */
$.fn.cycle.defaults.timeout = 6000;
$(function() {
    $('#r1').cycle({ 
    	fx:     'fade', 
    	speed:   300, 
    	timeout: 3000, 
    	next:   '#r1', 
    	pause:   1 
	});
    $('#r2').cycle({ 
    	fx:     'fade', 
    	speed:   300, 
    	timeout: 3000, 
    	next:   '#r2', 
    	pause:   1 
	});
    $('#r3').cycle({ 
    	fx:     'fade', 
    	speed:   300, 
    	timeout: 3000, 
    	next:   '#r3', 
    	pause:   1 
	});
    $('#r4').cycle({ 
    	fx:     'fade', 
    	speed:   300, 
    	timeout: 3000, 
    	next:   '#r4', 
    	pause:   1 
	});
});

// Popup Map Functions.
function popUp(evt,currElem) {
	if (document.getElementById) {
		stdBrowser = true
	}
	else {
		stdBrowser = false
	}

	if (stdBrowser) {
		popUpWin = document.getElementById(currElem).style
	}
	else {
		popUpWin = eval("document." + currElem)
	}
	
	if (document.all) {
		//popUpWin.pixelTop = parseInt(evt.y)+2
		//popUpWin.pixelLeft = Math.max(2,parseInt(evt.x)-125)
		popUpWin.top = 400 + "px"
		popUpWin.left = 700 + "px"
	}
	else {
		if (stdBrowser) {
			//popUpWin.top = parseInt(evt.pageY)+2 + "px"
			popUpWin.top = 400 + "px"
			popUpWin.left = 700 + "px"
			//popUpWin.left = Math.max(2,parseInt(evt.pageX)-125) + "px"
		}
		else {
			//popUpWin.top = parseInt(evt.pageY)+2
			//popUpWin.left = Math.max(2,parseInt(evt.pageX)-125)
			popUpWin.top = 400 + "px"
			popUpWin.left = 700 + "px"
		}
	}
	popUpWin.visibility = "visible"
}

function popDown(currElem) {
	if (document.getElementById) {
		stdBrowser = true
	}
	else {
		stdBrowser = false
	}

	if (stdBrowser) {
		popUpWin = document.getElementById(currElem).style
	}
	else {
		popUpWin = eval("document." + currElem)
	}
	popUpWin.visibility = "hidden"
}


/* Cycle Images on the Homepage  */
$.fn.cycle.defaults.timeout = 6000;
$(function() {
    $('#ghcar').cycle({ 
    	fx:     'fade', 
    	speed:   300, 
    	timeout: 3000, 
    	next:   '#r1', 
    	pause:   1 
	});
    $('#gccar').cycle({ 
    	fx:     'fade', 
    	speed:   300, 
    	timeout: 3000, 
    	next:   '#r1', 
    	pause:   1 
	});
    $('#gmcar').cycle({ 
    	fx:     'fade', 
    	speed:   300, 
    	timeout: 3000, 
    	next:   '#r1', 
    	pause:   1 
	});
    $('#ggcar').cycle({ 
    	fx:     'fade', 
    	speed:   300, 
    	timeout: 3000, 
    	next:   '#r1', 
    	pause:   1 
	});
});
