function swap_img(id, state, img_path){
	if(state == "on"){
		document.getElementById("btn"+id).setAttribute("src", img_path+"btns/btn"+id+"_over.gif", 0);
	}
	else{
		document.getElementById("btn"+id).setAttribute("src", img_path+"btns/btn"+id+".gif", 0);
	}
}

function change_img_sp_menu(section, id, img_path){
		document.getElementById("menu_bg").setAttribute("src", img_path+"sp_menu/"+section+"_"+id+".jpg", 0);
}

function show_hide_definition(id){
	if(document.getElementById("def_"+id).style.display == ""){
		document.getElementById("def_"+id).style.display = "none";
	}
	else{
		document.getElementById("def_"+id).style.display = "";
	}
}

boli_activ = 0;

function boli_over(id, total){
	if(boli_activ != 0){
		document.getElementById("submenu_"+boli_activ).style.display = 'none';
		document.getElementById("menu_"+boli_activ).style['border'] = "1px solid #ffffff";
		document.getElementById("menu_"+boli_activ).style['background'] = "#ffffff";
	}
	document.getElementById("menu_"+id).style['border'] = "1px solid #656565";
	document.getElementById("menu_"+id).style['background'] = "#f8f5f0";
	document.getElementById("submenu_"+id).style.display = '';
	boli_activ = id;
}

function submenu_all_switch(off, on){
	document.getElementById('menu_'+off).style.display = "none";
	document.getElementById('menu_'+on).style.display = "";
}

function show_menu_all(section, id, img_path){
	document.getElementById("menu_bg").setAttribute("src", img_path+"sp_menu/"+section+"_"+id+"1.jpg", 0);
	document.getElementById('sp_menu').style.display = "none";
	document.getElementById('sp_menu_shade').style.display = "none";
	document.getElementById('menu_0').style.display = "";
	document.getElementById('sp_menu_all').style.display = "";
	document.getElementById('sp_menu_all1').style.display = "";
}


function fix_it(){
	objs = document.getElementsByTagName("div");
	len = objs.length;
	for(i=0;i<len;i++){
		if(objs[i].id == "flash_main"){
			objs[i].innerHTML = objs[i].innerHTML;
		}
	}
}


function submenu_articol_switch(off, on){
	document.getElementById('cont_'+off).style.display = "none";
	document.getElementById('cont_'+on).style.display = "";
	default_on = on;
}

default_on = 0;

function check_content(obj,cont){
	if(obj.value == cont){
		obj.value = "";
	}
	
}

function uncheck_content(obj,cont){
	if(obj.value == ""){
		obj.value = cont;
	}
}

function submenu_articol_switch_menu(on){
	document.getElementById('cont_'+default_on).style.display = "none";
	document.getElementById('cont_'+on).style.display = "";
	default_on = on;
}


cantar_on = -1;
function change_check(img_path, param){
	if(param == 0){
		document.getElementById("check_male").setAttribute("src", img_path+"check_on.jpg", 0);
		document.getElementById("check_female").setAttribute("src", img_path+"check_off.jpg", 0);
		cantar_on = 0;
	}
	else{
		document.getElementById("check_male").setAttribute("src", img_path+"check_off.jpg", 0);
		document.getElementById("check_female").setAttribute("src", img_path+"check_on.jpg", 0);
		cantar_on = 1;
	}
	
	//alert(cantar_on);
	calcualte_weigth();
}


function IsNumeric(strString){
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;
	
	if (strString.length == 0){
		return false;
	}
	for (i = 0; i < strString.length && blnResult == true; i++){
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1){
			blnResult = false;
		}
	}
	return blnResult;
}
   
   
function calcualte_weigth(){
//	varsta = document.getElementById("calc_varsta").value;
//	inaltime = document.getElementById("calc_inaltime").value;
	varsta = document.cantar['varsta'].value;
	inaltime = document.cantar['inaltime'].value;
	//alert(cantar_on);
	if(cantar_on == 0){
		//alert("xx");
		gender = 1;
	}
	else{
		if(cantar_on == 1){
		//alert("xxx");
			gender = 0.9;
		}
		else{
			document.getElementById("calac_necompletat").style.display = '';
			document.getElementById("calac_completat").style.display = 'none';
			return false;
		}
	}
	if(IsNumeric(varsta) && IsNumeric(inaltime)){
		if(varsta < 0 || varsta > 150){
			alert("Varsta trebuie sa fie mai mare de 1 an si mai mica de 150 de ani.");
			document.getElementById("calac_necompletat").style.display = '';
			document.getElementById("calac_completat").style.display = 'none';
			return false;
		}
		
		if(inaltime < 20 || inaltime > 300){
			alert("Inaltimea trebuie sa fie intodusa in centimetri si trebuie sa fie mai mare de 20cm si mai mica de 300.");
			document.getElementById("calac_necompletat").style.display = '';
			document.getElementById("calac_completat").style.display = 'none';
			return false;
		}
		gr = (50+0.75*(inaltime-150)+(varsta-20)/4)*gender;
		document.getElementById("calc_greutate").innerHTML = gr+" Kg";
		document.getElementById("calac_necompletat").style.display = 'none';
		document.getElementById("calac_completat").style.display = '';
		return true;
		
		
	}
	document.getElementById("calac_necompletat").style.display = '';
	document.getElementById("calac_completat").style.display = 'none';
}


