//=================================access.php
function TestEnterKey(key)
{
	if (key==13){ 
			Onsubmit_page();
	}
}
function Onsubmit_uplevel()
{
	document.uplevel.action = "";
	document.uplevel.submit();		
}

function Onsubmit_support()
{
	document.support.action ="?support=1";
	document.support.submit();		
}

function Onsubmit_support_parola()
{
	document.parola.action ="?support=2";
	document.parola.submit();		
}

//------------------------------------------------------
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//------------------------------------------------------
function moveLayerToMouseLoc(theLayer)
{
//alert (theLayer);
	if (findDiv(theLayer) != null ) {
 		mouseMove(theLayer);
		MM_showHideLayers(theLayer,'','show');
	}
}
//------------------------------------------------------
function mouseMove(theLayer) {
//ie		
    if (document.all) {
		getMouseLoc();
		layer = findDiv(theLayer);
		layer.style.left = mLoc.x + 7;
		layer.style.top = mLoc.y + 17;
    }
	else
//netscape
	{
		document.onmousemove = getMouseLoc;
		layer = findDiv(theLayer);
		layer.style.left = mLoc.x + 7;
		layer.style.top = mLoc.y + 17;
}
}
//------------------------------------------------------
function getMouseLoc(e)
{
	if (document.all)	//IE
	{
		mLoc.x = event.x + document.body.scrollLeft;
		mLoc.y = event.y + document.body.scrollTop;
	}
	else	//NS
	{
		mLoc.x = e.pageX;
		mLoc.y = e.pageY;
	}
}

//------------------------------------------------------
function findDiv(id){
	if(document.getElementById){ layer = document.getElementById(id);	}
	if (document.all) {	layer = document.all[id];	}
	return layer;
}

//------------------------------------------------------
function showDiv(id){
	if ((layer=findDiv(id))!=null)
		layer.style.display = "block";
}

//------------------------------------------------------
function hideDiv(id) {
	if ((layer=findDiv(id))!=null) 
		layer.style.display = "none";	
}

//------------------------------------------------------
function xorDiv(id){
	if ((layer=findDiv(id))!=null) {
		var mode=layer.style.display;
		switch (mode){
			case "block" :
				layer.style.display = "none";
				break;
			default :
				layer.style.display = "block";
		}//end switch	
	}
}

//------------------------------------------------------
function xorElem(id){
	if ((layer=findDiv(id))!=null) {
		var mode=layer.style.visibility;
		switch (mode){
			case "visible" :
				layer.style.visibility = "hidden";
				break;
			default :
				layer.style.visibility = "visible";
		}//end switch	
	}
}

// menu1 <=> menu2 - folosit in parc_detalii.php
	function add_selected(menu1, menu2) {
		var Obj1=document.getElementById(menu1);
		var Obj2=document.getElementById(menu2);
		var len1=Obj1.options.length;
		var len2=Obj2.options.length;
		if (document.all) {var ie=true;}
// selectez in menu1 ce exista in menu2
		for (k=0; k<len2; k++) {
			for (i=0; i<len1; i++) {
				if (Obj1.options[i].value==Obj2.options[k].value) {
					Obj1.options[i].selected=true;
				}
			}	
		}
// golesc menu2
		remove_options(Obj2);
// adaug in menu2 cele selectate in menu1
		for (k=0; k<len1; k++) {
			if (Obj1.options[k].selected==true) {
				var element_n=document.createElement("OPTION");
				if(ie){ Obj2.add(element_n); }else{ Obj2.appendChild(element_n); }
				element_n.value=Obj1.options[k].value;
				element_n.text=Obj1.options[k].text;
			}
		}
// deselectez tot	
		deselect(Obj1);	deselect(Obj2);	
	}

	function add_all(menu1, menu2) {
		var Obj1=document.getElementById(menu1);
		var Obj2=document.getElementById(menu2);
		var len1=Obj1.options.length;
		var len2=Obj2.options.length;
		if (document.all) {var ie=true;}
// golesc menu2
		remove_options(Obj2);
// adaug in menu2 toate din menu1
		for (k=0; k<len1; k++) {
			var element_n=document.createElement("OPTION");
			if(ie){ Obj2.add(element_n); }else{ Obj2.appendChild(element_n); }
			element_n.value=Obj1.options[k].value;
			element_n.text=Obj1.options[k].text;
		}
		deselect(Obj1);	deselect(Obj2);	
	}

	function remove_selected(menu1, menu2) {
		var Obj1=document.getElementById(menu1);
		var Obj2=document.getElementById(menu2);
		var len2=Obj2.options.length;
		if (document.all) {var ie=true;}
// elimin din menu2 cele selectate
		for (k=len2-1; k>=0; k--) {
			if (Obj2.options[k].selected==true) {
				Obj2.remove(k);		
			}	
		}
		deselect(Obj1);	deselect(Obj2);	
	}

	function remove_all(menu1, menu2) {
		var Obj1=document.getElementById(menu1);
		var Obj2=document.getElementById(menu2);
		var len2=Obj2.options.length;
		if (document.all) {var ie=true;}
		remove_options(Obj2);
		deselect(Obj1);	deselect(Obj2);	
	}

	function deselect(Obj) {
		var len=Obj.options.length;
		for (k=0; k<len; k++) {
			Obj.options[k].selected=false;		
		}	
	}	

	function remove_options(Obj) {
		var len=Obj.options.length;
		for (k=len-1; k>=0; k--) {
			Obj.remove(k);		
		}
	}
