var lista = new Array( 'emis', 'etape', 'celenoi', 'lista_1', 'lista_2', 'canale_pr', 'tag_pr', 'bicol', 'mainflvs', 'noumygsp' );

var lista_jos = new Array( 3,4,5,6,9 );

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 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 "";
}

function ascunde( id ){
	document.getElementById(lista[id]).className='motivHidde'; 
	document.getElementById(lista[id]+'_ascunde').className='motivHidde'; 
	document.getElementById(lista[id]+'_arata').className='motivShow';
	setCookie( 'zona_'+lista[id], 1, 1 );
	zone_ajax(id,0);
}

function arata( id ){
	document.getElementById(lista[id]).className='motivShow'; 
	document.getElementById(lista[id]+'_arata').className='motivHidde'; 
	document.getElementById(lista[id]+'_ascunde').className='motivShow';
	setCookie( 'zona_'+lista[id], 0, -1 );
	zone_ajax(id,1);
	
	if ( ( emis_1 == 1 && id == 0 ) || ( etapa_1 == 1 && id == 1 ) ){
		location.reload(true);
	}
	
}

function ascunde_zone(){
	for( x in lista ){
		var temp = getCookie( 'zona_'+lista[x] );
		if (temp!=null && temp!=""){
			if( document.getElementById(lista[x]) != null ){
				ascunde( x );
				if( x == 0 ){
					emis_1 = 1;
				}
				
				if( x == 1 ){
					etapa_1 = 1;
				}
			}
		}		
	}
}

function arata_zona_jos(){
	for( x in lista_jos ){
		if( document.getElementById('v'+lista_jos[x]) != null ){
			if(document.getElementById('v'+lista_jos[x]).checked){
				document.getElementById('v7').checked = true;
			}
		}
	}
}


function zone_ajax( id, tip ){
	$.ajax({
	  type: "GET",
	  url: "index.php",
	  data: "id="+id+"&ajax=1&tip="+tip,
	  success: function(msg){
	    if( parseInt(msg) == 1 ){
	    	//alert('Modificarile au fost salvate !!!');
	    }
	  }
	});
}

function activeaza_arata( id ){
	setCookie( 'zona_'+lista[id], 0, -1 );
	window.location = "/alege_zone.php?id="+id;
}

function tab_ajax( id, tip ){
	$.ajax({
	  type: "GET",
	  url: "index.php",
	  data: "id="+id+"&tabajax=1&tip="+tip,
	  success: function(msg){
		window.location = "redi.php?ancora=ancora_3";
	  }
	});
}
