currentsize = 1;
if (document.images){
  nav1_off = new Image();  nav1_off.src = view_path+"images/"+template+"/home.gif";
  nav1_on =  new Image();  nav1_on.src =  view_path+"images/"+template+"/home_on.gif";
  nav2_off = new Image();  nav2_off.src = view_path+"images/"+template+"/locations.gif";
  nav2_on =  new Image();  nav2_on.src =  view_path+"images/"+template+"/locations_on.gif";
  nav3_off = new Image();  nav3_off.src = view_path+"images/"+template+"/programs.gif";
  nav3_on =  new Image();  nav3_on.src =  view_path+"images/"+template+"/programs_on.gif";
  nav4_off = new Image();  nav4_off.src = view_path+"images/"+template+"/camps.gif";
  nav4_on =  new Image();  nav4_on.src =  view_path+"images/"+template+"/camps_on.gif";
  nav5_off = new Image();  nav5_off.src = view_path+"images/"+template+"/join.gif";
  nav5_on =  new Image();  nav5_on.src =  view_path+"images/"+template+"/join_on.gif";
  nav6_off = new Image();  nav6_off.src = view_path+"images/"+template+"/news.gif";
  nav6_on =  new Image();  nav6_on.src =  view_path+"images/"+template+"/news_on.gif";
  nav7_off = new Image();  nav7_off.src = view_path+"images/"+template+"/events.gif";
  nav7_on =  new Image();  nav7_on.src =  view_path+"images/"+template+"/events_on.gif";
  nav8_off = new Image();  nav8_off.src = view_path+"images/"+template+"/donate.gif";
  nav8_on =  new Image();  nav8_on.src =  view_path+"images/"+template+"/donate_on.gif";
  nav9_off = new Image();  nav9_off.src = view_path+"images/"+template+"/about.gif";
  nav9_on =  new Image();  nav9_on.src =  view_path+"images/"+template+"/about_on.gif";
  nav10_off = new Image();  nav10_off.src = view_path+"images/"+template+"/employment.gif";
  nav10_on =  new Image();  nav10_on.src =  view_path+"images/"+template+"/employment_on.gif";
  nav11_off = new Image();	nav11_off.src = view_path+"images/"+template+"/contact.gif";
  nav11_on = new Image();	nav11_on.src = view_path+"images/"+template+"/contact_on.gif";
  nav12_off = new Image();	nav12_off.src = view_path+"images/"+template+"/search.gif";
  nav12_on = new Image();	nav12_on.src = view_path+"images/"+template+"/search_on.gif";
  
  sbg = new Image(); sbg.src = view_path+"images/"+template+"/bg_subnav.jpg";
  sbg_on = new Image(); sbg_on.src = view_path+"images/"+template+"/bg_subnav_on.jpg";
}

function roll(sname,rname){
    sname = id2elem(sname);
    sname.src = rname.src;
}

function id2elem(id) {
	if (typeof(id) != 'string') {
		return id;
	}
	if (document.getElementById) {
		id = document.getElementById(id);
	} else if (document.all) {
		id=document.all[id];
	} else {
		id = null;
	}
	return id;
}
function popup(url,width,height){
    nw = window.open(url,"newwindow","width="+width+",height="+height+",status=0,toolbar=0,menubar=0,scrollbars=1,resizable=1,location=0");
    nw.focus();
}

function textsize(dir){
  item1 = id2elem('subnav');
  item2 = id2elem('subcontent');
  if(dir == 0){ //decrease text size
    if(currentsize > 1){
      currentsize--;
      item1.className = "size"+currentsize;
      item2.className = "size"+currentsize;
    }
  }else{//increase text size
    if(currentsize<4){
      currentsize++;
      item1.className = "size"+currentsize;
      item2.className = "size"+currentsize;
    }
  }
}

function highlightRow(id){
  element = id2elem(id);
  if(element.className == "off"){
    element.className = "on";
  }else{
    element.className = "off";
  }
}

function cyclePhotos(){
	$(document).ready(function(){
		$('#home_slide').cycle({
			fx:    'fade', 
	    	speed:  2500,
			random: 1
		});
	});
}

function setTitle(br,sect,style){
	if (style == 'urban' && sect != '') {
		var img = view_path+'images/'+style+'/title_'+sect+'.jpg';
		$("#"+sect+'_title').css({ 
			background: 'transparent url('+img+') 0px 0px no-repeat;', 
			padding: '8px 0px 0px 5px;', 
			overflow: 'hidden;', 
			margin: '16px 0px 0px 0px;', 
			color: '#ffffff;', 
			width: '216px;', 
			height: '31px;' 
		});
	}
		
}

function addContact() {
	
	var fData = $("#contactform").serialize();
	var cUrl = def_path + 'ajax/addcontact';

	$('#contactus').fadeOut("fast");

	var myAjax = $.ajax ({
		 type: "POST",
		 url: cUrl,
		 data: fData,
		 dataType: "text",
		 success: function() {
		  $("#contactstatus").fadeIn('fast');
		  //window.location.href = def_path + 'admin/branchclasses';
		}
	});
		
}

function addDonation() {

	var fData = $("#donationform").serialize();
	var cUrl = def_path + 'ajax/adddonation';

	var myAjax = $.ajax ({
		 type: "POST",
		 url: cUrl,
		 data: fData,
		 dataType: "text",
		 success: function(response) {
		 	if (response == 1) {
		 		$('#donation').fadeOut("fast");
		 		$("#donationerror").fadeOut('fast');
		  	$("#donationstatus").fadeIn('fast');
			} else {
				$("#donationstatus").fadeOut('fast');
				$("#donationerror").fadeIn('fast');
				$("#donationerror").html('<h2>'+response+'</h2>');
			}
		  //window.location.href = def_path + 'admin/branchclasses';
		}
	});
		
}

function addJobApplication() {
	
	var fData = $("#jobapplicationform").serialize();
	var cUrl = def_path + 'ajax/addjobapplication';
	
	$('#jobapplication').fadeOut("fast");

	var myAjax = $.ajax ({
		 type: "POST",
		 url: cUrl,
		 data: fData,
		 dataType: "text",
		 success: function() {
		  $("#jobapplicationstatus").fadeIn('fast');
		  //window.location.href = def_path + 'admin/branchclasses';
		}
	});
		
}

