function arata(id_div, x, y)
{
	if(!x)
	{
		x = 0;
	}
	if(!y)
	{
		y = 0;
	}
	document.getElementById(id_div).style.display = 'block';
	var divName = id_div; // div that is to follow the mouse
                       // (must be position:absolute)
	var offX = 15 + x;          // X offset from mouse position
	var offY = -35 + y;          // Y offset from mouse position
	
	function mouseX(evt) {if (!evt) evt = window.event; if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return 0;}
	function mouseY(evt) {if (!evt) evt = window.event; if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return 0;}
	
	function follow(evt) {if (document.getElementById) {var obj = document.getElementById(divName).style; obj.visibility = 'visible';
	obj.left = (parseInt(mouseX(evt))+offX) + 'px';
	obj.top = (parseInt(mouseY(evt))+offY) + 'px';
}}
	document.onmousemove = follow;
}

function ascunde(id_div)
{
	document.getElementById(id_div).style.display = 'none';
}

function arata_simplu(id_div)
{
	document.getElementById(id_div).style.display = "block";
}

function ascunde_simplu(id_div)
{
	document.getElementById(id_div).style.display = "none";
}

function completeaza(id_img,nota)
{
	var imagine;
	if(nota < 7)
	{
		imagine = '1';
	}
	else if(nota >= 7 && nota < 9)
	{
		imagine = '2';
	}
	else
	{
		imagine = '3';
	}
	document.getElementById(id_img).src = '_templates/default/img/rate_' + imagine + '_big.gif';
}

function changeBackgroundUrl(id) 
{
	document.getElementById(id).style.backgroundColor = '#2b8cac';
}

function restoreBackground(bgUrl, id)
{
	document.getElementById(id).style.background = "url('_templates/default/img/" + bgUrl + "') no-repeat 2% 50%";
}

function showDetails(id, number, start)
{
	if(document.getElementById('plus' + id).style.display == 'none')
	{
		document.getElementById('a' + id).innerHTML = '&nbsp;-&nbsp;&nbsp;';
		for(j=start;j<=start-1+number;j++)
		{
			if(j != id)
			{
				Effect.BlindUp('plus' + j, {duration: 0.5});
				document.getElementById('a' + j).innerHTML = '&nbsp;+&nbsp;';
			}
			else
			{
				Effect.BlindDown('plus' + id,  {duration: 0.5});
			}
		}
	}
	else
	{
		document.getElementById('a' + id).innerHTML = '&nbsp;+&nbsp;';
		Effect.BlindUp('plus' + id,  {duration: 0.5});
	}
}

function changeForms(showForm, hideForm)
{
	document.getElementById(showForm).style.display = "block";
	document.getElementById(hideForm).style.display = "none";
	document.getElementById("a_" + hideForm).className += " r_down"
	document.getElementById("a_" + showForm).className = "a_intreaba";
}

function ask(type, valoareInitiala) 
{
	if(document.getElementById("text_" + type).className == "intreaba_text")
	{
		document.getElementById("text_" + type).className += " hover";
	}
	else
	{
		document.getElementById("text_" + type).className = "intreaba_text"
	}
	
	if(document.getElementById("text_" + type).value == valoareInitiala)
	{
		document.getElementById("text_" + type).value = "";
	}
	else if(document.getElementById("text_" + type).value == "")
	{
		document.getElementById("text_" + type).value = valoareInitiala;
	}
}

function arataColt(id, number)
{
	if(document.getElementById("colt" + id).style.display == "none")
	{
		new Effect.BlindDown(document.getElementById("colt" + id), {duration: 0.5});
		for(j=1;j<=number;j++)
		{
			if(j != id)
			{
				new Effect.BlindUp(document.getElementById("colt" + j, {duration: 0.5}));
			}
		}
	}
	else
	{
		new Effect.BlindUp(document.getElementById("colt" + id, {duration: 0.5}));
	}
}

function textareaCounter(messageId, counterId, maxChars)
{
    var myTextArea=document.getElementById(messageId);
    var myCounter=document.getElementById(counterId);
    if (myTextArea.value.length > maxChars) 
    {
    	myTextArea.value = myTextArea.value.substring(0, maxChars);
    }
    else myCounter.value = maxChars - myTextArea.value.length;
}

function checkEmail(str){
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
			if (filter.test(str)){	return true;	}else{		return false;	}
					}
		
