myhref = document.location.href;
maxmediaid  = -1;
search  = null;
nrcomments = -1;

isLoaded = false;;
var X = 0;
var Y = 0;


//Hide status bar msg II script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use



if (document.layers)document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)



document.onmouseover=hidestatus;
document.onmouseout=hidestatus;
document.onmousedown=hidestatus;
document.onmouseup=hidestatus;
document.onmouseclick=hidestatus;



function init(){
	isLoaded = true;
    pushimages();
}



function hidestatus(){
window.status='Digital Advertising';
return true
}



function pushimages() {

      for (var i=0; i<document.images.length; i++) {
        if (!document.images[i].complete) {
            document.images[i].src = document.images[i].src;
        }
      }

}


function mycauta(){  
   if( trim(document.getElementById("searchtext").value) == ""){
      alert("nu ati introdus cuvinte de cautare");
   }
   else{
		  if( isAlphaNum( trim(document.getElementById("searchtext").value)) )
	      {
	          if ( document.getElementById("in_titlu").checked || document.getElementById("in_continut").checked){

			      if(document.getElementById("categorie").value == "toate"){
				         expr_categorie = "";
			      }
			      else{
				          expr_categorie = "categorie = '"+document.getElementById("categorie").value+"'";
			      }

			      if(document.getElementById("judet").value == "toate"){
				          expr_judet = "";
			      } 
			          else{
				          expr_judet = "judet = '"+document.getElementById("judet").value+"'";
			      }
			      lsearch = _mycauta();
			      if(expr_categorie != ''){lsearch += " and ("+expr_categorie+") "; }
			      if(expr_judet != '')    {lsearch += " and ("+expr_judet+") ";	    }			      
			      document.location.href="http://www.digital-advertising.ro/anunturi/index.php?SEARCH="+escape(lsearch);
			 
	          }
		      else{
			      alert("bifaţi cel puţin o locaţie de căutare ! (titlu sau conţinut)");
		      }	      
		  }
		  else{
			 alert("caractere ilegale în  secventa de căutare !");
		  }
   }
}




function _mycauta(){
	  lexact = true;
	  totalstring = document.getElementById("searchtext").value;
	  lexact = (totalstring.charAt(0) == "'" && totalstring.charAt( totalstring.length-1 ) == "'") ||
		       (totalstring.charAt(0) == '"' && totalstring.charAt( totalstring.length-1 ) == '"');
	  lsearch = "";
	  if(lexact){
		  totalstring = document.getElementById("searchtext").value.substr(1);
		  totalstring = totalstring.substr(0,totalstring.length-1);		 
		  wstring = "!"+totalstring+"!";	
		  ltitlu = "";   lcontinut = "";
	      if( document.getElementById("in_titlu").checked ){
			  ltitlu = "titlu like '"+wstring+"'";
		  }
		  if( document.getElementById("in_continut").checked ){
			  lcontinut = "continut like '"+wstring+"'";
		  }
		  if(ltitlu == '') { 
			 lsearch += " or ("+lcontinut+")"; 
		  }
		  else{
			 if(lcontinut == ''){
				lsearch += " or ("+ltitlu+")"; 
			 }
			 else{
				lsearch += " or ("+ltitlu+" or "+lcontinut+")";
			}
		  }		  
	  }
	  else {
			  totalstring = document.getElementById("searchtext").value;
			  arraystring = totalstring.split(" ");			
			  for(i=0; i< arraystring.length; i++){
                  
				  if( trim(arraystring[i]) != '' )
				  {			   
                      wstring = "!"+arraystring[i]+"!";	
			          ltitlu = "";   lcontinut = "";
			          if( document.getElementById("in_titlu").checked ){
				           ltitlu = "titlu like '"+wstring+"'";
			          }
			          if( document.getElementById("in_continut").checked ){
				          lcontinut = "continut like '"+wstring+"'";
			          }
			          if(ltitlu == '') { 
				          lsearch += " or ("+lcontinut+")"; 
			          }
			          else{
				          if(lcontinut == ''){
					          lsearch += " or ("+ltitlu+")"; 
				          }
				           else{
					           lsearch += " or ("+ltitlu+" or "+lcontinut+")";
				          }
			          }
				  }
			  
			  }
	  }	 
	  return "("+lsearch.substr(4)+")";             
}




