var basesite='http://www.boatshop.it/';
var caricato=0;
var ajax=new sack();
function whenLoading(){
document.body.style.cursor='wait';
document.getElementById('gifload').style.display='';
}
function whenLoaded(){
document.body.style.cursor='default';
document.getElementById('gifload').style.display='none';
}
function salva_ricerca(){
ajax.setVar("nome",document.getElementById('nome').value);
if (document.getElementById('mail')) ajax.setVar("mail",document.getElementById('mail').value);
ajax.requestFile=basesite+'ajax/salva_ricerca.php';
ajax.method='post';
ajax.onLoading=whenLoading;
ajax.onLoaded=whenLoaded;
ajax.onCompletion=function(){
if(ajax.responseStatus[0]==200){
if(ajax.response=="ERROR"){
document.getElementById('txt_mail').className='obb';
}
else{
document.getElementById('salva').innerHTML=ajax.response;
}
}
};
ajax.runAJAX();
}
function linkto(url){
ajax.setVar("url",url);
ajax.requestFile=basesite+'ajax/links.php';
ajax.method='post';
ajax.runAJAX();
}
function del_salvato(txt){
if(confirm(txt)){
ajax.setVar("mail",document.getElementById('elimina_mail').value);
ajax.setVar("code",document.getElementById('elimina_code').value);
ajax.requestFile=basesite+'ajax/del_ricerca.php';
ajax.method='post';
ajax.onLoading=whenLoading;
ajax.onLoaded=whenLoaded;
ajax.onCompletion=function(){
if(ajax.responseStatus[0]==200){
var risp=ajax.response.split('#!#');
if(risp[0]=="OK"){
document.getElementById('txt_del_ricerca').className='';
}
else{
document.getElementById('txt_del_ricerca').className='obb';
}
document.getElementById('txt_del_ricerca').innerHTML=risp[1];
}
};
ajax.runAJAX();
}
}
function modifica_inserzione(){
ajax.setVar("mod_mail",document.getElementById('mod_mail').value);
ajax.setVar("ins_code",document.getElementById('ins_code').value);
ajax.requestFile=basesite+'ajax/modifica_inserzione.php';
ajax.method='post';
ajax.onLoading=whenLoading;
ajax.onLoaded=whenLoaded;
ajax.onCompletion=function(){
if(ajax.responseStatus[0]==200){
var risp=ajax.response.split('#!#');
if(risp[0]=="OK"){
document.getElementById('recupera_codice_mail').className='';
document.getElementById('txt_modifica_inserzione').className='';
window.location.href=risp[1];
}
else{
document.getElementById('recupera_codice_mail').className='';
document.getElementById('txt_modifica_inserzione').className='obb';
document.getElementById('txt_modifica_inserzione').innerHTML=risp[1];
}
}
};
ajax.runAJAX();
}
function recupera_codice(){
ajax.setVar("rec_mail",document.getElementById('rec_mail').value);
ajax.requestFile=basesite+'ajax/recupera_codice.php';
ajax.method='post';
ajax.onLoading=whenLoading;
ajax.onLoaded=whenLoaded;
ajax.onCompletion=function(){
if(ajax.responseStatus[0]==200){
var risp=ajax.response.split('#!#');
if(risp[0]=="OK"){
$('box_recupera_codice').hide();
$('box_recupera_inserzione').show();
document.getElementById('recupera_codice_mail').className='';
document.getElementById('txt_modifica_inserzione').className='obb';
document.getElementById('txt_modifica_inserzione').innerHTML=risp[1];
}
else{
document.getElementById('txt_recupera_codice').className='obb';
document.getElementById('txt_recupera_codice').innerHTML=risp[1];
}
}
};
ajax.runAJAX();
}
function show_ricerca(idtipo,pagina){
if(!caricato){
ajax.setVar("idtipo",idtipo);
ajax.setVar("pagina",pagina);
ajax.requestFile=basesite+'ajax/ricerca.php';
ajax.method='post';
ajax.onLoading=whenLoading;
ajax.onLoaded=whenLoaded;
ajax.onCompletion=function(){
if(ajax.responseStatus[0]==200){
document.getElementById('ricerca').innerHTML=ajax.response;
document.getElementById('ricerca').style.height='0px';
caricato=1;
mooeffect('ricerca','salva');
}
};
ajax.runAJAX();
}
else{
mooeffect('ricerca','salva');
}
}
function mooeffect(sorg,controllo){
if(document.getElementById('btn_'+controllo)){
if(document.getElementById('btn_'+controllo).className=='moonewattivo'){
document.getElementById('btn_'+controllo).className='moonew';
eval('moo'+controllo).toggle();
}
}
if(document.getElementById('btn_'+sorg)){
if(document.getElementById('btn_'+sorg).className=='moonewattivo'){
document.getElementById('btn_'+sorg).className='moonew';
}
else{
document.getElementById('btn_'+sorg).className='moonewattivo';
}
}
eval('moo'+sorg).toggle();
}
function chk_da_a(el){
var da=document.getElementById(el+'_da');
var a=document.getElementById(el+'_a');
if(da.value&&a.value){
if(eval(da.value)>eval(a.value)){
da.selectedIndex=0;
}
}
}
function view(n){
var el=document.getElementById(n);
if(el.style.display=='none'){
el.style.display='';
}
else{
el.style.display='none';
}
}
function confronto(val,txt){
var chkbox=document.getElementsByTagName('input');
var str=new Array();
for(i=0;i<chkbox.length;i++){
if(chkbox.item(i).checked&&chkbox.item(i).name!='cerca_nuovousato'){
str.push(chkbox.item(i).getAttribute("name").substring(2));
}
}
if(str.length>1){
document.getElementById('prova').onclick=function onclick(event){
var finestra_confronta=window.open(basesite+'boats-compare.php?id='+str.join("_"),'confronta','width=750, height=500, toolbar=0, statusbar=0, location=0, scrollbars=1');
finestra_confronta.focus();
}
}
else{
document.getElementById('prova').onclick=function onclick(event){
alert(txt);
}
}
}
function calcola_cambio(v_da,c_da,c_a,cosa){
document.getElementById(cosa).value=Math.round(v_da*(c_a/c_da)*100)/100;
}