function CheckFrm()
{
	if(this.document.CTf.titlu.value==''){alert("Trebuie sa completati un titlu!"); this.document.CTf.titlu.focus(); return false;}
	if(this.document.CTf.select_materia.value=='alege'){alert("Trebuie sa alegeti o materie!"); this.document.CTf.materia.focus(); return false;}
	if(this.document.CTf.select_materia.value=='propune')
	{
		if (this.document.CTf.materia.value.length<=3)
		{
			{alert("Trebuie sa completati o materie!"); this.document.CTf.materia.focus(); return false;}
		}
	}
	if(this.document.CTf.descriere.value=='' ){alert("Trebuie sa completati descrierea!"); this.document.CTf.descriere.focus(); return false;}
	if(this.document.CTf.descriere.value.length<300 ){alert("Descrierea trebuie sa contina cel putin 300 de caractere!"); this.document.CTf.descriere.focus(); return false;}
	if (this.document.CTf.id_materie.value=='0' ){	
		alert('Materia trebuie specificata!'); 	document.CTf.id_materie.focus();	return false; }
//		if(this.document.CTf.subiect.value==''){alert("Trebuie sa completati un subiect!"); this.document.CTf.subiect.focus(); return false;}
	if(this.document.CTf.upload.value=='') {alert("Trebuie sa selectati un fisier!"); this.document.CTf.upload.focus(); return false;}
//		else if(!instr(this.document.CTf.upload.value,'.doc')&&!instr(this.document.CTf.value,'.zip')&&!instr(this.document.CTf.value,'.pdf')&&!instr(this.document.CTf.value,'.txt')&&!instr(this.document.CTf.value,'.rar')&&!instr(this.document.CTf.value,'.ace')&&!instr(this.document.CTf.value,'.rtf'))
	else if((this.document.CTf.upload.value.indexOf('.doc')==-1)&&(this.document.CTf.upload.value.indexOf('.zip')==-1)&&(this.document.CTf.upload.value.indexOf('.pdf')==-1)&&(this.document.CTf.upload.value.indexOf('.txt')==-1)&&(this.document.CTf.upload.value.indexOf('.rar')==-1)&&(this.document.CTf.upload.value.indexOf('.ace')==-1)&&(this.document.CTf.upload.value.indexOf('.rtf')==-1))
	{
		alert("Fisierul propus nu respecta formatul acceptat. Formatele de fisiere acceptate sunt: doc, zip, pdf, txt, rtf, rar, ace.");
		this.document.CTf.upload.value='';
		this.document.CTf.upload.focus();
		return false;
	}
	

}

function checkSearch()
{
	if(this.document.cautare_referat.search.value.length < 3)
	{
		alert("Trebuie sa completati cel putin trei carecter in campul de cautare!"); 
		this.document.cautare_referat.search.focus(); 
		return false;
	}
}

function arata_ascunde(div_id)
{
	if(document.getElementById(div_id).style.display == 'none')
	{
		arata_simplu(div_id);
	}
	else
	{
		ascunde_simplu(div_id);
	}
}

function arataListe(id)
{
	if(document.getElementById("div_lista_mea_" + id).style.display == "none")
	{
		new Effect.BlindDown(document.getElementById("div_lista_mea_" + id), {duration: 0.5});
	}
	else
	{
		new Effect.BlindUp(document.getElementById("div_lista_mea_" + id, {duration: 0.5}));
	}
}

function slideUpDown(id)
{
	Effect.toggle(id ,'blind', {duration:0.8} ); 
}


function slideOpenEx(id, time)
{
	time = time == null ? 0.8 : time;
	if(!$(id).visible())
		Effect.toggle(id ,'blind', {duration:time} ); 
}

function slideCloseEx(id, time) {
	time = time == null ? 0.8 : time;
	if($(id).visible())
		Effect.toggle(id ,'blind', {duration:time} ); 
}

function adaugaReferat()
{
	if ($("adauga_referat").style.display == 'none' && $("cauta_referat").style.display == 'none')
	{
		Effect.toggle('adauga_referat','blind',{duration:0.8}); 
	}
	else if ($("adauga_referat").style.display == 'none')
	{
		$("cauta_referat").style.display = 'none';
		$("adauga_referat").style.display = 'block';
	}
	else
	{
		Effect.toggle('adauga_referat','blind',{duration:0.8}); 
	}
}

