nav = navigator.appName.indexOf("Microsoft")!= -1 ? 1 : 2;

function setCookie(name,thevalue){
	var theDate = new Date();
	var oneYearLater = new Date( theDate.getTime() + 31536000000 );
	var expiryDate = oneYearLater.toGMTString();
	document.cookie=name+'='+thevalue+';path=/;expires='+expiryDate;
}
function popup(url, name, width, height, scroll, modal, resizable) {
	width=Math.min(screen.availWidth,width);
	height=Math.min(screen.availHeight-40,height);
	var poz_x=(screen.availWidth-width)/2;
	var poz_y=(screen.availHeight-height-30)/2;
	newwin=window.open(url, name, 'scrollbars='+scroll+', menubar=no, width='+width+', height='+height+', resizable=no,toolbar=no, left='+poz_x+', top='+poz_y+', location=no, status=no');
	if(modal){
		popInt=setInterval(function(n){
			if(typeof(newwin.name)=="string"){
				if(newwin.document.body){
					openerfocus=function(){
						if(typeof(newwin.name)=="string"){
							newwin.focus();
						}else{
							document.body.onfocus=null;
						}
					}
					document.body.onfocus=openerfocus;
					newwin.window.document.body.onunload=function(){}
					newwin.focus();
					/*with(newwin){
						self.focus()
						opener.document.body.onfocus=function(){self.focus();opener.alert(4);}
						self.document.body.onunload=function(){opener.document.body.onfocus=null}
					}*/
					clearInterval(popInt);
				}
			}else{
				clearInterval(popInt)
			}
		},1)
	}
}

function ajax_judet_localitate(elementdeschimbat,judetAles,orasAles,numeCamp,actiuneCamp){
	var ajaxRequest;
	var queryString="";
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			if(document.getElementById("ajax_feed_verify"+numeCamp)){
				document.getElementById("ajax_feed_verify"+numeCamp).value = ajaxRequest.responseText;
			}
			if(document.getElementById(elementdeschimbat)){
				document.getElementById(elementdeschimbat).innerHTML=ajaxRequest.responseText;
			}
		}
	}

	if(elementdeschimbat){
		var queryString=queryString + "&elementdeschimbat=" + elementdeschimbat;
	}
	if(orasAles){
		var queryString=queryString + "&orasAles=" + orasAles;
	}
	if(judetAles){
		var queryString=queryString + "&judetAles=" + judetAles;
	}
	if(numeCamp){
		var queryString=queryString + "&numeCamp=" + numeCamp;
	}
	
	if(actiuneCamp){
		var queryString=queryString + "&actiuneCamp=" + actiuneCamp;
	}
	
	ajaxRequest.open("GET", "util/validare_judet_localitate.php?" + queryString, true);

	ajaxRequest.send(null);
}
function rand( min, max ) {
	var argc = arguments.length;
	if (argc == 0) {
		min = 0;
		max = 2147483647;
	} else if (argc == 1) {
		throw new Error('Warning: rand() expects exactly 2 parameters, 1 given');
	}
	return Math.floor(Math.random() * (max - min + 1)) + min;
}

