/* begin Page */

/* Created by Artisteer v3.0.0.33215 */



function scrollToTop(id)

{

//document.getElementById(id).scrollTop = strPos; //Enter your desired Position

document.getElementById(id).scrollTop = 0; //It scrolls to top

}




function arata_profil()
{
	document.getElementById('informatii_profil').className = "";
	document.getElementById('arata_profil').href = "javascript:ascunde_profil()";
	document.getElementById('arata_profil').innerHTML = "ASCUNDE PROFILUL &raquo;";
}

function ascunde_profil()
{
	document.getElementById('informatii_profil').className = "informatii_profil";
	document.getElementById('arata_profil').href = "javascript:arata_profil()";
	document.getElementById('arata_profil').innerHTML = "ARATA TOT PROFILUL &raquo;";
}

function action_cautare_admin()
{
    var actiune = document.form_cautare.action;
	var cuvant_cautat = document.getElementById('cuvantcautat').value ;
	cuvant_cautat = cuvant_cautat.replace( "_", " ");
	document.form_cautare.action = actiune ;	
}


function arata_profil_useri(id_useri)
{
	document.getElementById('profil').className = "profil_useri_invisible";
	document.getElementById('informatii').className = "profil_useri_invisible";
	document.getElementById('fotografii').className = "profil_useri_invisible";
	document.getElementById('prieteni').className = "profil_useri_invisible";
	document.getElementById(id_useri).className = "profil_useri_visible";
	
}

function sterge_cat_mesaj(id)
{
	var child = document.getElementById(id);
    var parent = document.getElementById('categorii');
	
    parent.removeChild(child);	
}

function add_cat_mesaj_old()
{
	numar_cat = document.getElementById('numar_cat').value;
	numar_cat = parseInt(numar_cat) + 1;
	document.getElementById('numar_cat').value = numar_cat;
	newdiv = document.createElement('div');
	sterge = "<br /><a href=\"javascript:sterge_cat_mesaj('cats" + numar_cat + "')\">STERGE</a>";
  	newdiv.setAttribute('id','cats' + numar_cat);
   	newdiv.innerHTML = "<hr />" + document.getElementById('cats').innerHTML;
   	document.getElementById("categorii").appendChild(newdiv);
}

function add_cat_mesaj()
{
	numar_cat = document.getElementById('numar_cat').value;
	numar_cat = parseInt(numar_cat) + 1;
	document.getElementById('numar_cat').value = numar_cat;
	
	sterge = "<br /><a href=\"javascript:sterge_cat_mesaj('cats" + numar_cat + "')\">STERGE</a><hr />";
	old_cats= document.getElementById('cats').innerHTML ;
	new_cats= old_cats + sterge;
	
	document.getElementById('cats').innerHTML = new_cats;

	var div_node = document.getElementById('cats');
    div_node.id =  'cats' + numar_cat;

	newdiv = document.createElement('div');
  	newdiv.setAttribute('id','cats');
   	newdiv.innerHTML = old_cats;
   	document.getElementById("categorii").appendChild(newdiv);
}

function schimba_subcategorii(id,subcategorii,categorie)
{
	subcat = "";
	for (key in subcategorii[categorie])
	{
	subcat = subcat + '<option value ="' + subcategorii[categorie][key] + '" >' + subcategorii[categorie][key]  + '</option>';
	}
	document.getElementById(id).innerHTML = subcat;
}
 
function add_mesaj(mesaj)
{
	document.getElementById('mesaj_adaugat').value = mesaj;
	document.forms["add_mesaj"].submit();
}