function cautaReferat()
{
	if ($("adauga_referat").style.display == 'none' && $("cauta_referat").style.display == 'none')
	{
		Effect.toggle('cauta_referat','blind',{duration:0.8}); 
	}
	else if ($("cauta_referat").style.display == 'none')
	{
		$("cauta_referat").style.display = 'block';
		$("adauga_referat").style.display = 'none';
	}
	else
	{
		Effect.toggle('cauta_referat','blind',{duration:0.8}); 
	}
}

function gotoJudet(id) {
	document.getElementById(judet).value = id;
	document.getElementById("cauta").click();
}

function changeLessons(id, number)
{
	if(document.getElementById('lectia' + id).style.display == 'none')
	{
		for(j=1;j<=number;j++)
		{
			if(j != id)
			{
				Effect.BlindUp('lectia' + j, {duration: 0.5});
			}
			else
			{
				Effect.BlindDown('lectia' + id,  {duration: 0.5});
			}
		}
	}
	else
	{
		Effect.BlindUp('lectia' + id,  {duration: 0.5});
	}
}

function changeFeeder(id, nr_id) {
	document.getElementById("feeder" + id).style.display = "block";
	document.getElementById("changer" + id).className = "categorii_feeder selected";
	for(i=1;i<=nr_id; i++)
	{
		if(i!=id)
		{
			document.getElementById("feeder" + i).style.display = "none";
			document.getElementById("changer" + i).className = "categorii_feeder";
		}
	}
}

var totalSlides = 0;
var slidesLeft;
var categorii;

function initCategorii()
{
	if($("categorii"))
	{
		categorii = document.getElementById("categorii").getElementsByTagName("li");
		if(categorii.length >= 11)
		{
			totalSlides = categorii.length - 11;
		}
		slidesLeft = totalSlides;
		for(i=0;i<categorii.length;i++)
		{
			if($("subcategorii" + i) && $("subcategorii" + i).style.display != "none")
			{
				var subcategorii = categorii[i].getElementsByTagName("b").length;
				slidesLeft += subcategorii;
				totalSlides += subcategorii;
			}
		}
		if($('up'))
		{
			$("up").hide();
			if(slidesLeft == 0)
			{
				$("down").hide();
			}
		}
		if($('press_scroll'))
		{
			$('press_scroll').onclick = moveScroller;
			$('categorii').style.top = "0px";
			$('categorii').onmousewheel = scrollWithWheel;
			if(window.addEventListener)
			{
				$('categorii').addEventListener('DOMMouseScroll', scrollWithWheel, false);
			}
		}
	}
}

function scrollWithWheel(evt)
{
	var direction = 0;
	if(!evt)
	{
		evt = window.event;
	}
	if(evt.wheelDelta)
	{
		direction = event.wheelDelta / 120;
	}
	else if(evt.detail)
	{
		direction = - evt.detail / 3;
	}
	
	if(direction)
	{
		if(direction < 0)
		{
			scrollUp();
		}
		else
		{
			scrollDown();
		}
	}
	
	if(evt.preventDefault)
	{
		evt.preventDefault();
	}
	evt.returnValue = false;
}

function locateScroll()
{
	$('scroll_position').style.bottom =  21 + 175 * (slidesLeft / totalSlides) + "px";
}

function scrollUp()
{
	if(slidesLeft > 0)
	{
		$('categorii').style.top = (parseInt($('categorii').style.top.replace('px', '')) - 21) + 'px';
		slidesLeft --;
		locateScroll();
	}
}

function scrollDown()
{
	if(slidesLeft < totalSlides)
	{
		$('categorii').style.top = (parseInt($('categorii').style.top.replace('px', '')) + 21) + 'px';
		slidesLeft ++;
		locateScroll();
	}
}

function moveUp()
{
	if(slidesLeft > 0)
	{
		new Effect.Move ($("categorii"),{ x: 0, y: -21, mode: 'relative', duration: 0.2});
		slidesLeft --;
		if(slidesLeft == 0)
		{
			$("down").hide();
			if(totalSlides != 0)
			{
				$("up").show();
			}
		}
		if(slidesLeft < totalSlides)
		{
			$("up").show();
		}
		locateScroll();
	}
}

