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 || document.getElementById("in_tags").checked){

			      if(document.getElementById("categorie").value == "toate"){
				         expr_categorie = "";
			      }
			      else{
				          expr_categorie = "categorie = '"+document.getElementById("categorie").value+"'";
			      }
			    
			      lsearch = _mycauta();
			      if(expr_categorie != ''){lsearch += " and ("+expr_categorie+") "; }      
			      document.location.href="http://www.digital-advertising.ro/director/index.php?SEARCH="+escape(lsearch);
			 
	          }
		      else{
			      alert("bifati cel putin o locatie de cautare ! (titlu, continut sau tags)");
		      }	      
		  }
		  else{
			 alert("caractere ilegale in  secventa de cautare !");
		  }
   }
}




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 = "";   ltags = "";
	      if( document.getElementById("in_titlu").checked ){
			  ltitlu = "nume like '"+wstring+"'";
		  }
		  if( document.getElementById("in_continut").checked ){
			  lcontinut = "descriere like '"+wstring+"'";
		  }

		  if( document.getElementById("in_tags").checked ){
			  ltags = "tags like '"+wstring+"'";
		  }

          if(ltitlu != ''){
			 lsearch += " or ("+ltitlu+")"; 
		  }
          if(lcontinut != ''){
			 lsearch += " or ("+lcontinut+")"; 
		  }
          if(ltags != ''){
			 lsearch += " or ("+ltags+")"; 
		  }		
	  }
	  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 = "";  ltags = "";
			          if( document.getElementById("in_titlu").checked ){
				           ltitlu = "nume like '"+wstring+"'";
			          }
			          if( document.getElementById("in_continut").checked ){
				          lcontinut = "descriere like '"+wstring+"'";
			          }
			          if( document.getElementById("in_tags").checked ){
				          lcontinut = "tags like '"+wstring+"'";
			          }

                      if(ltitlu != ''){
			             lsearch += " or ("+ltitlu+")"; 
		              }
                      if(lcontinut != ''){
			              lsearch += " or ("+lcontinut+")"; 
		              }
                      if(ltags != ''){
			             lsearch += " or ("+ltags+")"; 
		              }		
				  }
			  
			  }
	  }	 
	  return "("+lsearch.substr(4)+")";             
}


function showcautare() {
	document.getElementById("anuntcautare").style.display="block"; 
	//return true;
    
}



function hidecautare() {
	document.getElementById("anuntcautare").style.display="none"; 
	//return true;
}


function loadSite(site){
    document.location.href = site;
}


function raspundesite(){
   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 resetsite(){
   document.getElementById("subiect").value = '';
   document.getElementById("email").value   = '';
   document.getElementById("mesaj").value   = '';
   document.getElementById("nume").value   = '';
}








