
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
			
function toggleTT(_w,_h)
{
    if (document.all) { // is IE
        if (_h=='s') eval("document.all."+_w+".style.display='inline';");
        if (_h=='h') eval("document.all."+_w+".style.display='none';");
    }
    else if(document.getElementById(_w)){ // is firefox? 
        elem = document.getElementById(_w);          
        if (_h=='s'){
            elem.style.display='table-row';
        }
        else elem.style.display='none';     
    } 
    else { // is NS? 
        if (_h=='s') eval("document.layers['"+_w+"'].display='inline';");
        if (_h=='h') eval("document.layers['"+_w+"'].display='none';");
    }
}

function clearDefault(el) {
	if (el.defaultValue==el.value) el.value = ""
}

function restoreDefault(el) {
	if (el.value == "") el.value = el.defaultValue
}

function toggleElement(element)
{
	if(document.getElementById(element).style.display!='')
	{
		document.getElementById(element).style.display='';
	}
	else
	{
		document.getElementById(element).style.display='none';
	}
}

function toggleR(id)
{           
	jQuery(".options").hide();
        jQuery("#"+id).show(); 
}


function toggleT(_w, _d)
{
	if (document.all) 
	{ // is IE
		if (eval("document.all."+_w+".style.display == 'none'"))
		{
			eval("document.all."+_w+".style.display='inline';");
			eval("document.all."+_w+"_img.src='/images/minimise.gif';")
		}
		else 
		{
			eval("document.all."+_w+".style.display='none';");
			eval("document.all."+_w+"_img.src='/images/expand.gif';")
		}
	}
	else if(document.getElementById(_w)){ // is firefox? 
		elem = document.getElementById(_w);
		img = document.getElementById(_w+"_img")
		if (elem.style.display=='none')
		{
			elem.style.display=_d;
			img.src='/images/minimise.gif';
		}
		else 
		{
			elem.style.display='none';
			img.src='/images/expand.gif';
		}
	}
	else { // is NS? 
		if (eval("document.layers['"+_w+"'].display=='none';"))
		{
			eval("document.layers['"+_w+"'].display='inline';")
			eval("document.layers['"+_w+"_img'].src='/images/maximise.gif';")
		}
		else 
		{
			eval("document.layers['"+_w+"'].display='none';")
			eval("document.layers['"+_w+"_img'].src='/images/maximise.gif';")
		}
	}
}

function showLoader()
{
		document.getElementById("loading").style.display="block";
		document.getElementById("loading_con").style.display="block";
}

function confirmAction(message, url)
{
	if (confirm(message)) 
	{
		document.location = url;
	}
}

function textLarger()
{
	var currentFontSize = 0;
	var mumblers = [".text",".text h2",".text h3",".text h4","#nav","#right-column"]
	mumblers.each( function(eles)
	{
		currentEl = eles;
		currentFontSize = parseFloat(jQuery(currentEl).css('font-size'));
		if(currentFontSize < 20)
		{
			var newFontSize = (currentFontSize+2)+"px";
			jQuery(currentEl).css('font-size', newFontSize);
		}
	}); 
    return false;
}

function textSmaller()
{
	var currentFontSize = 0;
	var mumblers = [".text",".text h2",".text h3",".text h4","#nav","#right-column"]
	mumblers.each( function(eles)
	{
		currentEl = eles;
		currentFontSize = parseFloat(jQuery(currentEl).css('font-size'));
		if(currentFontSize > 8)
		{
			var newFontSize = (currentFontSize-2)+"px";
			jQuery(currentEl).css('font-size', newFontSize);
		}
	}); 
    return false;
}
function changeCaptcha()
{
		var rand=Math.floor(Math.random()*10000)
		jQuery('#captcha').attr({"src":"/images/captcha/captcha.php?rand="+rand});
}

function expand_link(id)
{                                             
    jQuery("#links_list #cat_"+id+"").toggle();
    jQuery("#cat_link_"+id+".expand").toggleClass("minimise");
}          

function load_image(str,obj)
{
	$("#gallery-photo, #gallery-photo-title").fadeOut(500,function(){
		$.loadImages(str,function(){
			var title=jQuery(obj).attr("title");
			$("#gallery-photo").attr("src",str);
			$("#gallery-photo").attr("alt",title);
			$("#gallery-photo").attr("title",title);
			$("#gallery-photo").fadeIn(500);
			$("#gallery-photo-title").html(title).fadeIn(500);
		});
	});
	return false;
}

function toggle_feed(type){
	if(type=='blog'){
		$("#news-nav h2").addClass("blogged");
		$("#news-items").fadeOut(0,function(){
			$("#blog-items").fadeIn(0);
		});
	}
	else{
		$("#news-nav h2").removeClass("blogged");
		$("#blog-items").fadeOut(0,function(){
			$("#news-items").fadeIn(0);
		});
	}
	return false;
}
                                                                 
$(document).ready(function(){
	var atavist = "false";
    jQuery.each(jQuery.browser, function(i, val) {
		if(i=="msie" && jQuery.browser.version.substr(0,3)=="6.0")
	    {
 		    atavist = "true";
	    } 
    });    
    if(atavist=="false")
	{
		if($("#nav ul").length)
	    { 
	        $("#nav ul").superfish({ 
	            delay:       500,                            // one second delay on mouseout 
	            animation:   {height:'show'},  // fade-in and slide-down animation 
	            speed:       "fast",                          // faster animation speed 
	            autoArrows:  false,                           // disable generation of arrow mark-up  
	            hoverClass:'sfhover',
	            onShow: function(){
	            	$(this).parent("li").addClass("selected");
	            },
	            onHide: function(){
	            	$(this).parent("li").removeClass("selected");
	            }
	        });        
	    }
		$("h2#blog_control").click(function(){return toggle_feed("blog")});
		$("h2#news_control").click(function(){return toggle_feed("news")});
	}

    if($("#add-favourites").length){ 
    	$("#add-favourites").jBrowserBookmark();
    }
    $("#print_button").click(function(){ 
    	window.print();
    });
    if($(".enq-form-small #contactUs").length)
    { 
    	$.get("/index.php", {type:"getFormSec", region:"ajax", id:"0"},function(txt){
    		$(".contactUs").append('<input type="hidden" name="ts" value="'+txt+'" />');
    	});
    }
    else if($("#subscribe_newsletter").length)
    { 
    	$.get("/index.php", {type:"getFormSec", region:"ajax", id:"0"},function(txt){
    		$("#subscribe_newsletter").append('<input type="hidden" name="ts" value="'+txt+'" />');
    	});
    }
    $("a.target_blank").click(function(){
    	window.open($(this).attr("href"));
    	return false;
    });

	if ( $.browser.msie ) {
		if( parseInt($.browser.version) <9 ){
		    $("#type_select").mousedown(function(){
		    			$(this).css("width", "auto");
		            });
		    $("#type_select").bind('blur change',function(){
		                $(this).css("width", "125px");
		            });
		}
	}
	$("a.staff_link").hover(
				function(){
					var sel=$(this).attr("id");
					var bits = sel.split("_");
					var i = bits[1];
					$("div#ss_0").fadeOut(0);
					$("div#ss_"+i).fadeIn(0);
				},
				function(){
					var sel=$(this).attr("id");
					var bits = sel.split("_");
					var i = bits[1];
					$("div#ss_0").fadeIn(0);
					$("div#ss_"+i).fadeOut(0);
				}
				)
}); 