function moveMoreUp(times)
{
	if(slidesLeft > 0)
	{
		if(slidesLeft > times - 1)
		{
			new Effect.Move ($("categorii"),{ x: 0, y: -21 * times, mode: 'relative', duration: 0.2});
			slidesLeft -= times;
		}
		else
		{
			new Effect.Move ($("categorii"),{ x: 0, y: -21 * slidesLeft, mode: 'relative', duration: 0.2});
			slidesLeft = 0;
		}
		locateScroll();
	}
}

function moveDown()
{
	if(slidesLeft < totalSlides)
	{
		new Effect.Move ($("categorii"),{ x: 0, y: 21, mode: 'relative', duration: 0.2});
		slidesLeft ++;
		if(slidesLeft < totalSlides)
		{
			$("down").show();
		}
		if(slidesLeft == totalSlides)
		{
			$("up").hide();
			if(slidesLeft != 0)
			{
				$("down").show();
			}
		}
		locateScroll();
	}
}

function moveMoreDown(times)
{
	if(slidesLeft < totalSlides)
	{
		if(slidesLeft < totalSlides - (times - 1))
		{
			new Effect.Move ($("categorii"),{ x: 0, y: 21 * times, mode: 'relative', duration: 0.2});
			slidesLeft += times;
		}
		else
		{
			new Effect.Move ($("categorii"),{ x: 0, y: 21 * (totalSlides - slidesLeft), mode: 'relative', duration: 0.2});
			slidesLeft = totalSlides;
		}
		locateScroll();
	}
}

function moveScroller(evt)
{
	if(!evt)
	{
		evt = window.event;
	}
	if(navigator.appName.indexOf("Microsoft") != -1)
	{
		evt.pageY = evt.clientY + (document.documentElement.scrollTop ?  document.documentElement.scrollTop : document.body.scrollTop);
	}
	if(evt.pageY > 300 && evt.pageY < 476)
	{
		var bottom = 496 - evt.pageY;
		$('scroll_position').style.bottom = bottom + "px";
		var diff = Math.floor(((231 - $('categorii').offsetHeight) * (1 - (bottom - 21) / 174)) / 21)
		$('categorii').style.top =  21 * diff + "px";
		slidesLeft = totalSlides + diff;
	}
}

function dragScroll()
{
	document.onmousemove = moveScroller;
	document.onmouseup = function()
	{
		document.onmousemove = null;
	}
}

function arataSubcategorii(id)
{
	var subcategorii = categorii[id].getElementsByTagName("b").length;
	Effect.toggle($("subcategorii" + id) ,'blind', {duration:0.5} );
	for(i=0;i<categorii.length;i++)
	{
		if(i != id)
		{
			if($("subcategorii" + i) && $("subcategorii" + i).style.display != "none")
			{
				var subcategoriiAltul = categorii[i].getElementsByTagName("a").length - 1;
				Effect.BlindUp($("subcategorii" + i), {duration: 0.5});
				totalSlides -= subcategoriiAltul;
				slidesLeft -= subcategoriiAltul;
				if(slidesLeft < 0)
				{
					slidesLeft = 0;
				}
			}
		}
	}
	if($("subcategorii" + id).style.display == "none")
	{
		slidesLeft += subcategorii;
		totalSlides += subcategorii;
	}
	else
	{
		new Effect.Move ($("categorii"),{ x: 0, y: 21 * (totalSlides - slidesLeft), mode: 'relative', duration: 0.2});
		totalSlides -= subcategorii;
		slidesLeft = totalSlides;
		if(slidesLeft < 0)
		{
			slidesLeft = 0;
		}
	}
	if(slidesLeft > 0 && slidesLeft < totalSlides)
	{
		$("down").show();
		$("up").show();
	}
	else if(slidesLeft == totalSlides && slidesLeft > 0)
	{
		$("up").hide();
		$("down").show();
	}
	else if(slidesLeft == 0)
	{
		$("down").hide();
		$("up").hide();
	}
	
	if(id == categorii.length - 1 && $("subcategorii" + id).style.display == "none")
	{
		for(i=0;i<subcategorii;i++)
		{
			moveUp();
		}
	}
}

addEvent(window,'load', initCategorii, false);

