function toggle_menu(el){
if (document.getElementById(el).style.display == 'none')
		document.getElementById(el).style.display = 'block';
	else
		document.getElementById(el).style.display = 'none';
}

function handleToggleMenu(id) {
		var url = baseUrl + '/category/getchilds';
	    $('#menu'+id).load(url, {kat_parent: id}, function() {;});    
	    toggle_menu('menu' + id);
}

function handleSet(id, parent_id) {
		//var url = baseUrl + '/category/handleset';
	    //$('#empty').load(url, {kat_id: id, kat_parent: parent_id}, function() {;});    
}

function handleChangeVal(id, event){

	if(event == 'onclick' && navigator.appName != "Microsoft Internet Explorer")
		return;
	if(event == 'onchange' && navigator.appName == "Microsoft Internet Explorer")
		return;	

	var url = baseUrl + '/category/handlechangeval';
	var s = false;

	if (document.getElementById('kat_item' + id).checked)
		s = true;
	$.post(url, {kat_id: id, set: s}, function(){;});   
	var tmpId = "#sm" + id;	
	var list = $(tmpId+ " .menuItemContentCh");
	
	if(s)
		for(i = 0; i<list.length;i++)
		{
			list[i].checked = true;
			
			//list[i].setAttribute("checked",true); 
			//list[i].
		}
	else
		for(i = 0; i<list.length;i++)
			list[i].checked = false;			
		
}

function clearSelection()
{
	
	$.post(baseUrl + '/category/clearselection', {}, function() {window.location.href=baseUrl + "/index/index";});
	//var list = $(".menuItemContentCh");

	//for(i = 0; i<list.length;i++)
	//	list[i].checked = false;
	//$("#searchField").val(""); 


}

function search()
{
	var sf = document.getElementById("searchField");


	if(sf.className == "emptySearch text")
	{
		sf.value = "";
		sf.className  = "search text";
	}

}

function setCookie(c_name,value,expiredays)                                                                                                                  
{                                                                                                                                                            
var exdate=new Date();                                                                                                                                       
exdate.setDate(exdate.getDate()+expiredays);                                                                                                                 
document.cookie=c_name+ "=" +escape(value)+                                                                                                                  
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());                                                                                                
}                                                                                                                                                            
                                                                                                                                                             
                                                                                                                                                             
function changeStyle(id, newClass){                                                                                                                          
                document.getElementById(id).className = newClass;                                                                                            
}      

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

// by kp

function checkUncheckAll(theElement) {
    var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
     if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm[z].checked = theElement.checked;
	  }
    }
   }
