//functii javascript comune

//Arata/ascunde un element din pagina

function SH(id){

	if(id == false){

		alert("ati apelat functia SH fara a specifica un id valid");

		return

		}	

		

	if(document.getElementById(id).style.visibility == 'visible'){		

		//alert(document.getElementById(id).style.visibility);

		document.getElementById(id).style.visibility = 'hidden';

		return

		}

	if(document.getElementById(id).style.visibility == 'hidden'){

		document.getElementById(id).style.visibility = 'visible';		

		return

		}

}

//sterge fii unui element din document

function sterge(id){

	if(id){

		var elem = document.getElementById(id);

		for(var i = elem.childNodes.length-1; i>=0; i--){

			elem.removeChild(elem.childNodes[i]);

		}

	}

	else{

		alert("ati apelat functia sterge fara a specifica un id valid");

	}

}

function reincarca(locatie){

	window.location = locatie;	

	}

	var cerere;

	function schimba(layout){

		var divs = document.getElementsByTagName("a");	

		var h    = document.getElementsByTagName("h1");	
		
		var bord = document.getElementsByClassName("picleft");
			
		var len  = divs.length;
		
		var lenh = h.length;
		
		var lend = bord.length;

		if(layout == 'roz'){
			
			var lend =bord.length;
			for(var i=0;i<lend;i++)
			{
				thisBord=bord[i];
				if(thisBord.className=='picleft')
				{
					thisBord.style.borderColor=	'#761b3e';				
				}
			}		
			
			for (var i = 0; i < lenh; i++)

			{
				thisH = h[i];
				if (thisH.className == 'sdbtitle'  || thisH.className == '' || thisH.className == 'logintable')
				{
					thisH.style.color='#761b3e';
				}				
			}
			
			for (var i = 0; i < len; i++)
			{
				thisDiv = divs[i];
				if (thisDiv.className == 'buttonMiddle' || thisDiv.className == '' || thisDiv.className == 'sdbmiddle')
					thisDiv.style.color='#761b3e';
				else if(thisDiv.id=='footer_btn' && thisDiv.className=='footer_btn')
					;
			}
			
			for(var i=0;i<2;i++)
			{
			if(document.getElementById('sdbmiddle').className=="sdbmiddle" || document.getElementById('sdbmiddle').className=="sdbmiddleverde")
				document.getElementById('sdbmiddle').className="sdbmiddleroz";
			}

			document.body.style.backgroundImage = "url(/images/gradient2.gif)";

			document.getElementById('logo').style.background = "url(/images/logo2.gif)";
			
			document.getElementById('logo').style.backgroundPosition="0px 4px";

			document.getElementById('sdbup').style.borderBottomColor = "#761b3e";

			document.body.style.backgroundColor="#de70eb";	

			document.getElementById('all_continut').style.backgroundImage="url(/images/flower2.gif)";
			
			document.getElementById('btnroz').className='btnroz1';
			
			document.getElementById('btnverde').className='btnverde1';
			
			document.getElementById('register_btn').style.backgroundImage = "url(/../newimages/inregistrareRoz.gif)";
			
			document.getElementById('cauta_pic').style.backgroundImage="url(/../newimages/cautaRoz.gif)";
			
		if(document.getElementById('inregistreaza_btn'))
			document.getElementById('inregistreaza_btn').style.backgroundImage="url(/../newimages/inregistreazaRoz.gif)";
		}
		else if(layout == 'verde'){
		
		if(document.getElementById('inregistreaza_btn'))
			document.getElementById('inregistreaza_btn').style.backgroundImage="url(/../newimages/inregistreazaVerde.gif)";
			document.getElementById('cauta_pic').style.backgroundImage="url(/../newimages/cauta.gif)";
			
			document.getElementById('register_btn').style.backgroundImage = "url(/../newimages/inregistrareVerde.gif)";
			
			document.getElementById('btnroz').className='btnroz2';
			
			document.getElementById('btnverde').className='btnverde2';
			
			document.body.style.backgroundImage = "url(/images/gradient1.gif)";

			document.getElementById('logo').style.background = "url(/images/logo1.gif)";
			
			document.getElementById('logo').style.backgroundPosition="0px 4px";

			document.getElementById('all_continut').style.backgroundImage = "url(/images/flower1.gif)";

			document.getElementById('sdbup').style.borderBottomColor = "#25791b";

			document.body.style.backgroundColor="#d6ec70";

			for(var i=0;i<2;i++)
			{
			if(document.getElementById('sdbmiddle').className=="sdbmiddle" || document.getElementById('sdbmiddle').className=="sdbmiddleroz")
				document.getElementById('sdbmiddle').className="sdbmiddleverde";
			}
			
			var lend =bord.length;
			for(var i=0;i<lend;i++)
			{
				thisBord=bord[i];
				if(thisBord.className=='picleft')
					thisBord.style.borderColor=	'#25791b';				
			}

			for (var i = 0; i < len; i++)
			{
				thisDiv = divs[i];
				if (thisDiv.className == 'buttonMiddle' || thisDiv.className == '' || thisDiv.className == 'sdbmiddle')
					thisDiv.style.color='#25791b';
				else if(thisDiv.id=='footer_btn')
					{;}	
			}
			for (var i = 0; i < lenh; i++)
			{
				thisH = h[i];
				if (thisH.className == 'sdbtitle'  || thisH.className == '' || thisH.className == 'sdbmiddleroz' || thisH.className == 'logintable')
				{
					thisH.style.color='#25791b';
				}				
			}			
		}
		url = "/schimbaLayout/schimba.php?layout="+layout;

		incarcaURL(url, "schimbaLayout");
	}