var carousel = function(id, divWidth, divsVisible)
{
	this.name = id; //id-ul
	this.divWidth = divWidth; //latimea unui item 
	this.divsVisible = divsVisible; //cate item-uri sunt vizibile
	this.theCarousel = $(id); //carouselul
	this.Elements = this.theCarousel.getElementsByTagName("div"); //item-urile
	this.numberOfElements = this.Elements.length; //numarul total de item-uri
	this.navLinks = new Array();
	this.navLinks[0] = this.theCarousel.parentNode.getElementsByTagName("b")[0].getElementsByTagName("a")[0]; //next
	this.navLinks[1] = this.theCarousel.parentNode.getElementsByTagName("b")[1].getElementsByTagName("a")[0]; //prev
	this.attachNavEvents(this, this.divsVisible * this.divWidth);
	this.totalParts = Math.ceil(this.numberOfElements / this.divsVisible);
	this.pointer = 1;
};

carousel.prototype = {
	showProperties: function()
	{
		var properties = "Numele: " + this.name + "\nLatimea unui item: " + this.divWidth + "px\nItem-uri vizibile: " + this.divsVisible + "\nNumarul de item-uri: " + this.numberOfElements;
		alert(properties);
	},
	
	attachNavEvents: function(carousel, distance)
	{
		this.navLinks[0].onclick = function()
		{
			moveNext(carousel, distance);
			return false;
		}
		
		this.navLinks[1].onclick = function()
		{
			movePrev(carousel, distance);
			return false;
		}
	}
}

function moveNext(carousel, distance)
{
	if(carousel.pointer < carousel.totalParts)
	{
		new Effect.Move (carousel.theCarousel,{ x: -distance * carousel.pointer, y: 0, mode: 'absolute'});
		carousel.pointer++;
		if(carousel.pointer == carousel.totalParts)
		{
			carousel.navLinks[0].style.display = "none";
		}
		if(carousel.pointer > 1)
		{
			carousel.navLinks[1].style.display = "block";
		}
	}
}

function movePrev(carousel, distance)
{
	if(carousel.pointer > 1)
	{
		new Effect.Move (carousel.theCarousel,{ x: -distance * (carousel.pointer - 2), y: 0, mode: 'absolute'});
		carousel.pointer--;
		if(carousel.pointer == 1)
		{
			carousel.navLinks[1].style.display = "none";
		}
		if(carousel.pointer < carousel.totalParts)
		{
			carousel.navLinks[0].style.display = "block";
		}
	}
}

addEvent(window, 'load', initCarousels, false);

function initCarousels()
{
	if($("servicii_homepage"))
	{
		carousel_1 = new carousel("servicii_homepage_div", 138, 7);
	}
	if($("pentru_elevi") && $("pentru_profesori") && $("pentru_parinti"))
	{
		carousel_1 = new carousel("pentru_elevi", 127, 5);
		carousel_2 = new carousel("pentru_profesori", 127, 5);
		carousel_3 = new carousel("pentru_parinti", 127, 5);
	}
	
	if($("ultimele_teste_trivia"))
	{
		carousel_4 = new carousel("teste", 127, 5);
	}
	
	if($("colturi_elevi") && $("colturi_profesori") && $("colturi_parinti"))
	{
		if (!$("colturi_catalog_prima") && !$("colturi_obiecte_cautare") && !$("colturi_obiecte_compara"))
		{
			carousel_6 = new carousel("colturi_elevi", 106, 3);
			carousel_7 = new carousel("colturi_profesori", 106, 3);
			carousel_8 = new carousel("colturi_parinti", 106, 3);
		}
		
		if($("colturi_preview"))
		{
			carousel_15 = new carousel("colturi_elevi", 106, 3);
			carousel_16 = new carousel("colturi_profesori", 106, 3	);
			carousel_17 = new carousel("colturi_parinti", 106, 3);
		}
		
		if($("colturi_catalog_prima"))
		{
			carousel_18 = new carousel("colturi_elevi", 106, 4);
			carousel_19 = new carousel("colturi_profesori", 106, 4);
			carousel_20 = new carousel("colturi_parinti", 106, 4);
		}
		
		if($("colturi_obiecte_cautare"))
		{
			carousel_24 = new carousel("colturi_elevi", 120, 2);
			carousel_25 = new carousel("colturi_profesori", 120, 2);
			carousel_26 = new carousel("colturi_parinti", 120, 2);
		}
		
		if($("colturi_obiecte_compara"))
		{
			carousel_27 = new carousel("colturi_elevi", 115, 2);
			carousel_28 = new carousel("colturi_profesori", 115, 2);
			carousel_29 = new carousel("colturi_parinti", 115, 2);
		}
	}
	
	if($("foto_catalog"))
	{
		carousel_30 = new carousel("foto_catalog", 127, 5);
	}
	
	if($("video_catalog"))
	{
		carousel_31 = new carousel("video_catalog", 127, 5);
	}
}

