function get_info_box(status_id, id, term, el, type)
{
	term = term.replace(/\'/i,"&apos;");
	if(jQuery('#info_box').is(':visible'))
	{
		jQuery('#info_box:visible').hide("slide", {direction: "down"}, 200, function(){
			var stat_list = "";
			var status = ["Pending","Live","Rejected"];
			for ( var i in status )
			{
				if(i==status_id)
				{
					stat_list += "<li><b>"+status[i]+"</b></li>";
				}
				else
				{
					stat_list += "<li><a href='#' onClick='change_status("+id+","+i+",\""+term+"\");return false;'>"+status[i]+"</a></li>";
				}
			} 
			n=jQuery("#"+el.id).offset();
			cont = 'Change '+term+' status:'+
					'<ul>'+stat_list+'</ul>'+
					'<a href="#" onClick="close_info_box();return false;">cancel</a>';
			jQuery('#info_box_cont').html(cont);
			jQuery('#info_box').css({'top':(n.top-jQuery('#info_box').height())-10,'left':n.left-10,'position':'absolute'});
			jQuery('#info_box').show("slide", {direction: "down"}, 200);
		});
	}
	else
	{
		var stat_list = "";
		var status = ["Pending","Live","Rejected"];
		for ( var i in status )
		{
			if(i==status_id)
			{
				stat_list += "<li><b>"+status[i]+"</b></li>";
			}
			else
			{
				stat_list += "<li><a href='#' onClick='change_status("+id+","+i+",\""+term+"\",\""+type+"\");return false;'>"+status[i]+"</a></li>";
			}
		} 
		n=jQuery("#"+el.id).offset();
		cont = 'Change '+term+' status:'+
				'<ul>'+stat_list+'</ul>'+
				'<a href="#" onClick="close_info_box();return false;">cancel</a>';
		jQuery('#info_box_cont').html(cont);
		jQuery('#info_box').css({'top':(n.top-jQuery('#info_box').height())-20,'left':n.left-10,'position':'absolute'});
		jQuery('#info_box_down_arrow').css({'top':jQuery('#info_box').height()+10,'position':'absolute'});
		jQuery('#info_box').show("slide", {direction: "down"}, 200);
	}
}

function change_status(id, stat_id, term, type)
{	
	jQuery.get("/index.php", {type:"ajaxChange"+type+"Status", region:"ajax", id:""+id+"", n:""+stat_id+"", s:""+term+""}, function(data){
		jQuery('#story_tag_'+id).fadeOut(200, function(){
			if(data.length >0) {
				jQuery('#story_tag_'+id).html(data).css( "font-weight", "normal" ).fadeIn(200);
			}
		});
	});
	close_info_box();
}

function change_status_edit(id, stat_id, term, type)
{	
	jQuery.get("/index.php", {type:"ajaxChange"+type+"Status", region:"ajax", id:""+id+"", n:""+stat_id+"", s:""+term+""}, function(data){
		jQuery('#status_box .cont').fadeOut(200, function(){
				var stat_list = "";
				var status = ["Pending","Live","Rejected"];
				for ( var i in status )
				{
					if(i==stat_id)
					{
						stat_list += "<li class='"+status[i]+"'><b>"+status[i]+"</b></li>";
					}
					else
					{
						stat_list += "<li><a href='#' onClick='change_status_edit("+id+","+i+",\""+term+"\",\"Story\");return false;'>"+status[i]+"</a></li>";
					}
				} 
				cont = stat_list;

				jQuery('#status_box .cont').html(cont).css( "font-weight", "normal" ).fadeIn(200);
		});
	});
	close_info_box();
}

function close_info_box()
{
	jQuery('#info_box').hide("slide", {direction: "down"}, 200);
}


        
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 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 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",".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 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");
}

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);


