function ShowPopup(hoverpopup,hoveritem) {

	hp = document.getElementById(hoverpopup);

	// Set position of hover-over popup
//	hp.style.top = hoveritem.offsetTop + 18;
//	hp.style.left = hoveritem.offsetLeft + 20;

	// Set popup to visible
	hp.style.display = "";

	// showDiv(hoverpopup);
}

function HidePopup(hoverpopup) {

	hp = document.getElementById(hoverpopup);

	// Set popup to visible
	hp.style.display = "none";
}

function showDiv(id) {

	if (document.getElementById){
		obj = document.getElementById(id);
		obj.style.display = "";
	} 
}


function hideDiv(id) {

	if (document.getElementById){
		obj = document.getElementById(id);
		obj.style.display = "none";
	} 
}

function alternateHideShowDiv (id) {

	if (document.getElementById){
		obj = document.getElementById(id);

		if (obj.style.display == "none") {

			obj.style.display = "";
		}
		else {

			obj.style.display = "none";
		}
	} 
}

function parseXML(text) {

	try { //Internet Explorer
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
		xmlDoc.loadXML(text);
	}
	catch(e) {
		try { //Firefox, Mozilla, Opera, etc.
			parser=new DOMParser();
			xmlDoc=parser.parseFromString(text,"text/xml");
		}	

		catch(e) {
			alert(e.message);
			return;
		}
	}


//	document.getElementById("to").innerHTML=xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
//	document.getElementById("from").innerHTML=xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
//	document.getElementById("message").innerHTML=xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
}

function getAjaxActionSuccess (text) {

	var successText = text.substr(0,8);
//	alert(successText);
	if (successText == '<!--1-->') return true;
	else return false;

//	doc = XML.parse(text);
//	return doc.getElementsByTagName("success")[0].childNodes[0].nodeValue;
}

function getAjaxActionResponse (text) {

	doc = XML.parse(text);
	return doc.getElementsByTagName("response")[0].childNodes[0].nodeValue;
}

function updateSelectWithString (selectBoxId, myString, mySeparator) {

	var selectBox = document.getElementById(selectBoxId);
	var selectOptions = myString.split(mySeparator);
	// alert(selectOptions);

	// remove all

	for (i = selectBox.length - 1; i >= 1 ; i--) {

		// selectBox.remove(selectBox.options[i].index);
		selectBox.remove(i);
	}

	// add new

	// alert(selectOptions.length);

	for (i = 0; i + 1 < selectOptions.length; i = i + 2) {

		// if (i < 2) alert(selectOptions[i]);

		var newOption = document.createElement('option');
		newOption.value = selectOptions[i];
		newOption.text = selectOptions[i + 1];
		newOption.text = newOption.text.replace("&amp;", "&");

		try {
			selectBox.add(newOption,null); // standards compliant
		}
		catch(ex) {
			selectBox.add(newOption); // IE only
		}
	}
}

function addInputToForm (divName, inputType, inputId, inputName) {
	if (!document.getElementById(inputId)) {
		var newdiv = document.createElement('div');
		newdiv.innerHTML = "<input type='" + inputType + "' id='" + inputId + "' name='" + inputName + "'>";
		document.getElementById(divName).appendChild(newdiv);
	}
}

function markAllRows( container_id ) {

    	var rows = document.getElementById(container_id).getElementsByTagName('tr');
    	var unique_id;
    	var checkbox;

	for ( var i = 0; i < rows.length; i++ ) {
		checkbox = rows[i].getElementsByTagName( 'input' )[0];
		if ( checkbox && checkbox.type == 'checkbox' ) {
            		unique_id = checkbox.name + checkbox.value;
            		if ( checkbox.disabled == false ) {
                		checkbox.checked = true;
            		}
	    	}
	}

	return true;
}

function unMarkAllRows( container_id ) {
	var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

	for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;
        }
	}

	return true;
}

function confirmLink(link,mesaj)
{
if(window.confirm(mesaj))
{ 
 window.location.href=link; 
}
}

function submitMultAction(status,mesaj) {

	if(window.confirm(mesaj)) {

		var form = document.getElementById("searchResults"); 
		var actionStatus = document.getElementById("actionStatus"); 

//		alert(actionStatus);
//		alert(form);

		actionStatus.value = status;
		form.submit(); 

	}
}

function submitFormCheck(nume,mesaj) {
	if(window.confirm(mesaj)) {
		eval(nume+".submit();"); 
	}
}