//schimba layoutul home-ului

function schimbaHome(layout){

		var a = document.getElementsByTagName("a");			
		var b = document.getElementsByTagName("div");		
		var len  = a.length;	
		var lenb  = b.length;	
		if(layout == 'roz'){
			
			document.body.style.backgroundImage = "url(/images/gradient2.gif)";

			document.body.style.backgroundColor="#ea9ff2";

			document.getElementById('menu').style.background = "url(/images/xbeauty2.gif)";

			document.getElementById('ftleft').style.background = "url(/images/downleftH2.gif)";	

			document.getElementById('ftright').style.background = "url(/images/downrightH2.gif)";

			document.getElementById('subleft').style.background = "url(/images/subleft2.gif)";

			document.getElementById('subright').style.background = "url(/images/subright2.gif)";

			document.getElementById('logo').style.background = "url(/images/logo2.gif)";

			document.getElementById('submiddle').style.background = "url(/images/submiddle2.gif)";

			document.getElementById('btnroz').className='btnroz1';

			document.getElementById('btnverde').className='btnverde1';
			
			document.getElementById('submiddle').className = "submiddle";
			
			for(j=0;j<5;j++)
			{
			if(document.getElementById('buttons2'))
				if(document.getElementById('buttons2').className=="buttons2")
					document.getElementById('buttons2').id="buttons1";
			if(document.getElementById('buttons3'))
				document.getElementById('buttons3').id="buttons1";
			}
		}

		else if(layout == 'verde'){
		
			for(j=0;j<5;j++)
			{
			if(document.getElementById('buttons2'))
				if(document.getElementById('buttons2').className=="buttons2")
					document.getElementById('buttons2').id="buttons3";
			if(document.getElementById('buttons1'))
				document.getElementById('buttons1').id="buttons3";
			}

			document.body.style.backgroundImage = "url(/images/gradient1.gif)";

			document.body.style.backgroundColor="#d6ec70";

			document.getElementById('menu').style.background = "url(/images/xbeauty1.gif)";

			document.getElementById('ftleft').style.background = "url(/images/downleftH1.gif)";	

			document.getElementById('ftright').style.background = "url(/images/downrightH1.gif)";

			document.getElementById('subleft').style.background = "url(/images/subleft1.gif)";

			document.getElementById('subright').style.background = "url(/images/subright1.gif)";	

			document.getElementById('logo').style.background = "url(/images/logo1.gif)";

			document.getElementById('submiddle').style.background = "url(/images/submiddle1.gif)";

			document.getElementById('btnroz').className='btnroz2';

			document.getElementById('btnverde').className='btnverde2';
			
			document.getElementById('submiddle').className = "submiddle";


					

		}

		url = "/schimbaLayout/schimba.php?layout="+layout;

		incarcaURL(url, "schimbaLayout");

	}

//incarca URL-ul care raspunde pentru cerere

function incarcaURL(url, fct){

	if(window.XMLHttpRequest){

		cerere = new XMLHttpRequest();

		cerere.onreadystatechange = eval(fct);

		cerere.open("GET", url, true);

		cerere.send(null);

	}

	else if(window.ActiveXObject)

	{

		cerere = new ActiveXObject("Msxm12.XMLHTTP");

		if(cerere){

			cerere.onreadystatechange = eval(fct);

			cerere.open("GET", url, true);

			cerere.send();

		}

	}



}

function schimbaLayout(){

	if(cerere.readyState == 4){		

		if(cerere.status == 200){			

					

		}

		else{

			alert("A aparut o problema la transferul datelor:\n" + cerere.statusText);

		}	

	}

}
//=====================================================menu logare========================================
var i=1;
var c=0;
var intHide;
var heigh=9;
function show_hide_menu()
{
if (c==0)
	{
	intShow=setInterval("show()",100);
	c=1;
	}
else
	{
	intHide=setInterval("hide()",100);
	c=0;
	}
}
function show()
{
	height = parseFloat(document.getElementById("loginform").style.height);
	height = height+22;
	document.getElementById("loginform").style.height = height+'px';	
       if(height>=120){
		clearInterval(intShow);
		document.getElementById("loginform").style.height = 120+'px';
	}
	document.getElementById("sageata").src="/images/arrowt.gif"
}
function hide()
{
	height = parseFloat(document.getElementById("loginform").style.height);
	height = height-22.2;
	document.getElementById("loginform").style.height = height+'px';	
       if(height<=9){
		clearInterval(intHide);
		document.getElementById("loginform").style.height = 9+'px';
	}
	document.getElementById("sageata").src="/images/arrow.gif"
}
//===========================================================================================================