document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++)
	{
		var classes = elem[i].className;
		if (myclass.test(classes)) retnode.push(elem[i]);
	}
	return retnode;
};

function hideBucuresti()
{
	$("inspectorate_ilfov").style.display = "none";
}

function showInspectorate(id)
{
	if($("harta_inspectorate"))
	{
		var hideDiv;
		
		$("inspectorate_ilfov").onmouseover = function()
		{
			clearTimeout(hideDiv);
		}
		
		$("inspectorate_ilfov").onmouseout = function()
		{
			hideDiv = setTimeout(hideBucuresti, 500);
		}
	
		var areas = $("harta_inspectorate").getElementsByTagName("area");
		
		for(i=0;i<areas.length;i++)
		{
			if(areas[i].id != "more_links")
			{
				areas[i].onmouseover = function()
				{
					arata("titlu_inspectorat", -5, 20);
					$("titlu_inspectorat").innerHTML = this.title;
					$("inspectorate_ilfov").style.display = "none";
				}
				
				areas[i].onmouseout = function()
				{
					ascunde("titlu_inspectorat");
				}
			}
			else
			{
				areas[i].onmouseover = showBucuresti;
			}
		}
	}
}

function showBucuresti(evt, divName)
{
	var x, y;
	
	if (!evt)
	{
		evt = window.event;
	}
	if (evt.pageX)
	{
		x = evt.pageX;
	}
	else if (evt.clientX)
	{
		x = evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft);
	}

	if (evt.pageY)
	{
		y = evt.pageY; 
	}
	else if (evt.clientY)
	{
		y = evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	}
	
	$("inspectorate_ilfov").style.display = "block";
	$("inspectorate_ilfov").style.left = (x - 10) + "px";
	$("inspectorate_ilfov").style.top = (y - 10) + "px";
}

addEvent(window, 'load', showInspectorate, false);

function showArticleDescription(id)
{
	slideUpDown("description_" + id);
}

if(navigator.appName == "Netscape")
{
	window.onload = function()
	{
		if(document.getElementById("frame_2"))
		{
			document.getElementById("frame_2").style.display = "none";
		}
	}
}

var currentPicker;

function switchColorChangers(this_changer, all_changers)
{
	currentPicker = this_changer;
	for(i=1;i<=all_changers;i++)
	{
		if(i != this_changer)
		{
			$("color_changer" + i).hide();
		}
	}
	arata_ascunde("color_changer" + this_changer);
}

function returnHexColor(color)
{
	if(currentPicker == 2 || currentPicker == 3)
	{
		if($("culoare_1").value != color.substring(1, 7))
		{
			$("culoare_" + currentPicker).value = color.substring(1, 7);
			$("background_" + currentPicker).style.backgroundColor = color;
			$("color_changer" + currentPicker).hide();
		}
		else
		{
			alert('Culoarea este acceasi cu culoarea background-ului!');
		}
	}
	else
	{
		$("culoare_" + currentPicker).value = color.substring(1, 7);
		$("background_" + currentPicker).style.backgroundColor = color;
		$("color_changer" + currentPicker).hide();
	}
}

function renunta()
{
	$("color_changer"+currentPicker).hide();
}

function gotoPage(page)
{
	if(page=="maps")
	{
		top.location.href="http://www.calificativ.ro/harti-scoala/cauta-harta-scolii.html";
	}
}

function propuneMaterie()
{
	if($("select_materia").value == "propune")
	{
		$("materia").show();
		$("alege_materie").show();
		//$("select_materia").hide();
		$("select_materia").style.visibility = "hidden";
		$("select_materia").style.position = "absolute";
	}
}

function alegeMaterie()
{
	//$("select_materia").show();
	$("select_materia").style.visibility = "visible";
	$("select_materia").style.position = "static";
	$("materia").hide();
	$("alege_materie").hide();
	$("select_materia").value = "alege";
}

