    
var total_sites = 11;
var site_1 = "españa,http://casas.trovit.es,http://coches.trovit.es,http://empleo.trovit.es,es,es_ES";
var site_2 = "reino unido,http://homes.trovit.co.uk,http://cars.trovit.co.uk,http://jobs.trovit.co.uk,uk,en_GB";
var site_3 = "francia,http://immo.trovit.com,http://voitures.trovit.com,http://emploi.trovit.com,fr,fr_FR";
var site_4 = "italia,http://case.trovit.it,http://it.trovit.it,http://lavoro.trovit.it,it,it_IT";
var site_5 = "portugal,http://casa.trovit.pt,http://auto.trovit.pt,http://emprego.trovit.pt,pt,pt_PT";
var site_6 = "alemania,http://immobilien.trovit.de,http://autos.trovit.de,http://jobs.trovit.de,de,de_DE";
var site_7 = "netherlands,http://nl.trovit.com/huizen,nl.trovit.com/autos,http://nl.trovit.com/vacatures,nl,nl_NL";
var site_8 = "mejico,http://mexico.trovit.com/casas,http://mexico.trovit.com/autos,http://mexico.trovit.com/empleo,mx,es_MX";
var site_9 = "argentina,http://argentina.trovit.com/casas,http://argentina.trovit.com/autos,http://argentina.trovit.com/empleo,ar,es_AR";
var site_10 = "chile,http://chile.trovit.com/casas,http://chile.trovit.com/autos,http://chile.trovit.com/empleo,cl,es_CL";
var site_11 = "brasil,http://brasil.trovit.com/imoveis,http://brasil.trovit.com/automoveis,http://brasil.trovit.com/emprego,br,pt_BR";

var alquiler = new Array('alquiler','for rent','location','affitto','arrendamento','mieten','Te Huur','renta','renta','renta','aluguel');
var venta = new Array('venta','for sale','vente','vendita','venta','zu verkaufen','te koop','venta','venta','venta','venda');
var ejemplo = new Array('ejemplo','example','exemple','esempi','exemplo','Beispiele','ejemplo','ejemplo','ejemplo','exemplo');
var txt_ejemplo_casas = new Array('piso Barcelona','Studio London','maison Paris','attico Roma','moradia Lisboa','zu mieten Mannheim','Eindhoven','renta casa Guadalajara','renta piso Córdoba','Santiago','moradia São Paulo');
var txt_ejemplo_coches = "Porsche Cayenne";
var txt_ejemplo_empleo = new Array('product manager Barcelona','product manager London','Marketing Paris','Developer Roma','comerciais Porto','Marketing München','Java Amsterdam','administrativo Monterrey','administrativo Mendoza','Java Santiago','marketing São Paulo');

var coches = new Array('coches','cars','voitures','auto','automóveis','autos','auto\'s','autos','autos','autos','automóveis');
var casas = new Array('casas','homes','immo','case','imóveis','immobilien','Huizen','casas','casas','casas','imóveis');
var empleo = new Array('empleo','jobs','emploi','lavoro','emprego','Jobs','vacatures','empleo','empleo','empleo','emprego');

var buscar = new Array('Buscar','Search','Rechercher','Cercare','Pesquisar','Suchen','Zoeken','Buscar','Buscar','Buscar','Pesquisar');

function showHideTypeBox(state)
{
    frm = document.forms['gcode']; 

  if(frm.vertical.value == 1)
    frm.tipo.disabled = false;
    //document.getElementById('venta_alquiler').style.display="block";
  else
    frm.tipo.disabled = true;
    //document.getElementById('venta_alquiler').style.display="none";
}

function showHideTypeRoll(state)
{
    frm = document.forms['rollinfo']; 

  if(frm.vertical.value == 1)
    frm.tipo.disabled = false;
    //document.getElementById('venta_alquiler').style.display="block";
  else
    frm.tipo.disabled = true;
    //document.getElementById('venta_alquiler').style.display="none";
}

function generate_widget_code() { 

    frm = document.forms['rollinfo'];

    var roll ="";
    var print_tipo = venta[country-1];
    var country = frm.country.value;
    var vertical = frm.vertical.value;
    
    var type = frm.tipo.value;
    var num_ads = frm.n.value;
    var what = frm.what.value;
    
    if(type == 2)
        print_tipo = alquiler[country-1];
    site_data = eval('site_'+country).split(",");
    
    var url = site_data[vertical]; 
    
    roll = "<script type='text/javascript'>";
    if(vertical == 1)
        roll += "roll_title = '"+what+"';";
    else
        roll += "roll_title = '"+what+"';";

    roll += "roll_background_color = '#FFFFFF';";
    roll += "roll_width = '160px';";
    roll += "roll_text_font = '11px Arial, Helvetica, Sans serif';";
    roll += "roll_link_color = '#000000';";
    roll += "roll_border = '1px solid #000000';";
    roll += "roll_title_color = '#0000ff';";
    roll += "roll_text_color = '#999999';";
    roll += "</script>";
    if(vertical == 1)
        roll += "<script type='text/javascript' src='"+url+"/index.php/cod.roll/type."+type+"/what."+what+"/n."+num_ads+"'>";
    else
        roll += "<script type='text/javascript' src='"+url+"/index.php/cod.roll/what."+what+"/n."+num_ads+"'>";    
    roll += "<a href='"+url+"'> Trovit </a>";
    roll += "</script>";

    frm.my_roll.value= roll;
   
}

