init = function() {
   // quit if this function has already been called
   //if (arguments.callee.done) return;
	
   // flag this function so we don't do the same thing twice
   //arguments.callee.done = true;
	if(!document.getElementById || !document.createTextNode) return;
	var prajiturica = "gataAnimatia";
	var flashvars = {};
	var params = {};
	var attributes = {};
	var wrap=document.getElementById("wrap");
	var sectiune=wrap.getAttribute("class");
	console.log(sectiune);
	if(sectiune=="page") {
		var sectiune = document.getElementsByTagName("BODY")[0].getAttribute("id");
	}
	//alert(sectiune);
	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
		
	if(!readCookie("gataAnimatia")) { //scriu prajiturica
		createCookie("gataAnimatia", "true");
		//alert("no cookie");
	}
	
	else { // pregatesc cafeaua
		//alert("gata cafeaua");
		flashvars.animatieGata = "true";
	}
	
	flashvars.sectiune = sectiune;
	params.allowscriptaccess = "always";
	attributes.id = "antet";
	attributes.name = "antet";
	swfobject.embedSWF("http://www.scoalasoferitimisoara.ro/bunuri/swf/antet.swf", "antetFlash", "766", "381", "8.0.0", false, flashvars, params, attributes);
	var legi = document.getElementById("legi");
	var instructori = document.getElementById("lista-instructori");
	
	if(instructori){
		
		/*for(k=0; k<instructori.childNodes.length; k++) {
			inst = instructori.childNodes[k];
			
			if(inst.nodeName=="LI") {
				
				inst.onmouseover=function(){
					this.style.background="#40484d";
					this.style.cursor='pointer';
				}
				
				inst.onclick=function(){
					for(m=0; m<this.childNodes.length; m++) {
						m_node = this.childNodes[m];
						if(m_node.nodeName == "A"){
							url=m_node.attributes.href.nodeValue;
							window.location=url;
						}
					}
				}
				
				inst.onmouseout=function(){
					this.style.background="none";
				}
				
			}
			
		}*/
	}
	
	else if (legi) {
		for(i=0; i<legi.childNodes.length; i++){
			
			lege = legi.childNodes[i];
			
			if(lege.nodeName=="SPAN") {
				
				lege.onmouseover=function(){
					this.style.background="#40484d";
					this.style.cursor='pointer';
					
					for(j=0; j<this.childNodes.length; j++) {
						j_node = this.childNodes[j];
						if(j_node.nodeName == "A"){
							j_node.style.textDecoration = "none";
						}
					}
					
				}
				
				lege.onmouseout=function(){
					this.style.background="none";
					
					for(j=0; j<this.childNodes.length; j++) {
						j_node = this.childNodes[j];
						if(j_node.nodeName == "A"){
							j_node.style.textDecoration = "underline";
						}
					}
					
				}
				
				lege.onclick=function(){
					
					for(j=0; j<this.childNodes.length; j++) {
						j_node = this.childNodes[j];
						if(j_node.nodeName == "A"){
							url=j_node.attributes.href.nodeValue;
							window.location.href=url;
						}
					}
					
				}
				
			}
		}
	}
};
/* for Mozilla */
if (document.addEventListener) {
   document.addEventListener("DOMContentLoaded", init, false);
}
/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
   document.write("<script defer src=ie_onload.js><"+"/script>");
/*@end @*/
/* for other browsers */
window.onload = init;
