//*************
// MEGA NAV
//*************
$(document).ready(function() 
{
	//On Hover Over
	function megaHoverOver(){
    $(this).find(".sub").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
	}
	//On Hover Out
	function megaHoverOut(){
		$(this).find(".sub").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
		$(this).hide();  //after fading, hide it
		});
	}
	
	//Set custom configurations
	var config = 
	{
	sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
	interval: 10, // number = milliseconds for onMouseOver polling interval
	over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
	timeout: 10, // number = milliseconds delay before onMouseOut
	out: megaHoverOut // function = onMouseOut callback (REQUIRED)
	};

	$("ul#topnav li .sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
	$("ul#topnav li").hoverIntent(config); //Trigger Hover intent with custom configurations
	$("a[rel='enlarge']").colorbox();
	$("a[rel='largephoto']").colorbox(); //trigger for colorbox
	//$('#slider').nivoSlider(); //Trigger for Nivo Slider
	$('#slider').nivoSlider({
		effect:'random', //Specify sets like: 'fold,fade,sliceDown'
		animSpeed:500,
		pauseTime:4000,
		directionNav:false
		});
});


function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
		thefield.value = ""
}

//<![CDATA[
function dwbfb_getRequest(){http_request = false;if(window.XMLHttpRequest){http_request=new XMLHttpRequest();if(http_request.overrideMimeType){http_request.overrideMimeType('text/html');}}else if(window.ActiveXObject) {try{http_request = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try {http_request=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}if(!http_request){alert('Cannot create XMLHTTP instance');return false;}return http_request;}
function dwb_facebook_load (area, fb_action, count, url)
{
  var http_request = dwbfb_getRequest();
  http_request.open("GET", '/codepeople/facebook/dwb-facebook.php?s='+fb_action+'&count='+count+'&url='+encodeURIComponent(url), true);
  http_request.onreadystatechange = function () {
    var output = "";  
    if (http_request.readyState == 4) {if (http_request.status == 200){output = http_request.responseText;}else output = 'There was an error loading the facebook information. Please check if you have uploaded all the required files and if your server supports PHP. If the problem persists you can contact our support service and we will give you instructions to solve the problem, please be sure to provide your web page URL.';}
    if (output != "")try{document.getElementById(area).innerHTML = output;}catch(e){}
    }
  http_request.send(null); 
}
//]]>

function goto_URL(object) {
	window.location.href = object.options[object.selectedIndex].value;
}

function winBRopen(theURL, Name, popW, popH, scroll, resize) { // V 1.0
	var winleft = (screen.width - popW) / 2;
	var winUp = (screen.height - popH) / 2;
	winProp = 'width='+popW+',height='+popH+',left='+winleft+',top='+winUp+',scrollbars='+scroll+',resizable='+resize+'';
	Win = window.open(theURL, Name, winProp);
	Win.window.focus();
}