/**
* Functie pentru selectul din pagina de cautare header
* @author Texx
* @date 23.05.2008
*
**/
Event.observe(window,"load", function(){
	if($("sel_filtru") != undefined)
		Event.observe("sel_filtru", 'change', function(event){
			if(Event.element(event).value==0) return;
			qs=document.location.search.parseQuery();
//			qs.f !=undefined ? qs.f=null : qs.f=Event.element(event).value;
			
			if ( qs.f != undefined )
			{
				if ( qs.f ==  Event.element(event).value )
				{
					qs.f=null
				}
				else
				{
					qs.f = Event.element(event).value;
				}
			}
			else
			{
					qs.f = Event.element(event).value;
			}
			
			url=document.location.protocol+'//'+document.location.hostname+document.location.pathname+'?'+$H(qs).toQueryString()
			console.log(url);
			document.location.href=url
			})	
	
}  )

var scrolling = 0;
var scrolls = new Array();
var totalScroll =0;

function initScrolls()
{
	for(i=1;i<=12;i++)
	{
		if($("th_" + i))
		{
			scrolls[i - 1] = $("th_" + i).getWidth();
		}
	}
	
	if($("please_wait"))
	{
		$("please_wait").hide();
	}
}

function scrollTable(direction)
{
	if(direction == 1)
	{
		if(totalScroll < $("tabel_scroll").getWidth() - 710)
		{
			totalScroll += scrolls[scrolling];
			if(totalScroll < $("tabel_scroll").getWidth() - 710)
			{
				new Effect.Move ($("tabel_scroll"),{ x: -totalScroll, y: 0, mode: 'absolute', duration: 0.1});
			}
			else
			{
				new Effect.Move ($("tabel_scroll"),{ x: -($("tabel_scroll").getWidth() - 710	), y: 0, mode: 'absolute', duration: 0.1});
			}
			scrolling ++;
		}
	}
	
	if(direction == -1)
	{
		if(scrolling > 0)
		{
			totalScroll -= scrolls[scrolling - 1];
			new Effect.Move ($("tabel_scroll"),{ x: -totalScroll, y: 0, mode: 'absolute', duration: 0.1});
			scrolling --;
		}
	}
}