function generate_searchbox_code() {

    frm = document.forms['gcode'];

    var text ="";
    var country = frm.country.value;
    var vertical = frm.vertical.value;
        
    site_data = eval('site_'+country).split(",");

    if(vertical == 1)
    {
        txt_ejemplo = txt_ejemplo_casas[country-1];
        vertical_name = casas[country-1];
        cod = 'search_homes';
    }
    if(vertical == 2)
    {
        txt_ejemplo = txt_ejemplo_coches;
        vertical_name = coches[country-1];
        cod = 'search_cars';
    }
    if(vertical == 4)
    {
        txt_ejemplo = txt_ejemplo_empleo[country-1];
        vertical_name = empleo[country-1];
        cod = 'search_jobs';
        vertical -= 1;
    }    

    var url = site_data[vertical];
    
    if(frm.estilo.value == 1)
    {
       text += "<form action='"+url+"/index.php/cod."+cod+"' method='post' target='_blank'>";
       text += "<table style='BORDER-BOTTOM: #d8d7d8 1px solid; BORDER-LEFT: #d8d7d8 1px solid; BORDER-RIGHT: #d8d7d8 1px solid; BORDER-TOP: #d8d7d8 1px solid; font-family:arial; padding:5px;' cellspacing='0' style='font-family:arial'>";
       text += "<tr>";
       text += "<td colspan='2' valign='bottom' style='font-size:16px;color:#000'>";
       text += "<b>"+buscar[country-1]+" "+vertical_name+"</b>";
       text += "</td>";
       text += "<td align='right'>";
       text += "<a href='"+url+"' title='Trovit "+vertical_name+"'>";
       text += "<img align='left' alt='Trovit "+vertical_name+"' border='0' src='http://jobs.trovit.co.uk/images/global/logopowered2.png'>";
       text += "</a>";
       text += "</td>";
       text += "</tr>";
       text += "<tr>";
        if(vertical == 1)
        {
           text += "<td>";
           text += "<select name='type'>";
           text += "<option value='1' selected>"+venta[country-1]+"</option>";
           text += "<option value='2' >"+alquiler[country-1]+"</option>";
           text += "</select>";
           text += "</td>";
           text += "<td><input type='text' name='what' size='25'></td>";
        } else {
           text += "<td colspan='2'><input type='text' name='what' size='25'></td>";
        }
           text += "<td><input type='submit' value='"+buscar[country-1]+"'></td>";
           text += "</tr>";
           text += "<tr>";
        if(vertical == 1)
        {
           text += "<td>&nbsp;</td>";
           text += "<td valign='top' style='font-size:10px; color:#9c9a9c'>"+ejemplo[country-1]+":"+txt_ejemplo+"</td>";
        } else {
        
           text += "<td valign='top' style='font-size:10px; color:#9c9a9c'>"+ejemplo[country-1]+":"+txt_ejemplo+"</td>";
           text += "<td>&nbsp;</td>"; //se ha añadido este substituyendo el del if
        }
       text += "<td>&nbsp;</td>";
       text += "</tr></table></form>";
    } else {

       text += "<form action='"+url+"/index.php/cod."+cod+"' method='post' target='_blank'>";
       text += "<table style='BORDER-BOTTOM: #d8d7d8 1px solid; BORDER-LEFT: #d8d7d8 1px solid; BORDER-RIGHT: #d8d7d8 1px solid; BORDER-TOP: #d8d7d8 1px solid; font-family:arial; padding:5px;' cellspacing='0' style='font-family:arial'>";
       text += "<tr><td align='center' style='font-size:16px;color:#000;'><b>"+buscar[country-1]+" "+vertical_name+"</b></td></tr>";
        if(vertical == 1)
        {
           text += "<tr>";
           text += "<td align='center'>";
           text += "<select style='width:120px;' name='type'>";
           text += "<option value='1' selected>"+venta[country-1]+"</option>";
           text += "<option value='2' >"+alquiler[country-1]+"</option>";
           text += "</select>";
           text += "</td>";
           text += "</tr>";
        }
           text += "<tr><td align='center'><input type='text' style='width:116px;' name='what' size='15'></td></tr>";
           text += "<tr><td align='center' style='font-size:10px; color:#9c9a9c;'><em>"+ejemplo[country-1]+":"+txt_ejemplo+"</em></td></tr>";
           text += "<tr><td align='center'><input style='width:116px;' type='submit' value='"+buscar[country-1]+"'></tr>";
           text += "<tr>";
           text += "<td style='width:116px' align='center'>   ";
           text += "<a href='"+url+"' title='Trovit "+vertical_name+"'>";
           text += "<img alt='Trovit "+vertical_name+"' border='0' src='http://jobs.trovit.co.uk/images/global/logopowered2.png'>";
           text += "</a>";
           text += "</td>";
           text += "</tr>";
           text += "</table>";
           text += "</form>";
    }
    frm.code_result.value= text;
}