function switch_bg_color(obj, color){
	//obj.style['background-color'] = color;
	obj.setAttribute("bgcolor", "#"+color, 0);
}

function get_month_nr(nr){
	switch(nr){
		case 0:
			month = "Ianuarie";
			break;
		case 1:
			month = "Februarie";
			break;
		case 2:
			month = "Martie";
			break;
		case 3:
			month = "Aprilie";
			break;
		case 4:
			month = "Mai";
			break;
		case 5:
			month = "Iunie";
			break;
		case 6:
			month = "Iulie";
			break;
		case 7:
			month = "August";
			break;
		case 8:
			month = "Septembrie";
			break;
		case 9:
			month = "Octombrie";
			break;
		case 10:
			month = "Noiembrie";
			break;
		case 11:
			month = "Decembrie";
			break;
	}
	return(month);
}


function calc_nastere(){
	an = document.nastere['an'].value;
	luna = document.nastere['luna'].value;
	zi = document.nastere['zi'].value;
	
	if(an != "an" && luna != "luna" && zi != "zi"){
		data = new Date( );
		data.setDate(zi);
		data.setMonth(luna);
		data.setFullYear(an);
		months = 1000*60*60*24*30*3;
		days = 1000*60*60*24*7;
		year = 1000*60*60*24*364;
		
		data.setTime(data.getTime() - months + days + year);
		
		month = get_month_nr(data.getMonth());
		
		str = data.getDate()+" "+month+" "+data.getYear();
		
		document.getElementById('nastere_on').style.display = '';
		document.getElementById('nastere_data').innerHTML = str;
		document.getElementById('nastere_off').style.display = 'none';
	}
	else{
		document.getElementById('nastere_on').style.display = 'none';
		document.getElementById('nastere_off').style.display = '';
	}
}
	
function calc_ovulatie(e){
	if(window.event){
		keynum = e.keyCode;
	}
	else if(e.which){
		keynum = e.which;
	}
	keychar = String.fromCharCode(keynum);
	
	lungime = document.ovulatie['lungime'].value;
	zi = document.ovulatie['zi'].value;
	luna = document.ovulatie['luna'].value;
	an = document.ovulatie['an'].value;
	if(lungime.length < 2){
		lungime += keychar;
	}
	
	if((IsNumeric(lungime) && lungime>0 && lungime<32) && (zi != "zi") && (luna != "luna") && (an != "an")){
		str = Math.ceil(2.2+0.37*lungime);
		//alert(zi+"-"+luna+"-"+an);
		data = new Date( );
		data.setDate(zi);
		data.setMonth(luna);
		data.setFullYear(an);
		data.setTime(data.getTime() + str*1000*60*60*24);
		month = get_month_nr(data.getMonth());
		
		str = data.getDate()+" "+month+" "+data.getYear();
		document.getElementById('ovulatie_on').style.display = '';
		document.getElementById('ovulatie_data').innerHTML = str;
		document.getElementById('ovulatie_off').style.display = 'none';
	}
	else{
		document.getElementById('ovulatie_on').style.display = 'none';
		document.getElementById('ovulatie_off').style.display = '';
	}
}


function cover_stage(id,img_path){
	div = document.getElementById('shade_all');
	div.style['height'] = document.body.clientHeight+217;
	div.style['width'] = document.body.clientWidth;
	img_div = document.getElementById('img_cont');
	img = document.getElementById('img_full');
	img.setAttribute('src', img_path+"galerie/"+id+".jpg",0)
	img_div.style.display = '';
	div.style.display = '';
}
	
function hide_stage_cover(){
	div = document.getElementById('shade_all');
	img_div = document.getElementById('img_cont');
	img_div.style.display = 'none';
	div.style.display = 'none';
}

function addToFavorites(urlAddress, pageName) {
	if (window.external){
		window.external.AddFavorite(urlAddress,pageName);
	}
	else{
		alert("Sorry! Your browser doesn't support this function."); 
	}
} 

function open_print(link1, link2){
	print_link =link1+"print.php?print_link="+link2+"&ord="+default_on ;
	window.open(print_link, "print_window");
	//window.open("http://www.sfatmedical.ro", "ssss");
}

function open_mail(link1, link2){
	mail_link = link1+"mail.php?mail_link="+link2;
	window.open(mail_link, "mail_window", "location=0,status=0,scrollbars=0,width=400,height=250");
	//window.open("http://www.sfatmedical.ro", "ssss");
}
	