// menu1 <=> menu2 end
//--------------transfer parameter from child wind to parent and close parent win
function OpenFile( fileUrl )
{
//	alert (fileUrl);
	window.top.opener.SetUrl( fileUrl ) ;
	window.top.close();
	window.top.opener.focus() ;
}
//--------------confirm box
//many parameters
function confirmare(eparam) {
	var go = confirm("Santeti sigur?");
 	if (go == true) {
   		bCancel=false;
		//alert (eparam + '&act=yes' );
		window.location=eparam + '&act=yes' 

} else {
		//alert (eparam + '&act=yes' );
		window.location=eparam  + '&act=no'
	}
}
//one parameter
function confirmare_1(eparam) {
	var go = confirm("Santeti sigur?");
 	if (go == true) {
   		bCancel=false;
		alert (eparam + '?act=yes' );
		window.location=eparam + '?act=yes' 

} else {
		alert (eparam + '?act=yes' );
		window.location=eparam + '?act=yes' 
	}
}
//------------------------disable right click
function clickIE4(){
	if (event.button==2){
		return false;
	}
}
function clickNS4(e){
	if (document.layers||document.getElementById&&!document.all){
		if (e.which==2||e.which==3){
		return false;
		}
	}
}
function clickIeGk() {
	if (document.layers){
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown=clickNS4;
		}	else if (document.all&&!document.getElementById){
		document.onmousedown=clickIE4;
	}
	document.oncontextmenu=new Function("return false")
}
//-----------------------create new window

function openNewWin(urlT, nameT,t,l,w,h) {
	var sOptions = "toolbar=no,status=no,resizable=no,dependent=yes,scrollbars=yes" ;
	sOptions += ",width=" + w ;
	sOptions += ",height=" + h ;
	sOptions += ",left=" + l;
	sOptions += ",top=" + t;
	var oWindow = window.open( urlT, "NW", sOptions ) ;
}

// =======================================================cookie
 function Get_Cookie(name) {
   var start = document.cookie.indexOf(name+"=");
   var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
   if (start == -1) return null;
   var end = document.cookie.indexOf(";",len);
   if (end == -1) end = document.cookie.length;
   return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) {
    var cookieString = name + "=" +escape(value) +
       ( (expires) ? ";expires=" + expires.toGMTString() : "") +
       ( (path) ? ";path=" + path : "") +
       ( (domain) ? ";domain=" + domain : "") +
       ( (secure) ? ";secure" : "");
    document.cookie = cookieString;
}

function Delete_Cookie(name,path,domain) {
   if (Get_Cookie(name)) document.cookie = name + "=" +
      ( (path) ? ";path=" + path : "/") +
      ( (domain) ? ";domain=" + domain : "") +
      ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}

var today = new Date();
var zero_date = new Date(0,0,0);
today.setTime(today.getTime() - zero_date.getTime());
var cookie_expire_date = new Date(today.getTime() + (8 * 7 * 86400000));

var loaded_script = true;

//--set persoana id and ful name
function setCookiePersoana(idP,numeP,numeCookie){
	var persoanaVal=idP+'/'+numeP;
	Set_Cookie(numeCookie,persoanaVal,cookie_expire_date,'/');
}
//--set institutie
function setCookieInstitutie(idI,numeI,numeCookie){
	var institutieVal=idI+'/'+numeI;
	Set_Cookie(numeCookie,institutieVal,cookie_expire_date,'/');
}
//--set culoare
function setCookieCuloare(idC,numeC,hexaC,numeCookie){
	var culoareVal=idC+'/'+numeC+'/'+hexaC;
	Set_Cookie(numeCookie,culoareVal,cookie_expire_date,'/');
}
//--set clasificare
function setCookieClasificare(idDB,numeDB,numeCookie){
	var elemClasifVal=idDB+'/'+numeDB;
	Set_Cookie(numeCookie,elemClasifVal,cookie_expire_date,'/');
}
//--set dictionar
function setCookieDictionar(idDict,numeDict,numeCookie){
	var elemDictVal=idDict+'/'+numeDict;
	Set_Cookie(numeCookie,elemDictVal,cookie_expire_date,'/');
}


//--set persoana id and ful name
function setCookieBackUrl(valCookie,numeCookie){
	Set_Cookie(numeCookie,valCookie,cookie_expire_date,'/');
}
//sdel cookie
function stergeCaractDbCokie(fn){
	var numeCookie='db_caract_c'+fn;
	Set_Cookie(numeCookie,'',cookie_expire_date,'/');
}
/*		end		*/ 

// Removes leading whitespaces
function LTrim( value ) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim( value ) {
	return LTrim(RTrim(value));
}

function IsNumeric(sText) {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   if (sText.length == 0) IsNumber = false;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}