function AddToBookmarks (url,title) 
{ 
window.external.AddFavorite(url,title); 
}  

function clearDefault(el) {
	if (el.defaultValue==el.value) el.value = ""
}

function restoreDefault(el) {
	if (el.value == "") el.value = el.defaultValue
}

function closeWindow()
{
	//var browserName = navigator.appName;
	//var browserVer = parseInt(navigator.appVersion);
	var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;  

    if (ie7) 
	{    
        //This method is required to close a window without any prompt for IE7
		window.open('','_parent','');
		window.close();
    }
    else 
	{
		//This method is required to close a window without any prompt for IE6
		this.focus();
		self.opener = this;
		self.close();
	}
}
        
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 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 updateCommentStatus(inputString, name) {
	var bits=name.split("_"); 
	var id=bits[1];
	jQuery('#modOps_'+id).show( "slow" ).css( "font-weight", "bold" ).html("<option>updating comment status...</option>");
	
	jQuery.get("/index.php", {type:"ajaxUpdateCommentStatus", region:"ajax", id:""+id+"", s:""+inputString+""}, function(data){
	jQuery('#modOps_'+id).hide("slow");
	if(data.length >0) {
		jQuery('#modOps_'+id).html(data).css( "font-weight", "normal" ).show( "slow" );
	}});
	
}

function textLarger()
{
	var currentFontSize = 0;
	var mumblers = [".text","#col-centre h2","#breadcrumb",".text h2",".text h3",".text h4","#nav li a","#col-right","#col-right #tag-cloud a","#col-left"];
	mumblers.each( function(eles)
	{
		currentEl = eles;
		currentFontSize = parseFloat(jQuery(currentEl).css('font-size'));
		if(currentFontSize < 16)
		{
			var newFontSize = (currentFontSize+2)+"px";
			jQuery(currentEl).css('font-size', newFontSize);
		}
	}); 
    return false;
}

function textSmaller()
{
	var currentFontSize = 0;                                                                                                           
    var mumblers = [".text","#col-centre h2","#breadcrumb",".text h2",".text h3",".text h4","#nav li a","#col-right","#col-right #tag-cloud a","#col-left"];
    mumblers.each( function(eles)
	{
		currentEl = eles;
		currentFontSize = parseFloat(jQuery(currentEl).css('font-size'));
		if(currentFontSize > 10)
		{
			var newFontSize = (currentFontSize-2)+"px";
			jQuery(currentEl).css('font-size', newFontSize);
		}
	}); 
    return false;
}
     
function change_client_status(status, id)
{
    if(!jQuery(".stat-switch."+status).hasClass("on"))
    {                                                
        jQuery(".stat-switch").removeClass("on");
        jQuery(".stat-switch."+status).addClass("on");
        jQuery.get("/index.php", {type:"ajaxChangeClientStatus", region:"ajax", id:""+id+"", s:""+status+""}, function(data){
            if(data.length > 0)
            {
                jQuery("#term_"+id).html(data);
                jQuery("#term_"+id).fadeIn(200);
            }
        });    
    }
}

function edit_term(id)
{
    jQuery("#term_"+id).fadeOut(200);
    jQuery.get("/index.php", {type:"ajaxGetTermEditField", region:"ajax", id:""+id+""}, function(data){
        if(data.length > 0)
        {
            jQuery("#term_"+id).html(data);
            jQuery("#term_"+id).fadeIn(200);
        }
    });
    
}

function cancel_update_term(id)
{
	jQuery("#term_"+id).fadeOut(200);
	jQuery.get("/index.php", {type:"ajaxGetTermValue", region:"ajax", id:""+id+""}, function(data){
		if(data.length > 0)
		{
			jQuery("#term_"+id).html(data);
			jQuery("#term_"+id).fadeIn(200);
		}
	});
}

function update_term(id)
{
	new_term = jQuery("#term_field_"+id).attr("value");
	jQuery("#term_"+id).fadeOut(200);
	jQuery.get("/index.php", {type:"ajaxUpdateTermValue", region:"ajax", id:""+id+"", s:""+new_term+""}, function(data){
		jQuery.get("/index.php", {type:"ajaxGetTermValue", region:"ajax", id:""+id+""}, function(data){
			if(data.length > 0)
			{
				jQuery("#term_"+id).html(data);
				jQuery("#term_"+id).fadeIn(200);
			}
		});
	});
}

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 set_language(val)
{        
    id=jQuery(val).attr("value");
    jQuery.get("/index.php", {type:"ajaxSetLanguage", region:"ajax", id:""+id+""}, function(data){
        location.reload(true);
    });                                    
}

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);