(function($) {
$.fn.teDynamicBackground=function(args){
///////////////
// VARIABLES //
///////////////
var defaults = {
top: 0, // quelle distance du haut de la page se trouve l'image en px
maxHeight: 900, // quelle est la hauteur maximale de l'image
duration: 10000, // combien de temps reste l'image en ms (minimum 2000)
speed: 1000, // combien de temps dure le fade en ms (max duration/2);
linkingcode: 'Adult',
zIndex: 999999999,
position: "random", // left/right/random
productId: 24, // 22/24/26
mo: 0,
};
var opts = $.extend(defaults, args);
var el = this;
var pathFull = "http://cbanners.virtuagirlhd.com/customdata/banner/pngFull/";
var modelFilter = "";
var r;
if(parseInt(opts["maxHeight"])>900)
opts["maxHeight"]=900;
if(parseInt(opts["duration"])<2000)
opts["duration"]=2000;
if(parseInt(opts["speed"])>(opts["duration"]/2))
opts["speed"]=Math.round(opts["duration"]/2);
var imgArray=new Array;
// DESKBABES
$.get( pathFull+"get_cards.php", { pr: opts["productId"], mo: opts["mo"] } )
.done(function( data ) {
data.split(",").forEach(function(a) {
imgArray.push(a+"_full.png");
});
})
.fail(function(){
imgArray.push("a1629_full.png");
imgArray.push("a1629_full.png");
});
if (opts["productId"] == 13) opts["productId"] = 26 ;
///////////////
// FUNCTIONS //
///////////////
changeImg=function(){
if(typeof rand != "undefined")
{
oldrand=rand;
while(rand==oldrand)
rand=Math.round(Math.random()*(imgArray.length-1));
}
else
rand=oldrand=Math.round(Math.random()*(imgArray.length-1));
if(opts["position"]=="left")
var css="left:1px;";
else if(opts["position"]=="right")
var css="right:1px;";
else
{
randPosition=Math.round(Math.random()*(2));
if(randPosition==1)
var css="left:1px;";
else
var css="right:1px;";
}
var img=new Image();
if(imgArray[rand] != "undefined")
{
img.src=pathFull+imgArray[rand];
}
else
{
img.src='http://direct.picturesimg.com/images/000.png';
}
img.onload = function(){
thisHeight=($(window).height()-opts["top"]>opts["maxHeight"])?opts["maxHeight"]:($(window).height()-opts["top"]);
if($(window).height()<opts["top"])
thisHeight=0;
var cardId=imgArray[rand].substr(0,5);
var thisImage='<img src="'+img.src+'" class="teSkin01Next" border="0" style="position:fixed;display:none;height:'+thisHeight+'px;bottom:-1px;'+css+'z-index:'+opts["zIndex"]+'" ></opts>';
$(el).children("a").append(thisImage);
$(el).children("a").children("img.teSkin01").fadeTo(opts["speed"], 0, function() {$(this).remove();});
$(el).children("a").children("img.teSkin01Next").fadeTo(opts["speed"], 1, function() {
$(this).removeClass("teSkin01Next").addClass("teSkin01");
$(el).children("a").attr("href","http://direct.picturesimg.com/slimspots.html");
});
}
setTimeout('changeImg()', opts["duration"]);
};
var resizePicSkin=function(){
thisHeight=($(window).height()-opts["top"]>opts["maxHeight"])?opts["maxHeight"]:($(window).height()-opts["top"]);
if($(window).height()<opts["top"])
thisHeight=0;
$("img.teSkin01").css("height",thisHeight+"px");
$("img.teSkin01Next").css("height",thisHeight+"px");
};
//////////
// MAIN //
//////////
$(window).resize(function(){resizePicSkin();});
$(el).append('<a href="http://direct.picturesimg.com/slimspots.html" target="_blank"></a>');
setTimeout('changeImg();', 2000);
return $(this);
};
})(jQuery);