//GENERAL JAVASCRIPT INCLUDE FILE FOR CPAR SITE

try{
$(document).ready(function() {
    $('#pictures').cycle({ 
        fx:     'fade', 
        speed:   300, 
        timeout: 3000, 
        next:   '#pictures', 
        pause:   1 
    });
    
});
} catch(err) {
    //jquery not available. oh well!
}

var NAV = 0;
var img_number = 1;
var over_image = 0;
	
//determine browser
function preload(){
	NAV = (navigator.appName == 'Netscape');
}

//roll over images
function over(number,type,name,source,name2,source2){

	if (type=='haltimage') {
		over_image = 1;
		if (name=='rotate_img') {
			if (img_number == 1) {
				source='./images/structure/header_woman_down.gif';
			} else if(img_number == 2) { 
				source='./images/structure/header_kids_down.gif';
			} else if(img_number == 3) { 
				source='./images/structure/header_well_down.gif';
			}
		}
	}

	if (NAV) {
		document[name].src=source;
		if (number=='2') {
			document[name2].src=source2;
		}
	} else {
		document.all[name].src=source;
		if (number=='2') {
			document.all[name2].src=source2;
		}
	}
}

//roll out images
function out(number,name,source,name2,source2,type){
	if (type=='endhalt') {
		over_image = 0;
		if (img_number == 1) {
			source='./images/structure/header_woman_up.gif';
			source2='./images/structure/header_message_well.gif';
		} else if(img_number == 2) { 
			source='./images/structure/header_kids_up.gif';
			source2='./images/structure/header_message_well.gif';
		} else if(img_number == 3) { 
			source='./images/structure/header_well_up.gif';
			source2='./images/structure/header_message_well.gif';
		}
	}

	if (NAV) {
		document[name].src=source;
		if (number=='2') {
			document[name2].src=source2;
		}
	} else {
		document.all[name].src=source;
		if (number=='2') {
			document[name2].src=source2;
		}
	}
}

function popup(url,wide,high){
		smallWin = window.open(url,'popupWin','toolbar=0,location=0,directories=0,status="Caledon Countryside Alliance - Popup window",menubar=0,scrollbars=1,resizeable=0,width='+wide+',height='+high+'');
		smallWin.focus();		
}

function popupfull(url,wide,high){
		fullWin = window.open(url,'popupWin','toolbar=0,location=1,directories=0,status="Caledon Countryside Alliance - Popup window",menubar=1,scrollbars=1,resizeable=0,width='+wide+',height='+high+'');
		fullWin.focus();		
}

//this function refreshes the image at the top of the screen
function rollimage(){

	//if user is not currently over the image, then roll to the next one on function call
 if (over_image == 0) {
 	if (img_number == 1) {
 		change('2','rotate_img','./images/structure/header_kids_up.gif','img_message','./images/structure/header_message_well.gif');
 		img_number=2;
 	} else if (img_number == 2) {
 		change('2','rotate_img','./images/structure/header_well_up.gif','img_message','./images/structure/header_message_well.gif'); 	
 		img_number=3;
 	} else if (img_number == 3) {
  	change('2','rotate_img','./images/structure/header_woman_up.gif','img_message','./images/structure/header_message_well.gif');
 		img_number=1;
 	}
 	
 	
 }
 
	setTimeout('rollimage()',10000); 
	
}

// hide show layers
function toggleLayer(whichLayer)
{	
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"none";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"none";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"none";
	}
	
}

//change image
function change(number,name,source,name2,source2){
	if (NAV) {
		document[name].src=source;
		if (number=='2') {
			document[name2].src=source2;
		}
	} else {
		document.all[name].src=source;
		if (number=='2') {
			document.all[name2].src=source2;
		}
	}
}
// FACEBOOK CODE
function fbs_click() {
	u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

// FOR EMAILING PAGE
function SubmitEmailForm() { document.EmailPageForm.submit(); }