// Utilities functions
/*
// Script Preview
document.write('<div id="scriptpreview" style="visibility:hidden; background-color:#eeffff; layer-background-color:#eeffff;"><\/div>');

function closeDiv(){
    var div = document.getElementById('scriptpreview');
    div.style.visibility    = 'hidden';
}

function showDiv(sLink,w,h){
    var div = document.getElementById('scriptpreview');

    var html                   = "<html><body><center><div style:'color:#ffffff'><a href='javascript:closeDiv()'>CHIUDI ANTEPRIMA</a></div></center>";
        html                  += "<iframe src='" +sLink +"' width='" +w +"' height='" +h +"'></iframe>";
        html                  += "</body></html>";
    div.innerHTML              = html;

    // Size
    div.style.top              = (cursor.y-(h/2)) +"px";
    div.style.left             = (cursor.x-(w/2)) +"px";
    div.style.width            = w+"px";
    div.style.height           = h+"px";
    div.style.position         = 'absolute'; // Over the text

    // Color
    div.style.border           = '#000000 1px solid';

    // Show
    div.style.visibility       = 'visible';

    // Scrolling
    document.onmousemove       = scrollDiv;
    document.onmouseup         = descrollDiv;
}

function scrollDiv(e) {
    getXY(e);

    var div = document.getElementById('scriptpreview');
    div.style.top              = (cursor.y      ) +"px";
    div.style.left             = (cursor.x      ) +"px";
}

function descrollDiv(e) {
    document.onmousemove       = getXY;
    document.onmouseup         = null;
}

// Capture mouse position
window.onload = init;
function init() {
  if (window.Event) {
    document.captureEvents(Event.MOUSEMOVE);
  }
  document.onmousemove = getXY;
}

var cursor = {x:0, y:0};
function getXY(e) {
    e = e || window.event;
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX +
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY +
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
}
*/

function URLEncode(sStr){
    return escape(sStr).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27');
}

function showJS(js,k,p,g){
    Stamp = new Date();
    title = "" +Stamp.getMinutes() +"_" +Stamp.getSeconds();

    oWin = window.open("jshtml.jsp?p=" +URLEncode(p) +"&k=" +URLEncode(k) +"&g=" +URLEncode(g) +"&js=" +URLEncode(js), title ,"status=0,width=180,height=600");
    //oWin.document.write(sLink);
    oWin.focus();
}

function showJSH(js,k,p,g){
    Stamp = new Date();
    title = "" +Stamp.getMinutes() +"_" +Stamp.getSeconds();

    //oWin = window.open("", title ,"status=0,width=600,height=100");
    oWin = window.open("jshtml.jsp?p=" +URLEncode(p) +"&k=" +URLEncode(k) +"&g=" +URLEncode(g) +"&js=" +URLEncode(js) +"&v=m", title ,"status=0,width=600,height=100");
    //oWin.document.write(sLink);
    oWin.focus();
}

function showRSS(sLink){
    oWin = window.open(sLink, 'XML_RSS');
    oWin.focus();
}

// JC functions
function setJCChannel(s,p){
    //s = s.replace(/^[\sÿ]+|[\sÿ]+$/g,'');
    string2show  = '<';
    string2show += 'script language=Javascript';
    string2show += ' src="http://www.jobcrawler.it/jc/jsjobcrawler.jsp?k=' +URLEncode(s) +'&paese=' +p +'"';
    string2show += '>';
    string2show += '</script';
    string2show += '>';
    document.jc.strMLJC.value = string2show;
}

function setRSSJCChannel(s,p){
    //s = s.replace(/^[\sÿ]+|[\sÿ]+$/g,'');
    document.jcrss.strMLRSS.value = 'http://www.jobcrawler.it/jc/rss_lastinsert.jsp?k=' +URLEncode(s) +'&paese=' +p;
}

// NC functions
function setNCChannel(s,p) {
    //s = s.replace(/^[\sÿ]+|[\sÿ]+$/g,'');
    string2show  = '<';
    string2show += 'script language=Javascript';
    string2show += ' src="http://www.newscrawler.it/nc/jsnewscrawler.jsp?k=' +URLEncode(s) +'&g=' +p +'"';
    string2show += '>';
    string2show += '</script';
    string2show += '>';
    document.nc.strMLJS.value = string2show;
}

function setRSSNCChannel(s,p) {
    //s = s.replace(/^[\sÿ]+|[\sÿ]+$/g,'');
    document.ncrss.strMLRSS.value = 'http://www.newscrawler.it/nc/rss_lastinsert.jsp?k=' +URLEncode(s) +'&g=' +p;
}

// HC functions
function setRSSHCChannel(s) {
    //s = s.replace(/^[\sÿ]+|[\sÿ]+$/g,'');
    document.hcrss.strMLRSS.value = 'http://casa.newscrawler.it/rss_lastinsert.jsp?k=' +URLEncode(s);
}

// CV functions
function setRSSCVChannel(s) {
    //s = s.replace(/^[\sÿ]+|[\sÿ]+$/g,'');
    document.cvrss.strMLRSS.value = 'http://www.cvcrawler.it/rss_lastinsert.jsp?k=' +URLEncode(s);
}

// AC functions
function setRSSACChannel(s) {
    //s = s.replace(/^[\sÿ]+|[\sÿ]+$/g,'');
    document.acrss.strMLRSS.value = 'http://auto.newscrawler.it/rss_lastinsert.jsp?k=' +URLEncode(s);
}

function clickJCKit(){ document.getElementById('maintab').tabber.tabShow(5); }
function clickJCRSS(){ document.getElementById('jctab'  ).tabber.tabShow(3); }
function clickHCRSS(){ document.getElementById('hctab'  ).tabber.tabShow(1); }
function clickNCRSS(){ document.getElementById('nctab'  ).tabber.tabShow(2); }
function clickCVRSS(){ document.getElementById('cvtab'  ).tabber.tabShow(1); }
function clickACRSS(){ document.getElementById('actab'  ).tabber.tabShow(1); }
