// show hide mainDet content
function show(divID)
{
	if (document.getElementById(divID))	document.getElementById(divID).style.display='block';
}
function hide(divID)
{
	if (document.getElementById(divID))	document.getElementById(divID).style.display='none';
}
function showHide(divID) 
{
	document.getElementById(divID).style.display == 'none' ? document.getElementById(divID).style.display = 'block' : document.getElementById(divID).style.display = 'none';
}

// Checks if a field is empty, and if so, resets the input's content to the default value
function checkField( obj, value, pass )
{
	var isMSIE = /*@cc_on!@*/false;
	// Match any amount of white spaces
	if( obj.value == "" )
	{
		obj.value = value;
		if (pass && !isMSIE) 
		{
			obj.type = 'text';
		}
	}
	else if (pass && !isMSIE) 
	{
		obj.type = 'password';
	}
	return false;
}

// Clears an input's content
function clearField( obj, value, pass )
{
	var isMSIE = /*@cc_on!@*/false;
	if( obj.value == value )
	{
		obj.value = "";
		if (pass && !isMSIE)
		{
			obj.type = 'password';
		}
	}
	else if (pass && !isMSIE) 
	{
		obj.type = 'password';
	}
	return false;
}

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 reloadWindow()
{
	window.location=window.location;
	
	return;
}

function obiect(id)
{
	if (document.getElementById(id)) return document.getElementById(id); else return false;
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function toggle(activ)
{
	boxes = getElementsByClass('detaliiPersonal',null,'div');
	for (i=0; i<boxes.length; i++)
	{
		boxes[i].style.display='none';
	}
	obiect(activ).style.display='block';
}

function markFields(campuri, news)
{
	var vector = new Array;
	vector = campuri.split("%");
	for (i=0;i<vector.length;i++)
	if (obiect(vector[i]))
	{
		if (news) obiect(vector[i]).style.color = '#FF0000';
		else obiect(vector[i]).style.backgroundColor = '#F9E5E5';
	}
}

var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

function addOption(theSel, theText, theValue)
{
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex)
{ 
  var selLength = theSel.length;
  if(selLength>0)
  {
    theSel.options[theIndex] = null;
  }
}

function moveOptions(theSelFrom, theSelTo)
{
  
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
    if(theSelFrom.options[i].selected)
    {
      selectedText[selectedCount] = theSelFrom.options[i].text;
      selectedValues[selectedCount] = theSelFrom.options[i].value;
      deleteOption(theSelFrom, i);
      selectedCount++;
    }
  }
  
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
    addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
  
  if(NS4) history.go(0);
}

function closeWindow(id)
{
	if (document.getElementById(id)) document.getElementById(id).style.display = 'none';
}

function printPage(id)
{
	var opt = 'scrollbars=yes,width=690,height=600,left=10,top=10';
	var src = mainWebsiteURL+'print.php?id='+id;
	window.open(src,'',opt);
}

/*pop image*/

PositionX = 10;
PositionY = 10;


defaultWidth  = '';
defaultHeight = '';


var AutoClose = true;

var opt='scrollbars=yes,width=150,height=100,left='+PositionX+',top='+PositionY;
function pop(src){
imageURL=mainWebsiteURL+'custom_images/anunturi/'+src;
imageTitle='Profimob';
imgWin=window.open('about:blank','',opt);
with (imgWin.document){
writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
writeln('<html><head><title>Loading...</title><style type="text/css">body{margin:0; padding:0;}</style>');
writeln('<sc'+'ript type="text/javascript">');
writeln('function reSizeToImage(){');
writeln('window.resizeTo(100,100);');
writeln('width=100+document.images[1].width;');
writeln('height=100+document.images[1].height;');
writeln('window.resizeTo(width,height);}');
writeln('function doTitle(){document.title="'+imageTitle+'";document.getElementById(\'loading\').style.display="none";}');
writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor="#ffffff" onload="reSizeToImage();doTitle();self.focus()">');
writeln('<table width="100%"><tr><td align="center" valign="middle"><p id="loading">Loading...</p><p align="center"><a href="javascript:print();" style="text-decoration:none; color:#000;"><img border="0" src="'+mainWebsiteURL+'images/print.jpg" alt="Print" /></a></p><img name="Profimob" sr' + 'c='+imageURL+' style="display:block" /></td></tr></table></body></html>');
close();		
}}

/*end pop image*/

function changeAp(aId)
{
	var oldElements = getElementsByClass('tdActive',null,'TD');
	for (o=0;o<oldElements.length;o++)
	{
		oldElements[o].className = '';
	}
	var sCont = obiect('schitaApPeEtaj');
	if (sCont.childNodes.length) sCont.removeChild(obiect('schitaAp'));
	var tr = obiect('ap'+aId);
	for (t=0;t<tr.childNodes.length;t++)
	{
		if (tr.childNodes[t].tagName == 'TD') tr.childNodes[t].className = 'tdActive';
	}
	var imagine = document.createElement('img');
	imagine.setAttribute('src',mainWebsiteURL+schite[aId]);
	imagine.setAttribute('alt','Lucefarul');
	imagine.setAttribute('id','schitaAp');
	sCont.appendChild(imagine);
}

function confirmDelete(mesaj, link)
{
	var sterge = confirm(decodeURIComponent((mesaj.replace(/\+/g,  " "))));
	if (sterge) window.location = link;
}
