﻿/*CREATE TICKERS*/
/*160x600*/
function createJobatTicker160NL(divname, source, term, xml) {
    var query = GetQuery(source, term, xml);

    var url = 'http://www.jobat.be/ticker/ticker_160x600_nl.html' + query;

    var html = '<iframe src="' + url + '" scrolling="no" frameborder="0" vspace="0" marginwidth="0" marginheight="0" hspace="0" width="160px" height="600px">';
    var divticker = document.getElementById(divname);

    if (divticker)
        divticker.innerHTML = html;
}

function createJobatTicker160FR(divname, source, term, xml) {
    var query = GetQuery(source, term, xml);

    var url = 'http://www.jobat.be/ticker/ticker_160x600_fr.html' + query;

    var html = '<iframe src="' + url + '" scrolling="no" frameborder="0" vspace="0" marginwidth="0" marginheight="0" hspace="0" width="160px" height="600px">';
    var divticker = document.getElementById(divname);

    if (divticker)
        divticker.innerHTML = html;
}

/*362x200*/
function createJobatTicker362x200NL(divname, source, term, xml) {
    var query = GetQuery(source, term, xml);

    var url = 'http://www.jobat.be/ticker/ticker_362x200_nl.html' + query;

    var html = '<iframe src="' + url + '" scrolling="no" frameborder="0" vspace="0" marginwidth="0" marginheight="0" hspace="0" width="362px" height="200px">';
    var divticker = document.getElementById(divname);

    if (divticker)
        divticker.innerHTML = html;
}

function createJobatTicker362x200FR(divname, source, term, xml) {
    var query = GetQuery(source, term, xml);

    var url = 'http://www.jobat.be/ticker/ticker_362x200_fr.html' + query;

    var html = '<iframe src="' + url + '" scrolling="no" frameborder="0" vspace="0" marginwidth="0" marginheight="0" hspace="0" width="362px" height="200px">';
    var divticker = document.getElementById(divname);

    if (divticker)
        divticker.innerHTML = html;
}


/*177x255*/
function createJobatTicker177x255NL(divname, source, term, xml) {
    var query = GetQuery(source, term, xml);

    var url = 'http://www.jobat.be/ticker/ticker_177x255_nl.html' + query;

    var html = '<iframe src="' + url + '" scrolling="no" frameborder="0" vspace="0" marginwidth="0" marginheight="0" hspace="0" width="177px" height="255px">';
    var divticker = document.getElementById(divname);

    if (divticker)
        divticker.innerHTML = html;
}

function createJobatTicker177x255FR(divname, source, term, xml) {
    var query = GetQuery(source, term, xml);

    var url = 'http://www.jobat.be/ticker/ticker_177x255_fr.html' + query;

    var html = '<iframe src="' + url + '" scrolling="no" frameborder="0" vspace="0" marginwidth="0" marginheight="0" hspace="0" width="177px" height="255px">';
    var divticker = document.getElementById(divname);

    if (divticker)
        divticker.innerHTML = html;
}

/*211x300*/
function createJobatTicker211x300NL(divname, source, term, xml) {
    var query = GetQuery(source, term, xml);

    var url = 'http://www.jobat.be/ticker/ticker_211x300_nl.html' + query;

    var html = '<iframe src="' + url + '" scrolling="no" frameborder="0" vspace="0" marginwidth="0" marginheight="0" hspace="0" width="211px" height="300px">';
    var divticker = document.getElementById(divname);

    if (divticker)
        divticker.innerHTML = html;
}

function createJobatTicker211x300FR(divname, source, term, xml) {
    var query = GetQuery(source, term, xml);

    var url = 'http://www.jobat.be/ticker/ticker_211x300_fr.html' + query;

    var html = '<iframe src="' + url + '" scrolling="no" frameborder="0" vspace="0" marginwidth="0" marginheight="0" hspace="0" width="211px" height="300px">';
    var divticker = document.getElementById(divname);

    if (divticker)
        divticker.innerHTML = html;
}

/*300x430*/
function createJobatTicker300x430NL(divname, source, term, xml) {
    var query = GetQuery(source, term, xml);

    var url = 'http://www.jobat.be/ticker/ticker_300x430_nl.html' + query;

    var html = '<iframe src="' + url + '" scrolling="no" frameborder="0" vspace="0" marginwidth="0" marginheight="0" hspace="0" width="300px" height="430px">';
    var divticker = document.getElementById(divname);

    if (divticker)
        divticker.innerHTML = html;
}

function createJobatTicker300x430FR(divname, source, term, xml) {
    var query = GetQuery(source, term, xml);

    var url = 'http://www.jobat.be/ticker/ticker_300x430_fr.html' + query;

    var html = '<iframe src="' + url + '" scrolling="no" frameborder="0" vspace="0" marginwidth="0" marginheight="0" hspace="0" width="300px" height="430px">';
    var divticker = document.getElementById(divname);

    if (divticker)
        divticker.innerHTML = html;
}

/*General Functions*/

function GetQuery(source, term, xml) {
    var query = '?source={0}&term={1}&xml={2}';

    if (source && source != 'undefined') {
        query = query.replace('{0}', source);
    }
    else {
        query = query.replace('{0}', '');
    }

    if (term && term != 'undefined') {
        query = query.replace('{1}', term);
    }
    else {
        query = query.replace('{1}', '');
    }

    if (xml && xml != 'undefined') {
        query = query.replace('{2}', xml);
    }
    else {
        query = query.replace('{2}', '');
    }


    return query;
}