$(document).ready(function(){ 
    $("#searchinput").focus(function(){  
	if($(this).attr("value") == "Search website") $(this).attr("value", "");  
    }); 

    //support for device without :hover
    $(".menu .menuclickable").click(function () { 
	var isvisible = $(this).parent().find("> ul").hasClass("clicked");
	$(this).parent().parent().find("li > ul").removeClass("clicked");
    	$(this).parent().find("> ul").addClass("clicked");
	return isvisible; //if visible go to page, otherwise show menu
    });
    //support for IE6
    $(".menu > li").hover(function () { 
	$(this).parent().find("li > ul").removeClass("clicked");
	$(this).find("> ul").addClass("clicked");
	return false;
    },function () { 
	$(this).parent().find("li > ul").removeClass("clicked");
	return false;
    });
    if ($(".cycleBox .slides > div").length > 1) {
	$(".cycleBox .controls").show();
    	$(".cycleBox .slides > div").removeClass("more");
	//var rnd = Math.floor($(".test > div").length * (Math.random() % 1));	
	var $cycle = $(".cycleBox .slides").cycle({
		timeout: 9000,
		speed: 1000, 
		before: function() { 
	                if ($(this).attr("delay") != 'undefined') {
        	            var img = $(this).find('img:first');
	                    img.attr("src", $(this).attr("delay"));
	                    $(this).removeAttr("delay");
	                }
			$(".cycleBox .controls > a").removeClass("selected");
			$(".cycleBox .controls #i"+$(this).index()).addClass("selected");
		}
	}); 
	$('.cycleBox .controls > a').each(function (i, el) {
		$(el).click(function() { $cycle.cycle(i).cycle('pause'); return false;	});
		$(el).hover(function() { $cycle.cycle(i).cycle('pause'); return false;	},function() { $cycle.cycle('resume'); return false;	});
	});
    }
    if ($(".cycleLogo > a").length > 1) {
    	$(".cycleLogo > a").removeClass("more");
	//var rnd = Math.floor($(".test > div").length * (Math.random() % 1));	
	var $cycle = $(".cycleLogo").cycle({
		timeout: 3000,
		speed: 1000
	}); 
    }
    if ($("#latestnews .slides > div").length > 1) {
	$('#latestnews .slides').cycle({ 
	 containerResize: false,
	 speed:  0, 
	 prev:   '#latestnews_previous', 
	 next:   '#latestnews_next', 
	 timeout: 0 
	});
	$("#latestnews_next").click(function () { $("#latestnews_previous").show(); });
    }
   if ($("#sym_widget").length > 0) {
   	$("#sym_widget").symWidget();
   }
   for (var i = 0; i < 10; i++) {
   	if ($("#sym_widget_"+i).length > 0) $("#sym_widget_"+i).symWidget({type:i});
   }

   $("a").each(function() {
     if (/^mailto:/i.test($(this).attr("href"))){
	$(this).click(function() {
          _gaq.push(['_trackEvent', 'Email', 'Click',  $(this).attr('href').substring($(this).attr('href').lastIndexOf(':')+1) ]);
	});
      }
      if (/\.PDF$/i.test($(this).attr("href"))) {
	$(this).click(function() {
          _gaq.push(['_trackEvent', 'PDF', 'Download',  $(this).attr('href').substring($(this).attr('href').lastIndexOf('/')+1) ]);
	});
      }
   });
});
