function Twi(){
this.marque = new Array;
this.block = new Array;
}
function Twimarquediv (id,id_offre){
var options = {
id : 'tw_'+id,
div_id : id,
id_offre : id_offre,
w : '628px',
h : '145px'
}
this.setOption(options);
this.Timer = "";
}
function Twblock(options){
this.setOption(options);
}
/** Fonction Utile **/
Tw_fonction_essai = function (x,h){
var returnValue;
for (var i = 0, length = arguments.length; i < length; i++) {
var lambda = arguments[i];
try {
returnValue = lambda();
break;
} catch (e) { }
}
return returnValue;
}
/** Marque blanche **/
Twi.prototype.marqueInit = function (id,id_offre){
if(this.marque[id]){
return this.marque[id];
}
this.marque[id] = new Twimarquediv(id,id_offre);
return this.marque[id];
}
Twi.prototype.marqueGet = function (id){
if(this.marque[id]){
return this.marque[id];
}
return false;
}
Twimarquediv.prototype.setOption = function (options){
this.options = {
id : 'tw_',
div_id : '',
id_offre : '',
w : '628px',
h : '145px'
}
for (var property in options){
this.options[property] = options[property];
}
}
Twimarquediv.prototype.setParam = function (options){
for (var property in options){
this.options[property] = options[property];
}
}
Twimarquediv.prototype.setSize = function (x,h){
this.options.w = x;
this.options.h = h;
if(document.getElementById(this.options.id)){
document.getElementById(this.options.id).style.width = x;
document.getElementById(this.options.id).style.height = h;
document.getElementById(this.options.id+"_f").style.width = x;
document.getElementById(this.options.id+"_f").style.height = h;
}
}
Twimarquediv.prototype.afficher = function (){
if(document.getElementById(this.options.id)){
return false;
}else{
var pop_div = document.createElement('div');
pop_div.id = this.options.id;
pop_div.name = this.options.id;
pop_div.style.width = this.options.w;
pop_div.style.height = this.options.h;
pop_div.innerHTML = '';
var form_cache = document.createElement('form');
form_cache.method='POST';
form_cache.acceptCharset='utf-8';
form_cache.target= this.options.id+"_f";
form_cache.action= 'http://www.twimmo.com/template/refleximmo/phenix/enr_offre.php?id_offre='+this.options.id_offre+'&ct='+this.options.div_id;
var tab_champ=new Array();
tab_champ.push('');
tab_champ.push('');
tab_champ.push('');
form_cache.innerHTML = tab_champ.join('');
pop_div.appendChild(form_cache);
document.getElementById(this.options.div_id).appendChild(pop_div);
form_cache.submit();
}
}
/** PARTIE BLOCK **/
Twi.prototype.blockInit = function (id,option){
if(this.block[id]){
return this.block[id];
}
this.block[id] = new Twblock(option);
return this.block[id];
}
Twi.prototype.blockGet = function (id){
if(this.blockInit[id]){
return this.blockInit[id];
}
return false;
}
Twblock.prototype.setOption = function (options){
this.options = {
url : 'http://www.twimmo.com/template/refleximmo/scriptjs/block/',
typeblock : '',
data : '',
id_div : '',
page : ''
}
for (var property in options){
this.options[property] = options[property];
}
}
Twblock.prototype.setParam = function (options){
for (var property in options){
this.options[property] = options[property];
}
}
Twblock.prototype.traitementdata = function (data){
var aux;
if (typeof data == "string"){
if (aux != ""){
aux = "&";
}
aux += data;
}else{
if (typeof data != "object"){
return data;
}else{
for (j in data){
if (aux = ""){
aux += "&";
}
aux += j + "=" + escape(data[j]);
}
}
}
return aux;
}
Twblock.prototype.get = function (options){
if(options){
this.setParam(options);
}
var chiffreRamdon = Math.floor(Math.random()*99999999999);
data = this.traitementdata(this.options.data);
data = escape(this.options.typeblock)+"/"+this.options.page+".php?id_div="+escape(this.options.id_div)+"&"+data;
fileref=document.createElement('script');
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", this.options.url+data+'&cb='+chiffreRamdon);
document.getElementsByTagName("head").item(0).appendChild(fileref);
}
var options = {};