function getPos(obj) 
{
	var leftOff = topOff = 0;
	if (obj.offsetParent) 
	{
		do 
		{
			leftOff += obj.offsetLeft;
			topOff += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return {leftOff : leftOff, topOff : topOff};
}

var defaultTop ;

function getTop()
{
	if(typeof window.pageYOffset != "undefined")
	{
		return window.pageYOffset;
	}
	else
	{
		 if(document.documentElement && document.documentElement.scrollTop)
		 {
		 	if(document.documentElement.scrollTop)
		 	{
		 		return document.documentElement.scrollTop;
		 	}
		 	else
		 	{
		 		return document.body.scrollTop;
		 	}
		 }
		 else
		 {
		 	return 0;
		 }
	}
}

function fixLinks()
{
	$("scrollLeft").style.top = getTop() + "px";
	$("scrollRight").style.top = getTop() + "px";
}

function editHintContent(text)
{
	$("hint").innerHTML = text;
}

addEvent(window, "load", initScrolls, false);

var flash_heights = new Array();

function setHeight(x)
{
	flash_heights[flash_heights.length] = x;
	var i  = flash_heights.length - 1;
	$("flash_" + i).style.height = (90 + 40 * flash_heights[i]) + "px";
}

function gotoConcurs()
{
	top.location = $("link_concurs").href;
}

function gotoLetter(letter)
{
	if($("anc_" + letter))
	{
		top.location = "#" + letter;
	}
	else
	{
		alert("Nu exista nimic cu aceasta litera!");
	}
}

var s_index = 1;
var switch_s;
var in_out = 1;

function initS()
{
	if($("s_1"))
	{
		s_index = Math.floor(Math.random()*6) + 1;
		
		gotoS(s_index);
		
		for(i=1;i<=7;i++)
		{	
			$("sd_" + i).onmouseover = function()
			{
				in_out = 0;
			}
			
			$("sd_" + i).onmouseout = function()
			{
				in_out = 1;
			}
			
			$("s_" + i).onmouseover = function()
			{
				in_out = 0;
				$("s_info").style.background = this.getElementsByTagName("b")[0].style.background;
				$("s_info").innerHTML = this.title;
				arata("s_info", 0, 50);
			}
			
			$("s_" + i).onmouseout = function()
			{
				in_out = 1;
				ascunde("s_info");
			}
			
			$("s_" + i).onclick = function()
			{
				s_index = this.id.substr(2);
				gotoS(this.id.substr(2));
				return false;
			}
		}
		
		//switch_s = setInterval(switchS, 4000);
	}
}

function gotoS(id)
{
	for(i=1;i<=7;i++)
	{
		if(i != id)
		{
			$("sd_" + i).style.display = "none";
			$("s_" + i).getElementsByTagName("b")[0].style.margin = "3px 8px";
			$("s_" + i).getElementsByTagName("b")[0].style.border = "1px solid #000";
		}
		else
		{
			$("s_" + i).getElementsByTagName("b")[0].style.margin = "0 5px";
			$("s_" + i).getElementsByTagName("b")[0].style.border = "4px solid #fff";
			$("sd_" + i).style.display = "block";
		}
	}
}

function switchS()
{
	if(in_out == 1)
	{
		if(s_index < 7)
		{
			s_index++;
		}
		else
		{
			s_index = 1;
		}
		gotoS(s_index);
	}
}

addEvent(window, "load", initS, false);

function changeSubS(main, sub, nrS)
{
	for(i=1;i<=nrS;i++)
	{
		if(i != sub)
		{
			$("sub_s_" + main + "_" + i).style.display = "none";
			$("s_tab_" + main + "_" + i).className = "s_tab";
		}
		else
		{
			$("sub_s_" + main + "_" + sub).style.display = "block";
			$("s_tab_" + main + "_" + sub).className = "s_tab s_tab_selected";
		}
	}
}

// flash vrajitoare

var over_halloween = 0;
var outside;
var time_out;

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

function getMousePosition()
{
	function mouseY(evt) {if (!evt) evt = window.event; if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return 0;}
	
	function follow(evt)
	{
		if(mouseY(evt) > 230)
		{
			outside = 1;
		}
		else
		{
			outside = 0;
		}
	}
	document.onmousemove = follow;
	$('calificativ_middle').onmouseover = showHalloweenBanner;
	$('calificativ_top').onmouseover = hideHalloweenBanner;
}

function showHalloweenBanner()
{
	if(over_halloween == 0 && outside == 1)
	{
		over_halloween = 1;
		time_out = setTimeout(showWitch, 500);
	}
}

function showWitch()
{
	$('hidden_witch').hideWitch();
	$('halloween').style.top = '-205px';
	$('witch').resetMovie();
}

function hideHalloweenBanner()
{
	if(over_halloween == 1)
	{
		clearTimeout(time_out);
		over_halloween = 0;
	}
}

function hideWitch()
{
	$('halloween').style.top = '-1000px';
	$('hidden_witch').showWitch();
}

addEvent(window, "load", getMousePosition, false);


function getJudete()
{
	
	url = 'index.php?module=concurs&action=concurs&idConcurs=2&ajax=1&req=judet';
	id = $('judete').value;
	
	params = "id="+id;
	new Ajax.Updater(
	'orase_div', url, 
	{
		method: 'GET',
		parameters:params
	}
	
	)
}
function getInstitutie()
{
	
	url = 'index.php?module=concurs&action=concurs&idConcurs=2&ajax=1&req=institutieaj';
	id_judet = $('judete').value;
	id_oras = $('oras').value;
	tip = $('tip').value;
	
	params = "id_judet="+id_judet+"&id_oras="+id_oras+'&tip='+tip;
	new Ajax.Updater(
	'institutiiaj_div', url, 
	{
		method: 'GET',
		parameters:params
	}
	
	)
}

// Concurs Mos Craciun

function hideTopBanner()
{
	$('concurs_mos').style.display = 'none';
	$('hidden_halloween').style.left = '325px';
	$('halloween').style.display = 'none';
	$('calificativ_middle').onmouseover = showTopBanner;
}

function showTopBanner()
{
	$('halloween').style.display = 'block';
	$('hidden_halloween').style.left = '-3000px';
	$('concurs_mos').style.display = 'block';
}

function gotoSanta()
{
	top.location = $('concurs_mos').href;
}

function bookmarkPage(url, title)
{
	if(document.all)
	{
		window.external.AddFavorite(url, title);
	}
	else if(window.sidebar)
	{
		window.sidebar.addPanel(title, url, '');
	}
	else
	{
		alert('Apasa Ctrl + D pentru a adauga aceasta pagina la favorite!');
	}
}