function raspundeanunt(){
   xsubiect  = document.getElementById("subiect").value;
   xemail    = document.getElementById("email").value;
   xmesaj    = document.getElementById("mesaj").value;
   xnume     = document.getElementById("nume").value;
   vcode     = document.getElementById("VCODE").value;
   if( trim(vcode) != ''){
     if( isAlphaNum(xsubiect) && isAlphaNum(xmesaj) ){
        if ( trim(xsubiect) != "" && trim(xmesaj) != "" && trim(xnume) != "" && emailCheck(xemail)){	      
	       document.xform.submit();
        }
        else{
           alert("Completează numele, subiectul, mesajul şi adresa email corectă...");
        }
     }
     else{
	     alert("Caractere ilegale în text... !");
     }
   }
   else{
   	  alert("Cod verificare inexistent... !");
   }
}


function resetanunt(){
   document.getElementById("subiect").value = '';
   document.getElementById("email").value   = '';
   document.getElementById("mesaj").value   = '';
   document.getElementById("nume").value   = '';
}




function showcautare() {
	document.getElementById("anuntcautare").style.display="block"; 
	//return true;
    
}



function hidecautare() {
	document.getElementById("anuntcautare").style.display="none"; 
	//return true;
}










function showHint(obj, content, mode){   
   if (isLoaded){	 
      id_hint="hint_holder";
      if (mode == "show"){        
		 X = getElementLeft(obj);
	     Y = getElementTop(obj);
         document.getElementById(id_hint).style.top  = Y-80;
         document.getElementById(id_hint).style.left = X-80;
		 dynamiccontent(id_hint,content);
         
      }
      else{    
		 dynamiccontent(id_hint,'');
         document.getElementById(id_hint).style.top  = 0;
         document.getElementById(id_hint).style.left = 0;             
      }    
   }
}






function convertonthefly(euro, dolar, valuta_curenta, suma_de_convertit){
	euro  = euro.replace(",",".");
	dolar = dolar.replace(",",".");
	var retstring = '';
	if(valuta_curenta == "RON"){
		retstring = "<table  border='0' cellpadding='3' cellspacing='3' style = 'border: 1px solid #606060; background-color:#222233'>";
		retstring += "<tr><td class='usual1' align='left'><b>pret convertit in EUR si USD</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:showHint(0,0,\"hide\");'><img src='http://www.digital-advertising.ro/images/close.gif' width='15' height='15' border='0'></a></td></tr>";		
		retstring += "<tr><td class='usual'>EUR: "+myFormat(suma_de_convertit/euro,2)+" eur</td></tr>";
		retstring += "<tr><td class='usual'>USD: "+myFormat(suma_de_convertit/dolar,2)+" usd</td></tr>";
		retstring += "</table>";
	}
	if(valuta_curenta == "EUR"){
		retstring = "<table border='0' cellpadding='3' cellspacing='3' style = 'border: 1px solid #606060; background-color:#222233'>";
		retstring += "<tr><td class='usual1' align='left'><b>pret convertit in RON si USD</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:showHint(0,0,\"hide\");'><img src='http://www.digital-advertising.ro/images/close.gif' width='15' height='15' border='0'></a></td></tr>";
		
		retstring += "<tr><td class='usual'>RON: "+myFormat(suma_de_convertit*euro,2)+" ron</td></tr>";
		retstring += "<tr><td class='usual'>USD: "+myFormat(suma_de_convertit*euro/dolar,2)+" usd</td></tr>";
		retstring += "</table>";
	}
	if(valuta_curenta == "USD"){
		retstring = "<table border='0' cellpadding='3' cellspacing='3' style = 'border: 1px solid #606060; background-color:#222233'>";
		retstring += "<tr><td class='usual1' align='left'><b>pret convertit in EUR si RON</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:showHint(0,0,\"hide\");'><img src='http://www.digital-advertising.ro/images/close.gif' width='15' height='15' border='0'></a></td></tr>";
		retstring += "<tr><td class='usual'>EUR: "+myFormat(suma_de_convertit*dolar/euro,2)+" eur</td></tr>";
		retstring += "<tr><td class='usual'>RON: "+myFormat(suma_de_convertit*dolar,2)+" ron</td></tr>";
		retstring += "</table>";
	}
	
	 return retstring;
}


function getElementLeft(Elem) {
var elem;
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		xPos = elem.offsetLeft;
		tempEl = elem.offsetParent;
  		while (tempEl != null) {
  			xPos += tempEl.offsetLeft;
	  		tempEl = tempEl.offsetParent;
  		}
		return xPos;
}


function getElementTop(Elem) {
if(document.getElementById) {	
			var elem = document.getElementById(Elem);
    } else if (document.all) {
			var elem = document.all[Elem];
	   }
		yPos = elem.offsetTop;
		tempEl = elem.offsetParent;
		while (tempEl != null) {
  			yPos += tempEl.offsetTop;
	  		tempEl = tempEl.offsetParent;
  	   }
	return yPos;
}





