function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function tog_div(szDivID, iState) {// 1 visible, 0 hidden
	
	if(document.layers)	{   //NN4+
		if (!(iState)) { iState = (document.layers[szDivID].style.display=='none') ? 1 : 0; }
		document.layers[szDivID].style.display = (iState==1) ? "block" : "none";
	} else if(document.getElementById) {  //gecko(NN6) + IE 5+
		var obj = document.getElementById(szDivID);
		if (!(iState)) { iState = (obj.style.display=='none') ? 1 : 0; }
		obj.style.display  = (iState==1) ? "block" : "none";
	} else if(document.all) {	// IE 4
		if (!(iState)) { iState = (document.all[szDivID].style.display=='none') ? 1 : 0; }
		document.all[szDivID].style.display = (iState==1) ? "block" : "none";
	}
}
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 it(nume) { return document.getElementById(nume).value; }
function ck(nume) { return document.getElementById(nume).checked; }
function rd(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length;	if(radioLength == undefined) if(radioObj.checked) 	return radioObj.value; else return ""; for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; }	} return ""; }

function updateOras() {
	setCookie('oras',it('oras'),999);
	window.location.reload();
}


function InsertHTML(stuffneeded)
{
 var oEditor = FCKeditorAPI.GetInstance('html') ;
 if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
 {
 oEditor.InsertHtml( stuffneeded ) ;
 }
 else
 alert( 'You must be on WYSIWYG mode!' ) ;
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// AJAX CRAP ***************************************************************************

/* The following function creates an XMLHttpRequest object... */

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

/* You can get more specific with version information by using 
	parseInt(navigator.appVersion)
	Which will extract an integer value containing the version 
	of the browser being used.
*/
/* The variable http will hold our new XMLHttpRequest object. */
var http = createRequestObject(); 

/* Function called to get the product categories list */
function getAJAX(def_zone){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
		document contains references to all items on the page
		We can reference document.form_category_select.select_category_select and we will 		
		be referencing the dropdown list. The selectedIndex property will give us the 
		index of the selected item. 
	*/
	http.open('get', 'get_ajax.php?action=get_zone&id_oras='+document.getElementById('id_oras').value+'&id_selected='+def_zone);
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = handleProducts; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleProducts(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		document.getElementById('div_zona').innerHTML = response;
	}
}
var ajax_action='';

function doAJAX(aj_action,params){
	http.open('get', 'get_ajax.php?action='+aj_action+'&'+params);
	ajax_action=aj_action;
	http.onreadystatechange = handleResult; 
	http.send(null);
}
function handleResult(){
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;
		document.getElementById('div_'+ajax_action).innerHTML = response;
	}
}