function schimba_orase(judet)
{

	document.getElementById(judet).className = "orase_profil";	
	document.getElementById(document.getElementById("judet_vechi").value).className = "orase_profil_inv" ;
	document.getElementById("judet_vechi").value = judet;
}
function schimba_orase_mod(judet)
{

	document.getElementById(judet).className = "orase_profil";	
	document.getElementById(document.getElementById("judet_vechi").value).className = "orase_profil_inv" ;
	document.getElementById("judet_vechi").value = judet;
}
function change_forum($tip)
{

	if ($tip == "categorie")
	{
			document.getElementById('cat').className = "invisible_form";
			document.getElementById('sub').className = "invisible_form";					
	}
	else
	if ($tip == "subiect")
	{
			document.getElementById('cat').className = "visible_form";
			document.getElementById('sub').className = "invisible_form";					
	}
	else
	{
			document.getElementById('cat').className = "visible_form";
			document.getElementById('sub').className = "visible_form";					
	}
}

function change_cat(link_cat)
{
	sel_txt = "<div class=\"nume_edit_fel\">Subiect</div>" ;
	sel_sus = "<select class=\"select_edit_fel\" name=\"subiect\" id=\"subiect\" >";
	sel_jos = "</select>";
	sel_nou = document.getElementById('cat_' + link_cat).innerHTML;
	document.getElementById('sub').innerHTML = sel_txt + sel_sus + sel_nou + sel_jos ;
}
function arata_foto(numar_foto)
{
	var i=0;

	for (i=1;i<parseInt(numar_foto)+1;i++)
	{
		
		id = 'prem_' + i ;		
			document.getElementById(id).className = "visible_form";
			
	}

	for (i=parseInt(numar_foto)+1;i<4;i++)
	{
	
		id = 'prem_' + i;
				id = 'prem_' + i ;
			document.getElementById(id ).className = "invisible_form";
			
	}	
}
function schimba_categ(tip)
{
	if (tip=='felicitari')
	{
		document.getElementById('allcategorii').className = "visible_form";
	}
	else
	{
		document.getElementById('allcategorii').className = "invisible_form";
	}

}

function arata_lista(i)
{
	id = 'lista_em'+i;
	for (j=1;j<6;j++)
	{
		if (j != i)
		{
			document.getElementById('lista_em'+j).innerHTML = "" ;
			document.getElementById('lista_em'+j).style.visibility='hidden';	
		}
	}
	lista = document.getElementById('lista_emailuri').innerHTML;
	lista = lista.replace(/VALORI_SALVATE/g,i);
	lista = lista.replace(/adresa/g,'adresa_dest');
	
	document.getElementById(id).innerHTML = lista ;
	document.getElementById(id).style.visibility='visible';	
}
	

	
function adauga_date(nr_des,nr_email)
{

	nume= document.getElementById('nume_salvat' + nr_email).value ;
	email =document.getElementById('email_salvat' + nr_email).value ;
	document.getElementById('des_nume' + nr_des).value = nume ;
	document.getElementById('des_email' + nr_des).value = email ;
	document.getElementById('lista_em'+nr_des).innerHTML = "" ;
	document.getElementById('lista_em'+nr_des).style.visibility='hidden';
}
	
function sterge_dest(nr_email)
{
	sterge_salvat(nr_email) ;
	$('#adresa' + nr_email).remove();
	$('#adresa_dest' + nr_email).remove();
	
}


function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(name, value, expires, path) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") 
}

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



function sterge_salvat(index)
{   
			
		cookieemail = getCookie('fel_email_dest');
		cookienume = getCookie('fel_nume_dest');
	
		emailuri  = cookieemail.split('&|');
		nume_c = cookienume.split('&|');

	    emailuri.splice (index-1,1);
		nume_c.splice(index-1,1);
		email = emailuri.join("&|");
		nume = nume_c.join("&|");		
		if (email == "")
		{
			deleteCookie('fel_email_dest','/');
			deleteCookie('fel_nume_dest','/');			
		}
		else
		{   
		    var dt = new Date(), expiryTime = dt.setTime( dt.getTime() + 86400 *14 );
			setCookie('fel_email_dest',email,dt,'/');
			setCookie('fel_nume_dest',nume,dt,'/');			
		}
      
}

