var rank = new Array();
var currentMenu = 1;

rank[1] = '11';
rank[2] = '12';
rank[3] = '13';

// Get the cookie font size when doc loaded
window.onload=function () {
	getFontSize();
	document.getElementById('cntnt01moduleform_1').onsubmit = function() {
		var valueLength = document.getElementById('cntnt01searchinput').value.length;
		if (document.getElementById('cntnt01searchinput').value != "cautare" && valueLength != 0) {
			return true;
		} else {
			return false;
		}
	};
};


// Image preload
function MM_preloadImages() {
  var d=document;
  
  if(d.images) {
    if(!d.MM_p) {
      d.MM_p=new Array();
    }
      
    var i, j=d.MM_p.length, a=MM_preloadImages.arguments;
    
    for(i=0; i<a.length; i++) {
      if (a[i].indexOf("#") != 0) {
        d.MM_p[j] = new Image;
        d.MM_p[j++].src = a[i];
      }
    }
  }
}

// Cookie functions
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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function getFontSize() {
	// reading the cookie and getting the font size, 12 by default
	var docFontSize = readCookie('generalFontSize');
	
	if (docFontSize != 11) {
		document.body.style.fontSize = rank[docFontSize] + 'px';

	if (docFontSize==1) {
		document.getElementById('font_1').className='font_tweaker t_first t_active';
		document.getElementById('font_2').className='font_tweaker t_second';
		document.getElementById('font_3').className='font_tweaker t_third';
	} else if (docFontSize==2) {
		document.getElementById('font_1').className='font_tweaker t_first';
		document.getElementById('font_2').className='font_tweaker t_second t_active';
		document.getElementById('font_3').className='font_tweaker t_third';
	} else {
		document.getElementById('font_1').className='font_tweaker t_first';
		document.getElementById('font_2').className='font_tweaker t_second';
		document.getElementById('font_3').className='font_tweaker t_third t_active';
	}
	}
}

// General functions
function changeFontSize(id) {   
   document.body.style.fontSize = rank[id] + 'px';
   
   // creating the cookie with the new font size
   createCookie('generalFontSize', id, 1);
   
   if (id==1) {
	document.getElementById('font_1').className='font_tweaker t_first t_active';
	document.getElementById('font_2').className='font_tweaker t_second';
	document.getElementById('font_3').className='font_tweaker t_third';
   } else if (id==2) {
	document.getElementById('font_1').className='font_tweaker t_first';
	document.getElementById('font_2').className='font_tweaker t_second t_active';
	document.getElementById('font_3').className='font_tweaker t_third';
   } else {
	document.getElementById('font_1').className='font_tweaker t_first';
	document.getElementById('font_2').className='font_tweaker t_second';
	document.getElementById('font_3').className='font_tweaker t_third t_active';
   }
}

function makeActive(id) {
	if (id != currentMenu) {
		var p=document.getElementById("dd_menu_"+currentMenu);
		var newElem=document.getElementById("dd_menu_"+id);
		
		document.getElementById("menu_item_"+currentMenu).className="inactive_item";
		document.getElementById("img_t_"+currentMenu).src="images/menu_item_inactive_top.jpg";
		document.getElementById("img_b_"+currentMenu).src="images/menu_item_inactive_bottom.jpg";
		Effect.SlideUp(p);
		
		currentMenu = id;

		document.getElementById("menu_item_"+id).className="active_item";
		document.getElementById("img_t_"+id).src="images/menu_item_active_top.jpg";
		document.getElementById("img_b_"+id).src="images/menu_item_active_bottom.jpg";
		Effect.SlideDown(newElem);
	}
}
