
	
	//fckeditor // update editors content
	function getEditorContent(instanceName) {             
		var oEditor = FCKeditorAPI.GetInstance(instanceName) ;
   	    return oEditor.GetXHTML( true ); 		      
	} 

	//to clear default field value
	function clearText(thefield){
		if (thefield.defaultValue==thefield.value)
			thefield.value = ""
	} 
	
	function setBackText(thefield){
		if (thefield.value=="")
			thefield.value = thefield.defaultValue;
	} 

	function switch_row(value,id){

		if (value){
			//fix for IE7
			var x = navigator;
			x.userAgent;
				
			var i = (x.userAgent+'').indexOf("MSIE 7.0;", 1 ); 
					
			if (i>0)									
				$("#"+id).parent().parent().css({display:'block'});		
			else
				$("#"+id).parent().parent().css({display:'table-row'});		
		} else
			$("#"+id).parent().parent().css({display:'none'});		
	}
	
	


	
	
	$(document).livequery(function () {	
		/*$("#settings_form").livequery("submit",function(){
														
//			myajax_Form(document.getElementById('settings_form'),{lightbox_errors:true,success:'location.href=\'index.php\''});											
			var options = {
				url:undefined,
				success:function(msg){
					document.location.href='index.php';
				}
			}
						
			
			$(this).ajaxSubmit(options); 
			
			return false;
		});*/
									
									
		$(".groupItem .itemHeader a.close").livequery("click",function(){
			$(this).parent().parent().css({display:'none'});	
			myajax_Request({url:'index.php?act=rss_close&id='+$(this).parent().parent().attr("id")});
			return false;			
		});
	
		$("#customise_panel #reset").livequery("click",function(){
			if (confirm('Are you sure you want to reset your home page?')){
				myajax_Request({url:'index.php?act=rss_reset',success:'location.href=\'index.php\''});																
				if ($("#settings").css('display') == 'block')
					$("#settings").slideUp("fast");
			}
			return false;			
		});
		
		
	
		$(".colors a").livequery("click",function(){
			$(".colors a").removeClass("selected");									  
			$(this).addClass("selected");		
			
			document.getElementById('id_color').value=$(this).attr("id");
			return false;
		});		
		
		
		$("#btn_cancel").livequery("click",function(){

			if ($("#settings").css('display') == 'block')
				$("#settings").slideUp("fast");

			return false;
		});		
		
		
		$("#customise_panel #customize").livequery("click",function(){
															
			if ($("#settings").css('display') == 'block')
				$("#settings").slideUp("fast");			
			else
				$("#settings").slideDown("slow");

			return false;
		});		
	
		$("#nav_item").livequery("change",function(){
												
			switch_row(this.value,'ord');
			switch_row(this.value,'url');			
			switch_row(this.value,'parent');			
		});
		
		$("#nav_item").livequery(function(){
										 
			switch_row(this.value,'ord');
			switch_row(this.value,'url');	
			switch_row(this.value,'parent');				
		});
		

		session_interval=setInterval(function(){
			myajax_Request({url:'index.php?c=ajax&template=blank'});
			myajax_Request({url:'forum/'});
		},300000);

		//search form
		$("#search_form input").livequery("focus",function(){
			clearText(this);							   
		});
		$("#search_form input").livequery("blur",function(){
			setBackText(this);							   
		});				
	
		//login module
		$(".login input").livequery("focus",function(){
			clearText(this);							   
		});
		$(".login input").livequery("blur",function(){
			setBackText(this);							   
		});		
	
		$("#top #login form input").livequery("keydown",function(e){
			if (e.keyCode==13)													 
				this.parentNode.submit();						   
		});



		$(".tabnav li a").livequery("click",function(){
			var selected_tab=$(this).attr("href");
			
			$(".tabnav li a",this.parentNode.parentNode.parentNode).removeClass("selected");									 
			$(this).addClass("selected");		
		
			$(".tabdiv.selected",this.parentNode.parentNode.parentNode).slideUp("fast",function(){
														  
			    $(".tabdiv.selected",this.parentNode).removeClass("selected");	
			    $("#"+selected_tab).addClass("selected");					
			  
				$("#"+selected_tab).slideDown("fast");											  
			});
			return false;
			
		});
	


									

		//blog archive
		$(".archive a[href=#]").livequery("click",function(){
			if ($("ul:first",this.parentNode).css('display')=='none')											   
				$("ul:first",this.parentNode).slideDown("fast");		
			else
				$("ul:first",this.parentNode).slideUp("fast");
		
			return false;
		});
		
		
	});

