//Autor Vicentiu Maxim, Amax SRL CUI2206377. Proprietate intelectuala. 
//Proiect/document elaborat in 2008, componente elaborate in perioada: 2006-2008
//Toate drepturile rezervate. Preluarea, distribuirea, publicarea in totalitate sau in parte sunt strict interzise fara acordul scris al autorului.
/////////////////////////////////////////////////////////////////////////////
var b = 1;//bascula
//verifica argumentele sa fie NonEmpty; 
function valid_ne(){
    var r = 1;
    for (var i = 0; i < arguments.length; i++) {
        if (arguments[i].value === "") {
            r *= 0;
        }
        else {
            r *= 1;
        }
    }
    //if (r==0) alert("Va rugam sa completati campurile formularului.");
    return r;
}

function valid_ne_s(){
    var r = 1;
    var s;
    for (var i = 0; i < arguments.length; i++) {
        s = arguments[i].value;
        if (s.replace(/\ /g, "") == "") 
            r *= 0;
        else 
            r *= 1;
    }
    return r
}

//verifica argumentele de la 1 in sus sa fie de cel putin marime argument 0 -- BiggerThan
function valid_bt(){
    var r = 1;
    for (var i = 1; i < arguments.length; i++) {
        if (arguments[i].value.length < arguments[0]) {
            r *= 0;
        }
        else {
            r *= 1;
        }
    }
    return r;
}

// verifica daca x este egal cu y; in caz de inegalitate alert mesajul z
function egale(x, y, z){
    var r = 1;
    if (x.value != y.value) {
        r = 0;
        x.focus();
        alert(z);
    }
    return r;
}

