// general js

function goto(link)
{
    window.location.href = link;
}

function smartTipChange()
{
    var smart = ''+document.getElementById('smartTip').value;
    var idz = smart.split("-",2);
    
    if(idz[0] == 0)
        document.getElementById('select_tip_imobil').value = '';
    else
        document.getElementById('select_tip_imobil').value = idz[0];
        
    if(idz[1] == 0)
        document.getElementById('select_subtip_imobil').value = '';
    else
        document.getElementById('select_subtip_imobil').value = idz[1];
    
}
function smart_ca_submit(){


    var tipId         = document.getElementById('select_tip_imobil').value;
    if(tipId == 0 || tipId =="")
    {
        alert("Selectati tipul ofertei");
        return;
    }
    var tipTranz     = document.getElementById('select_tip_tranzactie').value;
    if(tipTranz == 0 || tipTranz =="")
    {
        alert("Selectati tipul tranzactiei");
        return;
    }

    var subtipId     = document.getElementById('select_subtip_imobil').value;
    if(document.getElementById('selca') != null)
    var zonaId         = document.getElementById('selca').value;   

    var p_min         = document.getElementById('p_min').value;
    var p_max         = document.getElementById('p_max').value;


    var numehtml = 'view';
    switch(tipId)
    {
        case "1": 
                numehtml = 'apartamente-iasi';
                break;
        case "2": 
                numehtml = 'case-iasi';
                break;
        case 3: 
                numehtml = 'vile-iasi';
                break;
        case 4: 
                numehtml = 'spatii-birouri-iasi';
                break;
        case 5: 
                numehtml = 'terenuri-iasi';
                break;
        default: 
                numehtml = 'view';
                break; 
    }

    var newHref = numehtml+'.html?tip='+tipId;
        if(subtipId > 5 && subtipId < 50)
            newHref += '&&subtip='+subtipId;
        if(tipTranz == 2)
            newHref += '&&tip_tranz='+tipTranz;
        if(zonaId != null && zonaId > 0 && zonaId < 1000)
        {
            newHref += '&zona='+zonaId;
            //alert('test='+zonaId+'--');
        }
        if(p_min > 0 && p_min < 10000000)
            newHref += '&&p_min='+p_min;
            
        if(p_max > 0 && p_max < 10000000)
            newHref += '&&p_max='+p_max;
    window.location.href = newHref;
            
}
function ca_submit(){


	var tipId 		= document.getElementById('select_tip_imobil').value;
	if(tipId == 0 || tipId =="")
	{
		alert("Selectati tipul ofertei");
		return;
	}
	var tipTranz 	= document.getElementById('select_tip_tranzactie').value;
	if(tipTranz == 0 || tipTranz =="")
	{
		alert("Selectati tipul tranzactiei");
		return;
	}

	var subtipId 	= document.getElementById('select_subtip_imobil_'+tipId).value;
	var zonaId 		= document.getElementById('select_zona_'+tipId).value;

	var p_min 		= document.getElementById('p_min').value;
	var p_max 		= document.getElementById('p_max').value;



	window.location.href =
		'view.php?tip='+tipId+'&&subtip='+subtipId +'&&zona='+zonaId +'&&tip_tranz='+tipTranz+'&&p_min='+p_min+'&&p_max='+p_max;
}

function ca_admin_submit(){


	var tipId 		= document.getElementById('select_tip_imobil').value;
	if(tipId == 0 || tipId =="")
	{
		alert("Selectati tipul ofertei");
		return;
	}
	var tipTranz 	= document.getElementById('select_tip_tranzactie').value;
	if(tipTranz == 0 || tipTranz =="")
	{
		alert("Selectati tipul tranzactiei");
		return;
	}

	var subtipId 	= document.getElementById('select_subtip_imobil_'+tipId).value;
	var zonaId 		= document.getElementById('select_zona_'+tipId).value;


	window.location.href =
		'admin.oferte.php?tip_imobil='+tipId+'&&subtip_imobil='+subtipId +'&&zona='+zonaId +'&&tip_tranzactie='+tipTranz;
}
function ca_admin_submit2(){
	var sid 		= document.getElementById('sid').value;
	window.location.href = 'admin.search.php?sid='+sid;
}
function filter_submit(tipId,tipTranz,p_min,p_max){
	var zonaId = document.getElementById('filtru_zona_'+tipId).value;
	var subtipId = document.getElementById('filtru_subtip_imobil_'+tipId).value;
	window.location.href =
		'view.php?tip='+tipId+'&&subtip='+subtipId +'&&zona='+zonaId +'&&tip_tranz='+tipTranz+'&&p_min='+p_min+'&&p_max='+p_max;
}
function popupc(link,id,w,h)
{
    var left = (screen.width - w )/2;
    var top = (screen.height -h ) /2;

    var details = 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + w + ',height=' + h + ',left = '+ left +',top ='+top;
    window.open(link,id,details);
}

/**
 *
 * @access public
 * @return void
 **/
function showDiv(iddiv){

for(i=0;i<5;i++){
	var thediv = document.getElementById('dep'+i);
	if(thediv != null)
		thediv.style.display = 'none';

	var shdiv =document.getElementById('dep'+iddiv);
	if(shdiv != null)
		shdiv.style.display = '';
}
}

function showp(iddiv){

for(i=0;i<20;i++){
	var thediv = document.getElementById('p'+i);
	if(thediv != null)
		thediv.style.display = 'none';

	var shdiv =document.getElementById('p'+iddiv);
	if(shdiv != null)
		shdiv.style.display = '';
}
}

function rollplay(ival)
{
    var i = parseInt(ival);
    
    if(i > 14)
        inext = 1;
    else
        inext = parseInt(i) + 1;        
                    
  //  var debugtext = 'i = '+i + ' --- inext = ' + inext + 'ival = || ' + ival +' || \n';
  //  var debugInput = document.getElementById('txtdebug');
  //  txtdebug.value += debugtext;
    
                                         
    var div = document.getElementById('ofspeciale_1_'+i);
    var divnext = document.getElementById('ofspeciale_1_'+inext); 
    div.style.display = 'none';
    divnext.style.display = '';
    
    var div2 = document.getElementById('ofspeciale_2_'+i);
    var divnext2 = document.getElementById('ofspeciale_2_'+inext); 
    div2.style.display = 'none';
    divnext2.style.display = '';
    
    var div3 = document.getElementById('ofspeciale_3_'+i);
    var divnext3 = document.getElementById('ofspeciale_3_'+inext); 
    div3.style.display = 'none';
    divnext3.style.display = '';
    
    var div4 = document.getElementById('ofspeciale_4_'+i);
    var divnext4 = document.getElementById('ofspeciale_4_'+inext); 
    div4.style.display = 'none';
    divnext4.style.display = '';
    
    setTimeout("rollplay(inext)",3000);
}

function cid_submit(){
	var sid 		= document.getElementById('idinp').value;
	window.location.href = 'details.php?id='+sid;
}

var message="RightClick nu este permis!";
// NU MODIFICA !!
function clickIE4(){
    if (event.button==2){
    //alert(message);
    return false;
    }
}

function clickNS4(e){
    if (document.layers||document.getElementById&&!document.all){
        if (e.which==2||e.which==3){
            //alert(message);
            return false;
        }
    }
}
