/* PDF Embed 1.5 */
function write_embed_objects(pdf_name,url){
if(pdf_name!=""){
embed_pdf("./catpdf/"+pdf_name,url,"pdf_container");
}
document.getElementById("page_products").innerHTML='<iframe src="redirect.php" frameborder="0" class="prod_list_frame" scrolling="no"></iframe>';
return true;
};

function goto_prev_page(){
send_post_request("ajax.php","function=prev_page&args=");
return true;
};

function goto_next_page(){
send_post_request("ajax.php","function=next_page&args=");
return true;
};

function goto_this_page(){
var pag=document.getElementById("page_num_id").value;
send_post_request("ajax.php","function=show_this_page&args="+pag);
return true;
};

function show_product_list(){
var display=document.getElementById("prod_list_container").style.visibility;

if(display=="visible"){
document.getElementById("prod_list_container").style.visibility="hidden";
}
else{
document.getElementById("prod_list_container").style.visibility="visible";
}
};

function reload_at_page(pag){
document.location.href="catalogo.php?pag="+pag;
return;
};

/*## Pulisce un numero da ogni elmento stringa o carattere ##*/
function cleanInt(ref){
var ValidChars="0123456789";
var Char;
var sText=ref.value;
var output="";

for (i=0;i<sText.length;i++){
Char=sText.charAt(i);
if(ValidChars.indexOf(Char)!=-1){
output+=Char;
}
}

ref.value=output;
return;
};

/* Swap images */
function swap_image(ref){
var img=ref.src;

if(img.indexOf("_d")==-1){
var part1=ref.src.substring(0,ref.src.lastIndexOf("\."));
var part2=ref.src.substring(ref.src.lastIndexOf("\.")+1);

ref.src=part1+"_d."+part2;
}
else{
ref.src=img.replace("_d","");
}

return true;
};


function go_to_index(){
document.location.href="indice_catalogo.php";
return true;
};


function goto_cart(){
send_post_request("ajax.php","function=manage_cart_road");
return true;
};

/* Invia la ricerca a PHP e ridireziona */
function register_search(){
var needle=document.getElementById("search_id").value;

if(needle.length>=3){
send_post_request("ajax.php","function=register_search_needle&args="+encodeHex(needle));
}
else{
alert("La chiave di ricerca deve essere di almeno 3 caratteri...");
}
};

function go_to(url){
window.document.location.href=url;
return true;
}


function goto_register(){
if(confirm("Non siete connessi al sito!\r\nVolete effettuare la registrazione?")){
document.location.href="register.php";
}
return true;
};


var help=null;
function open_helpme(){
if(help!=null){
help.close();
}

help=window.open("help/help.html","helpme","height=700,width=700,top=50,left=50,resizable=yes,menubar=no,scrollbars=yes,toolbar=no,status=no");

help.focus();

return true;
};
var certpdf=null;
function open_cert(num){
if(certpdf!=null){
certpdf.close();
}

certpdf=window.open("certificati_pdf.php?cnum="+num,"certificato","height=700,width=700,top=50,left=50,resizable=yes,menubar=no,scrollbars=yes,toolbar=no,status=no");

certpdf.focus();

return true;
};
