function openNewPopup(url, w, h) {

    var _left = 200;

    var _top = 200;

    var _location = 'no';

    var _directories = 'no';

    var _menubar = 'no';

    var _resizable = 'no';

    var _scrollbars = 'no';

    var _status = 'no';

    var _titlebar = 'no';

    var _toolbar = 'no';

        

    window.popupWindow = window.open(url, '_blank', 'width='+w

        +', height='+h+',left='+_left+', top='+_top+', location='+_location

        +', directories='+_directories+', menubar='+_menubar

        +', resizable='+_resizable+', scrollbars='+_scrollbars

        +', status='+_status+', titlebar='+_titlebar+', toolbar='+_toolbar);

        

    return false;

}



function makeSearch() {

	if($('search')) {

		if($('search').value) {

			window.location='cautare-'+$('search').value+'-X.html';

		}

	}

}

function quickSearchByKey(e) {

    var keyCode = (window.event) ? event.keyCode : e.keyCode;

    var enterCode = 13;

    if(keyCode==enterCode) {

        makeSearch();

    }

}



function $(id) {

	if(document.getElementById(id)) {

		return document.getElementById(id);

	}

}

function showCompanyInfo() {
	for(var i=1; i<10; i++) {
		if($('row_' + i)) {
			try {
				$('row_' + i).style.display = "table-row";
			} catch (err) {	
				$('row_' + i).style.display = "block";
			}
		}
	}
	return false;
}

//old

//Author: M. Catalin, dublutz@yahoo.com

//Date: 08.03.2006

window.maxqty = 90;

window.minqty = 0;



function incrementVal(id, max) {

	var elem = $(id);

	if(!elem) {

		return false;

	}

	

	maxqty = max ? max : maxqty;

    if( parseInt(elem.value) < 0 )
    {
    	elem.value = 1;
    	return false;
	}
	
	if(elem.value != maxqty) {

		elem.value = parseInt(elem.value) + 1;

	}

	return false;

}

function decrementVal(id, min) {

	var elem = $(id);

	if(!elem) {

		return false;

	}

	minqty = minqty ? minqty : min;

	
    if( parseInt(elem.value) < min )
    {
    	elem.value = min;
    	return false;
	}
	
	if(elem.value != minqty) {
		elem.value = parseInt(elem.value) - 1;
	}

	return false;

}



function mergiLaCasa() {

	window.location = "casa.php";

	return true;

}

function submitLogin() {

	var frm = $('login');

	if(!frm) {

		return false;

	}

	frm.submit();

	return true;

}

function $(id) {

	if(document.getElementById(id)) {

		return document.getElementById(id);

	} 

	return false;

}

function cumparaProdus(id) {

	if(!id) {

		return false;

	}

	$('b').value = id;

	$('buy').submit();

	return false;	

}

// hide/show arrows when cursor is over the menu

function rollin(name1,name2)
{
   if( document.getElementById(name1) )
   {
   	   document.getElementById(name1).style.display='block';//color="#000000";
   }
   
   if( document.getElementById(name2) )
   {
   	   document.getElementById(name2).style.display='block';//color="#000000";
   }   
}


function rollout(name1,name2)
{
   if( document.getElementById(name1) )
   {
   	   document.getElementById(name1).style.display='none';//.color="#FFFFFF";
   }
   
   if( document.getElementById(name2) )
   {
   	   document.getElementById(name2).style.display='none';//"#FFFFFF";
   }     
}

function toggle(id)
{
   var state;
   if( document.getElementById(id) )
   {
   	   state = document.getElementById(id).style.display;
   	   
   	   state == 'none' ? state = 'block': state = 'none';
   	   document.getElementById(id).style.display = state;
   }
  
}

function validate_altelocuri(id_location,id_command)
{
  if ( $(id_location).value == '')
  {
      alert ("Ati uitat sa scrieti localul !");
	  return false;
  }

  if ( $(id_command).value == '')
  {
      alert ("Comanda trebuie sa contina cel putin un produs !");
	  return false;
  }  
  
  document.altelocuri.submit();
  return true;
}

function toggle_cumpara_modifica(id_textbox,id_image,img_cumpara,img_modifica,default_text)
{

   if( $(id_textbox) && $(id_image) )
   {
       if ( default_text == "" ) return;
	   
       if( $(id_textbox).value != default_text )
       {
	       $(id_image).src = img_cumpara;
	   }
	   else
	   {
	       $(id_image).src = img_modifica;  
	   }
   }

}
