// JavaScript Document
function show_hide (id) {
	if ( document.getElementById(id).style.display == 'none' ) {
		document.getElementById(id).style.display = '';
		document.getElementById('link_'+id).style.display = 'none';
	}
	else {
		document.getElementById(id).style.display = 'none';
		document.getElementById('link_'+id).style.display = '';
	}
}



function switch_id ( id1, id2 ) {
	if ( div1 = document.getElementById(id1)) {
		div1.id = id2;
	}
	else {
		document.getElementById(id2).id = id1;
	}
}




function over(style) {
	style.cursor='pointer';
}

function out(style) {
	style.cursor='default';
}


function convert(mForm){
	mForm.toField.value = convertUnits(
	parseFloat(mForm.fromField.value),
	mForm.fromUnits.options[mForm.fromUnits.selectedIndex].value,
	mForm.toUnits.options[mForm.toUnits.selectedIndex].value);
}
function convertUnits(value, fromUnitFact, toUnitFact) {
	return Math.round((value * fromUnitFact / toUnitFact) * 100) / 100;
}

function arata(id){
	var obj=document.getElementById(id);
	obj.style.display='block';
}

function arata(id){
	var obj=document.getElementById(id);
	obj.style.display='block';
}
function ascunde(id){
	var obj=document.getElementById(id);
	obj.style.display='none';
}



function showDivForSelected(div,selected)
{
	//div-divul ce trebuie descoperit
	//selected-selectul pentru care se aplica
	var objSel = document.getElementById(selected);
	var objDiv = document.getElementById(div);

	//var td_1=document.getElementById('td_1');
	//var td_2=document.getElementById('td_2');

	var selIndex = objSel.selectedIndex;
	var selValue = objSel.options[selIndex].value;

	if (selValue == 1){
		objDiv.style.display = 'table-row';
		//td_1.style.display = 'table-cell';
		//td_2.style.display = 'table-cell';
	}
	else{
		objDiv.style.display = 'none';
		//td_1.style.display = 'none';
		//td_2.style.display = 'none';
	}

}

var bifate=0;
	function bife(iduri){
	var elemente=document.getElementsByName("check_item[]");
	$('iduri_sel').value = '';
	for (i=0;i<elemente.length;i++){
		if (bifate==0){
		elemente[i].checked=true;
		$('iduri_sel').value = iduri;
		}
		else{
		elemente[i].checked=false;
		}
	}
	
		if (bifate==0){
			bifate=1;
		}
		else
		{
			bifate=0;
		}
	
	}
	
function adauga_iduri(obj){
	if (obj.checked == true){
	$('iduri_sel').value +='-'+obj.value;
	}
	else{
		str_4_rep = '-'+obj.value;
		$('iduri_sel').value = $('iduri_sel').value.replace(str_4_rep,"");
	}
	
}

function emailCloak() {

	if (document.getElementById) {

		var user = "office";

		var website = "filipnet.ro";

		var newText = user+"@"+website;

		placeholder = document.getElementById("emailCloak");

		var oldText = placeholder.firstChild;

		var a = document.createElement("a");

		a.href = "mailto:"+newText;

		var address = document.createTextNode(newText);

		a.appendChild(address);

		placeholder.replaceChild(a,oldText);

	}

}

var countInput = 0;
function adauga_inp_file(id,maxInputs){
	var obj=document.getElementById(id);
	
	var new_input=document.createElement('input');
	var new_txt=document.createElement('span');
	var new_check=document.createElement('input');
	
	new_input.setAttribute('type','file');
	new_input.setAttribute('name','poza[]');
	new_input.setAttribute('style','width:200px');
	new_input.setAttribute('size','20');
	
	new_txt.innerHTML = 'principala ';
	
	new_check.setAttribute('type','radio');
	new_check.setAttribute('style','width:15px;height:15px;');
	new_check.setAttribute('name','pr');
	new_check.setAttribute('value',countInput);
	
	if (countInput < maxInputs){
	obj.appendChild(new_input);
	obj.appendChild(new_check);
	obj.appendChild(new_txt);
	
	var new_input=document.createElement('br');
	new_input.setAttribute('style','clear:both');
	obj.appendChild(new_input);
	countInput++;
	}
}