//pop-up vizualizare album foto: user view album
function uvalbum(id){
    var params = '';
    
    if (arguments.length == 1) {
        params = 'id=' + id;
    }
    else {
        return false;
    }
    
    u = window.open("./uvalbum.php?" + params, "galerie_editview", "alwaysRaised=yes, dependent=yes, directories=no, height=600, width=700, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    u.focus();
    return true;
}

//pop-up fereastra de editare mesaj in limba lang
function AddEditLang(id, lang)//adauga sau editeaza mesajul id in limba lang 
{
    var params = "id=" + id;
    
    if (lang.length > 0) {
        params = params + "&lang=" + lang;
    }
    window.open("./amsg_add_edit.php?" + params, "intretinere_tabela_mesaje", "alwaysRaised=yes, dependent=yes, directories=no, height=250, width=550, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

//fereastra de editare categorie
function AddEditCateg(id, nivel, edit){
    var params = '';
    
    if (arguments.length == 3) //id est probabil add sau edit, altfel add categ de rang 0
    {
        params = 'id=' + id + '&nivel=' + nivel + '&edit=' + edit;
    }
    
    window.open("./acateg_add_edit.php?" + params, "intretinere_tabele_iscateg", "alwaysRaised=yes, dependent=yes, directories=no, height=300, width=550, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

//fereastra de editare caracteristici
function AddEditCaract(nume_categ, id, niv, ce){
    //ce= ce e 0=unitate, 1=oferta 
    var params = 'nume_categ=' + nume_categ + '&id=' + id + '&nivel=' + niv + '&ce=' + ce;
    
    window.open("./acaract_add_edit.php?" + params, "intretinere_tabele_iscaract", "alwaysRaised=yes, dependent=yes, directories=no, height=300, width=550, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

//fereastra de editare pagina
function AddEditPagstat(id){
    var params = '';
    
    if (arguments.length == 1) //id est probabil add sau edit, altfel add categ de rang 0
    {
        params = 'id=' + id;
    }
    
    //	window.open('./apagstat_add_edit.php?'+params, 'wsx', 'height=600px,width=700px');//js 1.0, 1.1
    window.open("./apagstat_add_edit.php?" + params, "intretinere_tabele_ispagstat", "alwaysRaised=yes, dependent=yes, directories=no, height=600, width=700, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

//fereastra de editare tip de inscriere (gold, silver, etc;
function AddEditTip(id, pret, moneda){
    var params = '';
    
    if (arguments.length == 3) //id est probabil ..
    {
        params = 'id=' + id + '&pret=' + pret + '&moneda=' + moneda;
    }
    
    window.open("./atip_add_edit.php?" + params, "intretinere_tabele_istip", "alwaysRaised=yes, dependent=yes, directories=no, height=330, width=550, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

//fereastra de editare stare (activ, in asteptare, sters, etc);
function AddEditStare(id){
    var params = '';
    
    if (arguments.length == 1) //id est probabil add sau edit, altfel add categ de rang 0
    {
        params = 'id=' + id;
    }
    
    window.open("./astare_add_edit.php?" + params, "intretinere_tabele_isstare", "alwaysRaised=yes, dependent=yes, directories=no, height=300, width=550, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

//fereastra de scriere mesaj catre administratorul sitului
function ContactAdmin(linkid){
    var params = '';
    
    if (arguments.length == 1) {
        params = 'e=' + linkid;
    }
    
    window.open("./contact_admin.php?" + params, "contact_admin", "alwaysRaised=yes, dependent=yes, directories=no, height=300, width=550, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

//fereastra de vizualizare oferta, unitate, etc.
function ViewItem(id, lang){
    var params = '';
    
    if (arguments.length == 2) {
        params = 'id=' + id + '&lang=' + lang;
    }
    else {
        return false;
    }
    
    window.open("./uvelem.php?" + params, "citem_viewer", "alwaysRaised=yes, dependent=yes, directories=no, height=600, width=900, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

//separat pe tabele deci devine view item pt uc, ua, etc;
function ViewItemUC(id, lang){
    var params = '';
    
    if (arguments.length == 2) {
        params = 'id=' + id + '&lang=' + lang;
    }
    else {
        return false;
    }
    
    u = window.open("./uvelem_uc.php?" + params, "cuc_viewer", "alwaysRaised=yes, dependent=yes, directories=no, height=600, width=900, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    u.focus();
    return true;
}

function ViewItemAG(id, lang){
    var params = '';
    
    if (arguments.length == 2) {
        params = 'id=' + id + '&lang=' + lang;
    }
    else {
        return false;
    }
    
    u = window.open("./uvelem_ag.php?" + params, "cuag_viewer", "alwaysRaised=yes, dependent=yes, directories=no, height=600, width=900, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    u.focus();
    return true;
}

function ViewItemOUC(id, lang){
    var params = '';
    
    if (arguments.length == 2) {
        params = 'id=' + id + '&lang=' + lang;
    }
    else {
        return false;
    }
    
    u = window.open("./uvelem_ouc.php?" + params, "couc_viewer", "alwaysRaised=yes, dependent=yes, directories=no, height=600, width=600, location=no, menubar=no, resizable=yes, screenX=40, screenY=70, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    u.focus();
    return true;
}

function ViewItemOAG(id, lang){
    var params = '';
    
    if (arguments.length == 2) {
        params = 'id=' + id + '&lang=' + lang;
    }
    else {
        return false;
    }
    
    u = window.open("./uvelem_oag.php?" + params, "coag_viewer", "alwaysRaised=yes, dependent=yes, directories=no, height=600, width=600, location=no, menubar=no, resizable=yes, screenX=40, screenY=70, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    u.focus();
    return true;
}

//fereastra de vizualizare history - bun pentru user si pentru admin daca apelat cu user
function ViewHistory(user, entry){
    var params = '';
    
    if (arguments.length == 2) {
        params = 'u=' + user + '&e=' + entry;
    }
    else {
        return false;
    }
    
    window.open("./view_history.php?" + params, "history_viewer", "alwaysRaised=yes, dependent=yes, directories=no, height=500, width=700, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

//vizualizare instructiuni de plata
function ViewPayment(suma, moneda){
    var params = '';
    
    if (arguments.length == 2) {
        params = 'suma=' + suma + '&moneda=' + moneda;
    }
    else {
        return false;
    }
    
    window.open("./view_payment.php?" + params, "payment_viewer", "alwaysRaised=yes, dependent=yes, directories=no, height=500, width=700, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

//vizualizare, gestionare evenimente
function ViewEditEvent(event){
    var params = '';
    
    if (arguments.length == 1) {
        params = 'e=' + event;
    }
    else {
        return false;
    }
    
    window.open("./viewedit_event.php?" + params, "event_editview", "alwaysRaised=yes, dependent=yes, directories=no, height=500, width=700, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

//vizualizare, gestionare inregistrari - administrator
function ViewEditAdmEntry(entry, id_categ, n_categ, evid){
    var params = '';
    
    if (arguments.length == 4) {
        params = 'id=' + entry + '&id_categ=' + id_categ + '&n_categ=' + n_categ + '&evid=' + evid;
    }
    else {
        return false;
    }
    
    window.open("./aviewedit_entry.php?" + params, "entry_editview", "alwaysRaised=yes, dependent=yes, directories=no, height=550, width=690, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

//vizualizare gestionare platile unei intrari
function ViewEditPlati(entry){
    var params = '';
    
    if (arguments.length == 1) {
        params = 'en=' + entry;
    }
    else {
        return false;
    }
    
    window.open("./viewedit_plati.php?" + params, "plati_editview", "alwaysRaised=yes, dependent=yes, directories=no, height=500, width=700, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

//pop-up selectare categorie; parametru numeric, care dintre variante sa o aduca
function SelectCateg(varianta){
    if (arguments.length == 0) {
        window.open("./select_categ.php", "select_categ", "alwaysRaised=yes, dependent=yes, directories=no, height=700, width=500, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1		
    }
    else//cel putin un parametru, presupus corect, numeric
    {
        window.open("./select_categ" + varianta + ".php", "select_categ", "alwaysRaised=yes, dependent=yes, directories=no, height=300, width=400, location=no, menubar=no, resizable=yes, screenX=20, screenY=20, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    }
    return true;
}

function FlashMe(id_x){
    var df;
    var elem = document.getElementById(id_x);
    
    elem.style.backgroundColor = "#cc0000";
    //	df = new Date(new Date().getTime() + 1000);
    //	while (new Date() < df) {}
    
    //	for(i=0; i<10000; i++) 
    //	setTimeout('', 10000);
    
    return true;
}

//collapse/expand
function CollapseAllTD(){
    var rows = document.getElementById('tabel_categ').getElementsByTagName('td');
    
    for (i = 0; i < rows.length; i++) {
        if (rows[i].id.substr(0, 3) == 'fix') {
            rows[i].style.visibility = 'visible';
        }
        else {
            rows[i].style.visibility = 'collapse';
        }
    }
    return true;
}

function CollapseAllTR(){
    var rows = document.getElementById('tabel_categ').getElementsByTagName('tr');
    
    for (i = 0; i < rows.length; i++) {
        if (rows[i].id.substr(0, 3) == 'fix') {
            rows[i].style.visibility = 'visible';
        }
        else {
            rows[i].style.visibility = 'collapse';
        }
    }
    return true;
}

function ExpandTD(x){
    var cols = document.getElementById('tabel_categ').getElementsByTagName('td');
    CollapseAllTD();
    for (i = 0; i < cols.length; i++) {
        if (cols[i].id == x) {
            //				if (cols[i].style.visibility == 'collapse')
            cols[i].style.visibility = 'visible';
        }
        //				else
        //					cols[i].style.visibility = 'collapse';
    
    }
    return true;
}

function ExpandTR(x){
    var rows = document.getElementById('tabel_categ').getElementsByTagName('tr');
    CollapseAllTR();
    for (i = 0; i < rows.length; i++) {
        if (rows[i].id == x) {
            //				if (rows[i].style.visibility == 'collapse')
            rows[i].style.visibility = 'visible';
        }
        //				else
        //					rows[i].style.visibility = 'collapse';
    
    }
    //	ExpandTD(x);
    return true;
}

//expand/collapse general
function ExpandCollapseCategList(){
    var rows = document.getElementById('tabel_categ').getElementsByTagName('tr');
    var cols = document.getElementById('tabel_categ').getElementsByTagName('td');
    var stare = '';
    
    if (b === 0) {
        for (i = 0; i < rows.length; i++) {
            rows[i].style.visibility = 'visible';
        }
        for (i = 0; i < cols.length; i++) {
            cols[i].style.visibility = 'visible';
        }
    }
    else {
        CollapseAllTD();
        CollapseAllTR();
    }
    b = (b + 1) % 2;
    return true;
}

//transfera selectia in parinte
function Transfer(nc, id, x){
    //validare: nu las categorie radacina si in plus nici id zero, oriunde ar fi el.	
    if (nc == 0 || id == 0) {
        return false;
    }
    else {
        window.opener.document.forms[0].n_categ.value = nc;
        window.opener.document.forms[0].id_categ.value = id;
        window.opener.document.forms[0].nume_categ.value = x;
        
        return true;
    }
}

//aduce in fata traducerea x (sincron, declansat de onclick pe lang)
function FetchLang(x){//comutare intre mai multe limbi; necesar cel putin vector vlang, asociat campurilor lang
    var l = 0;
    var defined_nume = false;
    defined_continut = false;
    defined_titlu = false;
    defined_descriere = false;
    defined_keywords = false;
    defined_chk_arhiva = false;
    
    if (vlang) {
		l = vlang.length;
		j = document.forms[0].elements.length;
		//cu ce campuri in afara de lang mergem mei departe...	
		while (j-- > 0) {
			if (document.forms[0].elements[j].name == 'nume') {
				defined_nume = true;
			}
			if (document.forms[0].elements[j].name == 'continut') {
				defined_continut = true;
			}
			if (document.forms[0].elements[j].name == 'titlu') {
				defined_titlu = true;
			}
			if (document.forms[0].elements[j].name == 'descriere') {
				defined_descriere = true;
			}
			if (document.forms[0].elements[j].name == 'keywords') {
				defined_keywords = true;
			}
			if (document.forms[0].elements[j].name == 'chk_arhiva') {
				defined_chk_arhiva = true;
			}
		}
		
		for (i = 0; i < l; i++) {
			if (vlang[i] == document.forms[0].lang.value) {
				if (defined_nume) {
					vnume[i] = document.forms[0].nume.value;
				}
				if (defined_continut) {
					vcontinut[i] = document.forms[0].continut.value;
				}
				if (defined_titlu) {
					vtitlu[i] = document.forms[0].titlu.value;
				}
				if (defined_descriere) {
					vdescriere[i] = document.forms[0].descriere.value;
				}
				if (defined_keywords) {
					vkeywords[i] = document.forms[0].keywords.value;
				}
			}
		}
		document.forms[0].lang.value = vlang[x];
		if (defined_nume) {
			document.forms[0].nume.value = vnume[x];
		}
		if (defined_continut) {
			document.forms[0].continut.value = vcontinut[x];
		}
		if (defined_titlu) {
			document.forms[0].titlu.value = vtitlu[x];
		}
		if (defined_descriere) {
			document.forms[0].descriere.value = vdescriere[x];
		}
		if (defined_keywords) {
			document.forms[0].keywords.value = vkeywords[x];
		}
		//	tinyMCE.updateContent('keywords');
		tinyMCE.updateContent('continut');
		//	document.forms[0].keywords.focus(); tinyMCE.setContent(vkeywords[x]);
		
		
		if (l > (x + 1)) {
			document.forms[0].lang.readOnly = true;
		//		if(defined_chk_arhiva) document.forms[0].chk_arhiva.checked = true;
		}
		else {
			document.forms[0].lang.readOnly = false;
			if (defined_chk_arhiva) {
				document.forms[0].chk_arhiva.checked = false;
			}
		}
	}
    return true;
}

function TDKLang(){
    var l = 0;
    i = 0;
    done = false;
    
    l = vl.length;
    for (i = 0; i < l; i++) {
        if (vl[i] == document.forms[0].select_lang.options[document.forms[0].select_lang.selectedIndex].value) {
            document.forms[0].titlu.value = vt[i];
            document.forms[0].descriere.value = vd[i];
            document.forms[0].keywords.value = vk[i];
            done = true;
        }
    }
    if (!done) {
        document.forms[0].titlu.value = '';
        document.forms[0].descriere.value = '';
        document.forms[0].keywords.value = '';
        done = true;
    }
    //alert(document.forms[0].select_lang.options[document.forms[0].select_lang.selectedIndex].value);
    return true;
}

function isclick(enid, enurl){
    //modificata sa returneze intotdeauna true. motiv: deschis fereastra if returnat false - 
    var params = '';
    
    if (arguments.length == 2) {
        params = 'id=' + enid + '&url=' + enurl;
        window.open("./isclick_load.php?" + params, "isclick", "alwaysRaised=yes, dependent=yes, directories=no, height=570, width=780, location=yes, menubar=yes, resizable=yes, screenX=10, screenY=10, toolbar=yes, scrollbars=yes");//js 1.0, 1.1
        //	window.open("./isclick_load.php?"+params, "isclick", "alwaysRaised=yes, dependent=yes, height=550, width=750");//js 1.0, 1.1
    }
    //	else
    //	{ 	
    //		return false;
    //	}
    
    return true;
}

function isbroken(enid, enurl){
    var params = '';
    
    if (arguments.length == 2) {
        params = 'id=' + enid + '&url=' + enurl;
    }
    else {
        return false;
    }
    
    window.open("./broken_link.php?" + params, "isbroken", "alwaysRaised=yes, dependent=yes, directories=no, height=140, width=780, location=no, menubar=no, resizable=yes, screenX=10, screenY=10, toolbar=no, scrollbars=yes");//js 1.0, 1.1
    return true;
}

function isbookmark(url, title){
    //  alert(navigator.appName);
    //alert(url);
//     if (window.external)
//     {
//     window.external.AddFavorite(url,title);
//     }
//     else
//     {
//     alert("Sorry: could not automatically bookmark,\r\nPlease press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
//     }
    //sau...	
    if (window.sidebar) 
        window.sidebar.addPanel(title, url, "");//mozile si ff
    else 
        if (window.opera && window.print) {
            var elem = document.createElement('a');
            elem.setAttribute('href', url);
            elem.setAttribute('title', title);
            elem.setAttribute('rel', 'sidebar');
            elem.click();
        }
        else 
            if (document.all) 
                window.external.AddFavorite(url, title);//internet explorer - de verioficat pe 7
//     if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4))
//     window.external.AddFavorite(url,title);
//     else
//     if (navigator.appName == "Netscape")
//     {
//     window.sidebar.addPanel(title,url,"");
//     }
//     else
//     {
//     alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
//     }
    
}

//traducere de caractere, in special cele cu probleme
function htmlentities(s){
    //   	var s =new String;
    //	s = sir;
    if (s != '') {
        s = s.replace(/(')/g, "&#39;");
        s = s.replace(/(")/g, "&quot;");
        s = s.replace(/(<)/g, "&lt;");
        s = s.replace(/(>)/g, "&gt;");
    }
    return s;
}

//functia inversa lui htmlentities
function html_entity_decode(s){
    //    var s =new String;
    //	s = sir;
    if (s != '') {
        s = s.replace(/(&#39;)/g, "\'");
        s = s.replace(/(&quot;)/g, '\"');
        s = s.replace(/(&lt;)/g, "<");
        s = s.replace(/(&gt;)/g, ">");
    }
    return s;
}

//////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
//seria de functii quod validatem diferentiae per valor
//functia de stergere a alertelor din familia al
var tagalert = "SPAN";
function isRmAlert(al){
    var l = 0, i = 0, k = 0, e, ee, re;
    e = new Array();
    //    IE BUG: nu stie getElementsByName pentru dom introdusele.; ie8 va rezolva problema????
    re = /[\.]*MSIE[\.]*/;
    if (re.test(window.navigator.userAgent)) //window.navigator.userAgent contine MSIE
    {
        //	    ee = new Array();
        ee = document.getElementsByTagName(tagalert);
        k = ee.length;
        for (i = 0; i < k; i++) {
            if (ee[i].getAttribute("name") == al) {
                e[l] = ee[i];
                l++;
            }
        }
        //aici am e si l; perhaps corecte; 
    }
    else //end IE BUG; normal:  
    {
        e = document.getElementsByName(al);
        l = e.length;
    }
    
    if (l > 0) {
        for (i = 0; i < l; i++) {
            //adica intotdeauna sa fie elementul urmat de elementul alerta if the case pt ca sa pot remove fundalul de eroare
            if (e[0].previousSibling) 
                e[0].previousSibling.removeAttribute("style");
            e[0].parentNode.removeChild(e[0]);
        }
    }
    return l;//cate erat si eliminat
}

//validare data
function isvalidd_core(z, l, a){
    var vz = new Array();
    vz[1] = 31;
    if ((a % 4) == 0) 
        vz[2] = 29;
    else 
        vz[2] = 28;
    vz[3] = 31;
    vz[4] = 30;
    vz[5] = 31;
    vz[6] = 30;
    vz[7] = 31;
    vz[8] = 31;
    vz[9] = 30;
    vz[10] = 31;
    vz[11] = 30;
    vz[12] = 31;
    
    if (a < 1000 || a > 9999) 
        return false;
    if (l < 1 || l > 12) 
        return false;
    if (z < 1 || z > vz[l]) 
        return false;
    return true;
}

//especial pentru select: mesaj, retur 0 in cazul in care optiunea selectata e chiar cea nevalid
function isValidSel(msg, nevalid){
    var r = 1;
    var l, i, e, c;
    //1. elimin nodurile din grupa....
    isRmAlert("isgrpSelvalidare");
    //2. validarea dupa controalele date - dar against aceeasi valoare de nevalid; 
    l = arguments.length;
    //argumentul 0 e mesaj, 1 e valoarea de nevalid pt care testez
    for (i = 2; i < l; i++) {
        //		alert(arguments[i].id);
        //      e = document.getElementById(arguments[i].id);
        e = arguments[i];//transmis chiar elementul - de vazut if merge pe ie
        if (e.options[e.selectedIndex].value == nevalid) {
            //e.setAttribute("style", "background-color: #ffd0d0;");//nesuportat de insuportabilul msie; asadar:
            e.style.background = "#ffd0d0";
            c = document.createElement(tagalert);
            //c.setAttribute("class", "alerta");//nesuportat de insuportabilul msie; asadar:
            c.className = "alerta";
            c.setAttribute("name", "isgrpSelvalidare");
            c.appendChild(document.createTextNode(msg));//mesajul
            //sibling deci la elementul eronat plasez alerta
            e.parentNode.appendChild(c);
            //			return 0;//prima eroare -iese afara; altfel cata aller erorile, le marcheaza and gata
            r *= 0;
        }
        else 
            r *= 1;
    }
    return r
}

//validare X, non empty: 1 sau 0+msg
function isValidX(msg){
    var r = 1;
    //    var s, e, c, l, i;
    //1. elimin nodurile din grupa....
    isRmAlert("isgrpXvalidare");
    //2. validarea dupa toate argumentele	
    l = arguments.length;
    //argumentul 0 e mesajul
    for (i = 1; i < l; i++) {
        e = arguments[i];
        //        e = document.getElementById(arguments[i].name);
        //        s = arguments[i].value;//select nu are value
        s = e.value;
        //if not ok - orice, mai putin spatieri
        if (s.replace(/\ /g, "") == "") {
            //caz de eroare, afisez alerta
            //            e = document.getElementById(arguments[i].name);
            //            if (e.nodeName == "INPUT") {
            //e.setAttribute("style", "background-color: #ffd0d0;");//nesuportat de insuportabilul msie; asadar:
            e.style.background = "#ffd0d0";
            //            }
            //pregatesc elementul/textul relatie tata fiu: span cu clasa si text. elegant.
            c = document.createElement(tagalert);
            //c.setAttribute("class", "alerta");//nesuportat de insuportabilul msie; asadar:
            c.className = "alerta";
            c.setAttribute("name", "isgrpXvalidare");//asta merge si pe msie! nodeName e readonly - de aia oare?
            c.appendChild(document.createTextNode(msg));//mesajul
            //sibling deci la elementul eronat plasez alerta
            e.parentNode.appendChild(c);
            //			return 0;//prima eroare -iese afara; altfel cata aller erorile, le marcheaza and gata
            r *= 0;
        }
        else 
            r *= 1;
    }
    return r
}

//validare Telefon, fax, non empty
function isValidT(msg){
    var r = 1;
    var s, e, c, l, i;
    //1. elimin nodurile din grupa....
    isRmAlert("isgrpTvalidare");
    //2. validarea dupa toate argumentele	
    l = arguments.length;
    //argumentul 0 e mesajul
    for (i = 1; i < l; i++) {
        e = arguments[i];
        //        e = document.getElementById(arguments[i].id);
        s = arguments[i].value;//select nu are value
        if ((s == "") || (s.replace(/[\+]{0,1}[0-9]{2}[0-9\-\.\ ]*/, "") != "")) {
            //caz de eroare, afisez alerta
            //            e = document.getElementById(arguments[i].name);
            //            if (e.nodeName == "INPUT") {
            //e.setAttribute("style", "background-color: #ffd0d0;");//nesuportat de insuportabilul msie; asadar:
            e.style.background = "#ffd0d0";
            //            }
            //pregatesc elementul/textul relatie tata fiu: span cu clasa si text. elegant.
            c = document.createElement(tagalert);
            //c.setAttribute("class", "alerta");//nesuportat de insuportabilul msie; asadar:
            c.className = "alerta";
            c.setAttribute("name", "isgrpTvalidare");
            c.appendChild(document.createTextNode(msg));//mesajul
            //sibling deci la elementul eronat plasez alerta
            e.parentNode.appendChild(c);
            //			return 0;//prima eroare -iese afara; altfel cata aller erorile, le marcheaza and gata
            r *= 0;
        }
        else 
            r *= 1;
    }
    return r
}

//validare N, non empty; numar natural de vazut analog si pt float, etc
function isValidN(msg){
    var r = 1;
    var s, e, c, l, i;
    //1. elimin nodurile din grupa....
    isRmAlert("isgrpNvalidare");
    //2. validarea dupa toate argumentele	
    l = arguments.length;
    //argumentul 0 e mesajul
    for (i = 1; i < l; i++) {
        e = arguments[i];
        //        e = document.getElementById(arguments[i].id);
        s = arguments[i].value;//select nu are value
        //if not ok
        if ((s == "") || (s.replace(/[0-9]+/, "") != "")) {
            //caz de eroare, afisez alerta
            //e.setAttribute("style", "background-color: #ffd0d0;");//nesuportat de insuportabilul msie; asadar:
            e.style.background = "#ffd0d0";
            //            }
            //pregatesc elementul/textul relatie tata fiu: span cu clasa si text. elegant.
            c = document.createElement(tagalert);
            //c.setAttribute("class", "alerta");//nesuportat de insuportabilul msie; asadar:
            c.className = "alerta";
            c.setAttribute("name", "isgrpNvalidare");
            c.appendChild(document.createTextNode(msg));//mesajul
            //sibling deci la elementul eronat plasez alerta
            e.parentNode.appendChild(c);
            //			return 0;//prima eroare -iese afara; altfel cata aller erorile, le marcheaza and gata
            r *= 0;
        }
        else 
            r *= 1;
    }
    return r
}

//???validare pe numeric non zero (select)- util de ex la combo/selecturi, checkbox, radio, etc;
function isValidNZS(msg){
    var r = 1;
    var s, e, c, l, i;
    //1. elimin nodurile din grupa....
    isRmAlert("isgrpNZSvalidare");
    //2. validarea dupa toate argumentele	
    l = arguments.length;
    //argumentul 0 e mesajul
    for (i = 1; i < l; i++) {
        e = arguments[i];
        s = arguments[i].value;//select nu are value
        //if not ok
        if ((s == "") || (s.replace(/[0-9]+/, "") != "") || parseInt(s, 10) <= 0) {
            //caz de eroare, afisez alerta
            //e.setAttribute("style", "background-color: #ffd0d0;");//nesuportat de insuportabilul msie; asadar:
            e.style.background = "#ffd0d0";
            //            }
            //pregatesc elementul/textul relatie tata fiu: span cu clasa si text. elegant.
            c = document.createElement(tagalert);
            //c.setAttribute("class", "alerta");//nesuportat de insuportabilul msie; asadar:
            c.className = "alerta";
            c.setAttribute("name", "isgrpNZSvalidare");
            c.appendChild(document.createTextNode(msg));//mesajul
            //sibling deci la elementul eronat plasez alerta
            e.parentNode.appendChild(c);
            //			return 0;//prima eroare -iese afara; altfel cata aller erorile, le marcheaza and gata
            r *= 0;
        }
        else 
            r *= 1;
    }
    return r
}
//valid float
function isValidF(msg){
    var r = 1;
    var s, e, c, l, i;
    //1. elimin nodurile din grupa....
    isRmAlert("isgrpFvalidare");
    //2. validarea dupa toate argumentele	
    l = arguments.length;
    //argumentul 0 e mesajul
    for (i = 1; i < l; i++) {
        e = arguments[i];
        s = arguments[i].value;//select nu are value
        //if not ok
        if ((s == "") || (s.replace(/[0-9]+[\.]{0,1}[0-9]+/, "") != "") || parseFloat(s) <= 0) {
            //caz de eroare, afisez alerta
            //e.setAttribute("style", "background-color: #ffd0d0;");//nesuportat de insuportabilul msie; asadar:
            e.style.background = "#ffd0d0";
            //            }
            //pregatesc elementul/textul relatie tata fiu: span cu clasa si text. elegant.
            c = document.createElement(tagalert);
            //c.setAttribute("class", "alerta");//nesuportat de insuportabilul msie; asadar:
            c.className = "alerta";
            c.setAttribute("name", "isgrpFvalidare");
            c.appendChild(document.createTextNode(msg));//mesajul
            //sibling deci la elementul eronat plasez alerta
            e.parentNode.appendChild(c);
            //			return 0;//prima eroare -iese afara; altfel cata aller erorile, le marcheaza and gata
            r *= 0;
        }
        else 
            r *= 1;
    }
    return r
}

//validare A, non empty; alfabetic
function isValidA(msg){
    var r = 1;
    var s, e, c, l, i;
    //1. elimin nodurile din grupa....
    isRmAlert("isgrpAvalidare");
    //2. validarea dupa toate argumentele	
    l = arguments.length;
    //argumentul 0 e mesajul
    for (i = 1; i < l; i++) {
        e = arguments[i];
        s = arguments[i].value;//select nu are value
        //if not ok
        if ((s == "") || (s.replace(/[a-zA-Z_]{1}[a-zA-Z\-\(\)\!\?\/\ \{\}\:\;\,\%\&\*_\=]*/, "") != "")) {
            //caz de eroare, afisez alerta
            //e.setAttribute("style", "background-color: #ffd0d0;");//nesuportat de insuportabilul msie; asadar:
            e.style.background = "#ffd0d0";
            //            }
            //pregatesc elementul/textul relatie tata fiu: span cu clasa si text. elegant.
            c = document.createElement(tagalert);
            //c.setAttribute("class", "alerta");//nesuportat de insuportabilul msie; asadar:
            c.className = "alerta";
            c.setAttribute("name", "isgrpAvalidare");
            c.appendChild(document.createTextNode(msg));//mesajul
            //sibling deci la elementul eronat plasez alerta
            e.parentNode.appendChild(c);
            //			return 0;//prima eroare -iese afara; altfel cata aller erorile, le marcheaza and gata
            r *= 0;
        }
        else 
            r *= 1;
    }
    return r
}

//validare Email, non empty
function isValidE(msg){
    var r = 1;
    var s, e, c, l, i;
    //1. elimin nodurile din grupa....
    isRmAlert("isgrpEvalidare");
    //2. validarea dupa toate argumentele	
    l = arguments.length;
    //argumentul 0 e mesajul
    for (i = 1; i < l; i++) {
        e = arguments[i];
        s = arguments[i].value;//select nu are value
        //if not ok
        if ((s == "") || (s.replace(/[a-zA-Z0-9_][a-zA-Z0-9._-]*@[a-zA-Z0-9-.]+\.[a-zA-Z]{2,4}/, "") != "")) {
            //caz de eroare, afisez alerta
            //e.setAttribute("style", "background-color: #ffd0d0;");//nesuportat de insuportabilul msie; asadar:
            e.style.background = "#ffd0d0";
            //            }
            //pregatesc elementul/textul relatie tata fiu: span cu clasa si text. elegant.
            c = document.createElement(tagalert);
            //c.setAttribute("class", "alerta");//nesuportat de insuportabilul msie; asadar:
            c.className = "alerta";
            c.setAttribute("name", "isgrpEvalidare");
            c.appendChild(document.createTextNode(msg));//mesajul
            //sibling deci la elementul eronat plasez alerta
            e.parentNode.appendChild(c);
            //			return 0;//prima eroare -iese afara; altfel cata aller erorile, le marcheaza and gata
            r *= 0;
        }
        else 
            r *= 1;
    }
    return r
}

//validare data, not empty; parametri: lang si string formatul
function isValidD(msg, fmt){
    var r = 1;
    var s, e, c, l, i, re;
    //1. elimin nodurile din grupa....
    isRmAlert("isgrpDvalidare");
    //2. validarea dupa toate argumentele	
    l = arguments.length;
    //argumentul 0 e lang
    //argumentul 1 e formatul
    for (i = 2; i < l; i++) {
        e = arguments[i];
        s = arguments[i].value;
        err_param = false;
        if (fmt == "d/m/Y") //i.e. dd/mm/YYYY
        {
            re = /([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/;
            if (k = s.match(re)) {
                ziua = parseInt(k[1], 10);
                luna = parseInt(k[2], 10);
                anul = parseInt(k[3], 10);//k[0] e expresia insasi
            }
            else {
                err_param = true;
            }
        }
        else {
            //inainte de err true: verificari pt celelalte sabloane posibile, etc;
            err_param = true;
        }
        //aici avem zi luna an de verificat
        if (!err_param && (s != "") && isvalidd_core(ziua, luna, anul)) 
            r *= 1;//oarecumva inversat; explicatie: la sau face evaluare totala, la si progresiva; 
        else {
            //caz de eroare, afisez alerta
            //e.setAttribute("style", "background-color: #ffd0d0;");//nesuportat de insuportabilul msie; asadar:
            e.style.background = "#ffd0d0";
            //            }
            //pregatesc elementul/textul relatie tata fiu: span cu clasa si text. elegant.
            c = document.createElement(tagalert);
            //c.setAttribute("class", "alerta");//nesuportat de insuportabilul msie; asadar:
            c.className = "alerta";
            c.setAttribute("name", "isgrpDvalidare");
            c.appendChild(document.createTextNode(msg));//mesajul
            //sibling deci la elementul eronat plasez alerta
            e.parentNode.appendChild(c);
            //			return 0;//prima eroare -iese afara; altfel cata aller erorile, le marcheaza and gata
            r *= 0;
        }
    }
    return r
}

//a doua functie de validare data: aici validez o singura data, data ca si zi, luna, an si atasez alerta la elem precizat
//atentie: aici colorarea e la parinte nu la elem!!! iar elem e de fapt parentnode al unuia dintre controalele care compun data
//index e un numarator de controale, daca sunt mai multe la fel, sa se stie care e acela/textul apartinator lui
function isValidD2(msg, ziua, luna, anul, elem, index){
    var r = 1;
    
    //1. elimin nodurile din grupa....
    isRmAlert("isgrpD2validare" + index);
    //aici avem zi luna an de verificat
    if (isvalidd_core(ziua, luna, anul)) 
        r *= 1;
    else {
        //caz de eroare, afisez alerta
        //           elem.style.background = "#ffd0d0";
        //pregatesc elementul/textul relatie tata fiu: span cu clasa si text. elegant.
        c = document.createElement(tagalert);
        c.className = "alerta";
        c.setAttribute("name", "isgrpD2validare" + index);
        c.appendChild(document.createTextNode(msg));//mesajul
        //sibling undeva deci la elementul eronat plasez alerta
        elem.parentNode.appendChild(c);
        //			return 0;//prima eroare -iese afara; altfel cata aller erorile, le marcheaza and gata
        r *= 0;
    }
    return r
}


//--------------------------------------------------------------------------------------------

////xmlhttprequest- ajax:, ///////////////////////////////////////////////////////////////////////////////////////
var dest;
var request;
//functia ajax in care se intoarce raspunsul response
function sqlExecResponse(){
    if (request.readyState == 4) {
        if (request.status == 200) {
            response = request.responseText;
            //            alert(response);//it works - pe opera mai ales ajunge si aici
        }
        else {
            response = '';//error/ eventual seteaza ceva pe altceva - 1
        }
    }
    //	else alert(request.readyState);/// eventual seteaza ceva/careva element pe altceva - 2
}

//seteaza pe elementele nume_elem valoarea valoare; adica adauga pe child dupa ce l'a kilarit pe firstchild (if the case) 
function SetTextNume(nume_elem, text){
    var i, l, ve;
    
    ve = document.getElementsByName(nume_elem);
    l = ve.length;
    for (i = 0; i < l; i++) {
        if (ve[i].firstChild) 
            ve[i].removeChild(ve[i].firstChild);
        ve[i].appendChild(document.createTextNode(text));
    }
    return true;
    //diferenta principala dintre functia asta si SetText e ca asta merge pe nume nu pe id si asta e w3c compliant adica face cinstit append child, etc;
}

//functia seteaza un text pentru un element dom precizat
function SetText(id, text){
    var dest = document.getElementById(id);
    dest.innerHTML = text;
}

//functia ajax de invocare a unei executii la distanta
function sqlExec(qry, val){
    var url = 'isremotesql.php';
    var post_data = '';
    var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
    
    //datele care vor fi transmise. in acest caz post; daca se schimba modul, get;
    post_data = 'qry=' + encodeURIComponent(qry);//primul parametru
    for (var i = 1, ln_arg = arguments.length; i < ln_arg; i++) 
        post_data += '&val' + i + '=' + encodeURIComponent(arguments[i]);//restul parametrilor, un fel de indexare
    //ajax	cu post de data asta
    if (window.XMLHttpRequest) {
        request = new XMLHttpRequest();
        request.onreadystatechange = sqlExecResponse;
        request.open("POST", url, false);//parametrul 3 asyncron sau sincron: adica sa stea dupa el rezultatul sau ba
        request.setRequestHeader("Content-Type", contentType);
        request.send(post_data);
        //               alert(request.responseText);
        return request.responseText;
        //return true;
    }
    else 
        if (window.ActiveXObject) {
            request = new ActiveXObject("Microsoft.XMLHTTP");
            if (request) {
                request.onreadystatechange = sqlExecResponse;
                request.open("POST", url, false);
                request.setRequestHeader("Content-Type", contentType);
                request.send(post_data);
                return request.responseText;
            //return true;
            }
        }
    return false;
}

function processStateChange(){
    if (request.readyState == 4) {
        //		continut = getElementById(dest);
        if (request.status == 200) {
            response = request.responseText;
            voptiuni = response.split('!#!');
            dest.options[0] = new Option('select...', '0', false, false);
            for (i = 0; i < voptiuni.length; i++) {
                optiune = voptiuni[i].split(',');
                if (optiune[0].length > 0) {
                    dest.options[i + 1] = new Option(optiune[0], optiune[1], optiune[2], optiune[3]);
                }
            }
            dest.options[0].selected = true;
        }
        else {
            response = '';//error/ eventual seteaza combo pe altceva - 1
        }
    }
    //	else alert('sdfsdfsd');/// eventual seteaza combo pe altceva - 2
}

//url: cine se ocupa se aducerea datelor, parinte: cine contine element (de ex. document.form) elem - baza (id)numelui elementului,  
function isGetSubCateg(url, element, niv, nc){
    var l, k;
    var i, id;
    //	alert(elem+':'+niv+':'+nc);
    if (niv >= (nc - 1)) {
        return;
    }//end aici, ultimul nu mai are la ce sa raspunda.
    dest = document.getElementById(element + (niv + 1));//dest = dest_;
    source = document.getElementById(element + niv);
    //	alert(dest+','+source);
    k = source.length;
    if (source.selectedIndex == -1) {
        return false;
    }//de vazut cum incheiem diverse situatii
    for (i = 0; i < k; i++) {
        if (i == source.selectedIndex) {
            id = source.options[i].value;
            url = url + id;
        }
    }
    //	alert(url);
    //acum url are si id-ul categ selectate
    
    //erste: wir anulam das existente list	
    for (k = (niv + 1); k < nc; k++) {
        x = document.getElementById(element + k);
        l = x.length;
        for (i = 0; i < l; i++) {
            x.options[i].text = null;//optional, value conteaza
            x.options[i].value = null;
        }
        x.options.length = 0;//*
    }
    //anulat listele urmatoare listei in care se lucreaza
    //ajax	
    if (window.XMLHttpRequest) {
        request = new XMLHttpRequest();
        request.onreadystatechange = processStateChange;
        request.open("GET", url, true);
        request.send(null);
    }
    else 
        if (window.ActiveXObject) {
            request = new ActiveXObject("Microsoft.XMLHTTP");
            if (request) {
                request.onreadystatechange = processStateChange;
                request.open("GET", url, true);
                request.send();
            }
        }
    //then wir adaugam elementen an list	
    //	dest.length sa fie asadar 0; 

    //	l = 0;
    //	dest_.options[l] = new Option(url);
}

///////////////////////////////////////////////////////////////////////
function isHide(x){
    var a, b;
    if (a = document.getElementById(x)) {
        a.style.visibility = 'hidden';
        //	a.style.borderStyle = 'dotted';
        //	a.style.borderColor = 'black';
    }
    if (b = document.getElementById('l' + x)) {
        b.setAttribute('class', 'tab_inactiv');
        //	b.style.backgroundColor = 'transparent';
        b.style.borderStyle = 'dotted';
        b.style.borderColor = '#eeeeee';
        b.style.borderWidth = '0px';
        //	b.style.padding = '3px';
    }
}

function isShow(x){
    var a, b;
    if (a = document.getElementById(x)) {
        a.style.visibility = 'visible';
        a.style.borderStyle = 'solid';
        a.style.borderColor = '#dedede';
        a.style.borderWidth = '0px';
        //	a.style.padding = '7px';
    }
    if (b = document.getElementById('l' + x)) {
        //	b.style.backgroundColor = '#eeeeee';//vezi la foundtext probabil
        b.setAttribute('class', 'tab_activ');
        b.style.borderStyle = 'solid';
        b.style.borderColor = '#dedede';
        b.style.borderWidth = '0px';
        //	b.style.padding = '3px';
    }
}

//plus
function isshowtt(id_unde, msg){
    var elem = document.getElementById(id_unde);
    var i, l, x, y;
    
    y = document.getElementById('tt');
    if (y) {
    
    }
    else {
        y = document.createElement('div');
        elem.appendChild(y);
        
        y.id = 'tt';
        
        y.style.backgroundColor = '#dedede';
        y.style.borderStyle = 'dotted';
        y.style.borderColor = 'black';
        y.style.borderWidth = '1px';
        y.style.padding = '7px';
        y.style.position = 'absolute';
        
        y.style.left = y.offsetLeft + 100 + "px";
        y.style.top = y.offsetTop - 20 + "px";
        
    }
    
    y.style.visibility = 'visible';
    y.innerHTML = '<p>' + msg;//de ajustat acest innerhtml
    //	for(i=0; i<100; i++) 
    //	{
    setTimeout(isrmtt, 3000);
    clearTimeout();
    //	}
    ////	elem.removeChild(y);
    return true;//problema e ca trebuie intarziat acest return.
}

function isrmtt(){
    var y = document.getElementById('tt');
    /*	
     var now = new Date();
     var exitTime = now.getTime() + 1000;//numberMillis
     while (now.getTime() < exitTime)
     {
     now = new Date();
     }
     */
    //	for(i=0; i<10900; i++) 
    //	{
    //		setTimeout(null, 10900);
    //	}
    if (y) {
        y.style.visibility = 'hidden';
        y.parentNode.removeChild(y);
    }
    return true;
}

//////////////////////////////////////////
function ShowOne(n){
    var i, l;
    var obj, counter;
    
    obj = document.getElementsByTagName("div");
    counter = document.getElementsByTagName("input");
    l = obj.length;
    if (l > 0) {
        for (i = 0; i < l; i++) 
            obj[i].style.visibility = 'hidden';
        
        obj[n].style.visibility = 'visible';
        counter[n].value = (n + 1) + "/" + l;
    }
    else 
        counter[n].value = "---";
}

function ShiftLeft(){
    var i = 0, l = 0;
    var obj, counter;
    
    obj = document.getElementsByTagName("div");
    counter = document.getElementsByTagName("input");
    l = obj.length;
    if (l > 1) 
        for (i = 0; i < l; i++) 
            if (obj[i].style.visibility == "visible") {
                obj[i].style.visibility = 'hidden';
                obj[(i + l - 1) % l].style.visibility = "visible";
                counter[0].value = ((i + l - 1) % l + 1) + "/" + l;
                i = l;
            }
}

function ShiftRight(){
    var i = 0, l = 0;
    var obj, counter;
    
    obj = document.getElementsByTagName("div");
    counter = document.getElementsByTagName("input");
    l = obj.length;
    if (l > 1) 
        for (i = 0; i < l; i++) 
            if (obj[i].style.visibility == "visible") {
                obj[i++].style.visibility = 'hidden';
                obj[i % l].style.visibility = "visible";
                counter[0].value = (i % l + 1) + "/" + l;
                i = l;
            }
}

/////////////////////////////////////////////////////////////////////

//returneaza combo cu lista localitatilor din judetul judIndex
function PopulareLocalitati(pindex, tindex){
    var url = 'ispopulareloc.php';
    var post_data = '';
    var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
    
    //datele care vor fi transmise. in acest caz post; daca se schimba modul, get;
    post_data = 'pindex=' + encodeURIComponent(htmlentities(String(pindex)));//al doilea parametru, id sau sir dupa caz se va vedea in procedura
    if (tindex) 
        post_data += '&tindex=' + encodeURIComponent(htmlentities(String(tindex)));
    
    //ajax	cu post de data asta
    if (window.XMLHttpRequest) {
        request = new XMLHttpRequest();
        request.onreadystatechange = sqlExecResponse;
        request.open("POST", url, false);//parametrul 3 asyncron sau sincron: adica sa stea dupa el rezultatul sau ba
        request.setRequestHeader("Content-Type", contentType);
        request.send(post_data);
        //               alert(request.responseText);
        return request.responseText;
        //return true;
    }
    else 
        if (window.ActiveXObject) {
            request = new ActiveXObject("Microsoft.XMLHTTP");
            if (request) {
                request.onreadystatechange = sqlExecResponse;
                request.open("POST", url, false);
                request.setRequestHeader("Content-Type", contentType);
                request.send(post_data);
                return request.responseText;
            //return true;
            }
        }
    return false;
}

//returneaza combo cu lista localitatilor din judetul judIndex
function PopulareJudete(pindex, tindex){
    var url = 'ispopularejud.php';
    var post_data = '';
    var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
    
    //datele care vor fi transmise. in acest caz post; daca se schimba modul, get;
    post_data = 'pindex=' + encodeURIComponent(htmlentities(String(pindex)));//al doilea parametru, id sau sir dupa caz se va vedea in procedura
    if (tindex) 
        post_data += '&tindex=' + encodeURIComponent(htmlentities(String(tindex)));
    
    //ajax	cu post de data asta
    if (window.XMLHttpRequest) {
        request = new XMLHttpRequest();
        request.onreadystatechange = sqlExecResponse;
        request.open("POST", url, false);//parametrul 3 asyncron sau sincron: adica sa stea dupa el rezultatul sau ba
        request.setRequestHeader("Content-Type", contentType);
        request.send(post_data);
        //               alert(request.responseText);
        return request.responseText;
        //return true;
    }
    else 
        if (window.ActiveXObject) {
            request = new ActiveXObject("Microsoft.XMLHTTP");
            if (request) {
                request.onreadystatechange = sqlExecResponse;
                request.open("POST", url, false);
                request.setRequestHeader("Content-Type", contentType);
                request.send(post_data);
                return request.responseText;
            //return true;
            }
        }
    return false;
}

//returneaza combo cu lista regiunilor turistice din parent index adica tara probabil cu selectie pe t his index
function PopulareRegTur(pindex, tindex){
    var url = 'ispopulareregtur.php';
    var post_data = '';
    var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
    
    //datele care vor fi transmise. in acest caz post; daca se schimba modul, get;
    post_data = 'pindex=' + encodeURIComponent(htmlentities(String(pindex)));//al doilea parametru, id sau sir dupa caz se va vedea in procedura
    if (tindex) 
        post_data += '&tindex=' + encodeURIComponent(htmlentities(String(tindex)));
    
    //ajax	cu post de data asta
    if (window.XMLHttpRequest) {
        request = new XMLHttpRequest();
        request.onreadystatechange = sqlExecResponse;
        request.open("POST", url, false);//parametrul 3 asyncron sau sincron: adica sa stea dupa el rezultatul sau ba
        request.setRequestHeader("Content-Type", contentType);
        request.send(post_data);
        //               alert(request.responseText);
        return request.responseText;
        //return true;
    }
    else 
        if (window.ActiveXObject) {
            request = new ActiveXObject("Microsoft.XMLHTTP");
            if (request) {
                request.onreadystatechange = sqlExecResponse;
                request.open("POST", url, false);
                request.setRequestHeader("Content-Type", contentType);
                request.send(post_data);
                return request.responseText;
            //return true;
            }
        }
    return false;
}

//--------------------------------------------
//functia cauta primul nod cu numele tag printre fratii elementului elem si pe acesta il face ca stil activ sau inactiv
//utila de ex la desenarea ca inactive a etichetelor la checkboxuri inactive
function isDrawActiveInactive(tag, elem, aplica_clasa){
    var gasit = false;
    var i = 0;
    var bckup_elem = new Object;
    
    //intai in upstream
    bckup_elem = elem;
    while (!gasit && (labelfor = elem.previousSibling) && (i < 10)) {
        if (labelfor.nodeName.toUpperCase() == tag.toUpperCase()) {
            labelfor.className = aplica_clasa;
            gasit = true;
        }
        elem = labelfor;
        i++;
    }
    //apoi in downstream
    elem = bckup_elem;
    while ((gasit == false) && (labelfor = elem.nextSibling) && (i < 10)) {
        if (labelfor.nodeName.toUpperCase() == tag.toUpperCase()) {
            labelfor.className = aplica_clasa;
            gasit = true;
        }
        elem = labelfor;
        i++;
    }
    if (i >= 10) 
        alert('bai'); //in caz de prea departe, sau poate ceva aiureala...
    return gasit;
}

//afiseaza controalele din de tip tag grupul grup; acele controale au in alt -grup-
//de ex se cere afisarea divurilor (tag=div) din grupul fc(grup=fc) care au care proprietati(ex care=-11-12-34)
//in doc am ceva de genul <div name="fc-11-12-44">... <div name="fc-11-12-34">
function isShowGrup(tag, grup, care){
    var re_general = grup + '(\-.)*';//elementele din grupul grup
    var re_ = care;//atentie, pt multiple potriviri...aici vine unul singur si e inconjurat de la apel cu -care-
    var ve = document.getElementsByTagName(tag);
    var l, i;
    
    l = ve.length;
    for (i = 0; i < l; i++) 
        if (ve[i].id.match(re_general)) {
            if (ve[i].id.match(re_)) 
                ve[i].style.visibility = 'visible';
            else 
                ve[i].style.visibility = 'hidden';
        }
}

//varianta a doua: controalele afisate toate sunt dar cu stari de enable/disable; ca mai sus dar hidden=disable si visible=enabled
function isEnableGrup(tag, tip, grup, care){
    var re_general = grup + '(\-.)*';//elementele din grupul grup
    var re_ = care;//atentie, pt multiple potriviri...aici vine unul singur si e inconjurat de la apel cu -care-
    var ve = document.getElementsByTagName(tag);
    var l = 0, i = 0;
    
    l = ve.length;
    //	alert(l+'-'+tag);
    for (i = 0; i < l; i++) {
        if (ve[i].type == tip) {
            if (ve[i].id.match(re_general)) {
                if (ve[i].id.match(re_)) {
                    ve[i].disabled = false;
                    //removeAttribute("style");
                    isDrawActiveInactive('label', ve[i], 'label_activ')
                }
                else {
                    ve[i].disabled = true;
                    isDrawActiveInactive('label', ve[i], 'label_inactiv')
                }
            }
            
        }
        
    }
}

//pune atributul dat cu valoarea data la totii copiii nodului
function isResetChildrenAttrib(elem, atribut, valoare){
    var nc;
    if (nc = elem.firstChild) {
        nc.setAttribute(atribut, valoare);
        
        while (nc = nc.nextSibling) {
            nc.setAttribute(atribut, valoare);
        }
        return true;
    }
    return false;
}

//pune atributul dat cu valoarea data la totii copiii nodului
//adica numai width si heigth pentru ca functia de mai sus nu merge pe MSIE. sucks.
function isResetChildrenWidthHeightMSIE(elem, w, h){
    var nc;
    if (nc = elem.firstChild) {
        nc.style.width = w + 'px';
        nc.style.height = h + 'px';
        
        while (nc = nc.nextSibling) {
            nc.style.width = w + 'px';
            nc.style.height = h + 'px';
        }
        return true;
    }
    return false;
}

function isResetChildrenBorderMSIE(elem, tag){
    //    var nc = new Object();// sau fara lasand instantierea ad libitum 
    if (nc = elem.firstChild) {
        if (nc.nodeName == tag) 
            nc.style.cssText = 'border: none;';
        
        while (nc = nc.nextSibling) {
            if (nc.nodeName == tag) 
                nc.style.cssText = 'border: none;';
        }
        return true;
    }
    return false;
}

function isPoliglotTextarea(id_textarea, id_link){
    var e = document.getElementById(id_textarea);
    var le = document.getElementById(id_link);
    
    isResetChildrenWidthHeightMSIE(e.parentNode, 0, 0);//aduc la 0, 0 tot
    e.style.width = 'auto';
    e.style.height = 'auto';//restaurez doar pe cel curent;
    e.focus();
    
    isResetChildrenBorderMSIE(le.parentNode, 'A');
    le.style.cssText = 'border: solid; border-width: 1px; border-color: #0000ff;';
}

//bascula: ascunde/arata; schimba starea in negatul ei
function isShowHide(x){
    var a;
    if (a = document.getElementById(x)) {
        if (a.style.visibility != 'visible') {
            a.style.visibility = 'visible';
        }
        else {
            a.style.visibility = 'hidden';
        }
    }
}

//ascunde sau afiseaza un tr sau altceva care are id-ul x
function isShowCollapse(x){
    var a;
    if (a = document.getElementById(x)) {
        if (a.style.display == '')//this is futut sau eu nu-i pricep logica; collapse nu merge pe ie, nici display: table-row; merge insa none si ''.
        {
            //a.style.visibility = 'visible';
            a.style.display = 'none';
        }
        else {
            //a.style.visibility = 'collapse'; 
            a.style.display = '';
        }
    }
}
function ListaPersNwslttr()
{

	window.open("./alistapersnwslttr.php", "wnd_persnwslttr", "alwaysRaised=yes, dependent=yes, directories=no, height=650, width=800, location=no, menubar=no, resizable=yes, screenX=20, screenY=10, toolbar=no");//js 1.0, 1.1
	return true;
}