
var ScrollImgId;

function Scroll(img, id,speed){

this.Intervalo  = null;
this.Started = false;
this.cssBGImage=new Image();
this.cssBGImage.src=img;
if(speed) this.speed = speed;
else this.speed = 25;
ScrollImgId = id;

}

Scroll.prototype.Start = function() {
if(!this.Started){
window.cssMaxWidth=  this.cssBGImage.width;
window.cssXPos=0;
this.Started = true;
};
this.Intervalo = setInterval(this.Move,this.speed);
}
Scroll.prototype.Stop = function(){
if(this.Intervalo){
clearInterval(this.Intervalo);
this.Intervalo = null;
}
};

Scroll.prototype.Move = function() {
window.cssXPos=window.cssXPos+1;
if (window.cssXPos>=window.cssMaxWidth) {
window.cssXPos=0;
}

var toMove=document.getElementById(ScrollImgId);
toMove.style.backgroundPosition=window.cssXPos+"px 0px";

};


function ResizeFrame(target,mw) {
var sw = parseInt(window.screen.availWidth);
var w = Math.floor(sw * mw/100);
if(w < 480) w = 480;
if(w > 640) w = 640;
var h = Math.floor(w * 3/4);

var Code = '<div style="text-align:center" ><iframe class="shadow rounded"  id="Youtube"  ' + ' width="' + (w).toString() +'"  height="' + (h).toString() + '" '
+  ' src=' +  target  + ' frameborder="0" allowfullscreen></div>'
+ ' </iframe>';
return(Code);
}

function ResizeVideo(target,  alternative,mw) {
var sw = parseInt(window.screen.availWidth);
var w = Math.floor(sw * (mw/100));
if(w < 300) w = 200;
var h = Math.floor(w * 3/4);

var Code = '<video poster="../imagens/Casas-Bahia.png" id="VideoElem" style="margin-left:auto;margin-right:auto;" "' + ' width="' + (w).toString() +'"  height="' + (h).toString() + '" '
+  ' src=' +  target  + ' controls>'
+ '<iframe width="' + (w).toString() + '" height="' +  (h).toString()   +'" src="http://www.youtube.com/embed/9VyxVVdlzpQ" frameborder="0" allowfullscreen></iframe>'
+ ' </video>';
return(Code);
}

function ResizeEmbed(target,mw) {

var Code = '<embed style="float:left;"   quality="high" wmode="transparent" bgcolor="#FFFFFF" width="200"  height="300" '
+  ' src=' +  target  + ' allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">'
+ ' </embed>';
return(Code);
}


var fadeDone = true;

function initImage(Id) {
if(!fadeDone) return;
  imageId = Id;
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  //image.style.visibility = 'visible';
  fadeDone = false;
  fadeIn(imageId,0);
}


function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}


function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")",100);
    }
    else fadeDone = true;
  }
}



var Imagens = new Array (
"http://www.zeusbox.com/thumbs/hot_sexy_legs_60014_b12_123_761lo-t2.jpg",
"http://www.zeusbox.com/thumbs/candice_swanepoel_493lo_wallpaper_f042011-t2.jpg",
"http://www.zeusbox.com/thumbs/candice_swanepoel_39128-t2.jpg","http://www.zeusbox.com/thumbs/candice_swanepoel_2010_candice_3-t2.jpg","http://www.zeusbox.com/thumbs/candice_swanepoel_img_4b7e569c7da70-t2.jpg","http://www.zeusbox.com/thumbs/candice_swanepoel_38928-t2.jpg",
"http://www.zeusbox.com/thumbs/beautiful_girl_wallpaper_f222011-t2.jpg",
"http://www.zeusbox.com/thumbs/elishaare_zeusbox_com_j072011-t2.jpg",
"http://www.zeusbox.com/thumbs/hot_girls_wallpapers_1110_0091-t2.jpg",
"http://www.zeusbox.com/thumbs/lips_lovely_model_nice_photography_pretty_red-t2.jpg",
"http://www.zeusbox.com/thumbs/best_sexy_and_hot_wallpapers_0504_03-t2.jpg",

"http://www.zeusbox.com/thumbs/2011_08_17_caroline_francischini_3587kdx_zeusbox_com_i202011-t2.jpg"
);
var ImgLen = Imagens.length;
var SexyWallpaper = 0;
function NextImage(){
if(fadeDone) SexyWallpaper = Math.floor(Math.random()* ImgLen);
return(Imagens[SexyWallpaper]);

}
function CloseYoutube(){
var ymusica = document.getElementById("YPlayer");
YoutubeLoaded = false;
ymusica.style.display = "none";
ymusica.innerHTML =  
'<a href="javascript:;" onclick="OpenYoutube()"><img id="YLogo" src="imagens/magnatune.jpg" width="20%" border="0"   title="Clique para ouvir Música" onmouseout="initImage(\'YLogo\')"></a>';
ymusica.style.display = "inline";
}

var YoutubeLoaded = false;

function OpenYoutube(){
var ymusica = document.getElementById("YPlayer");
if(MagLoaded)CloseMagnatune();
if(JamendoLoaded) CloseJamendo();
var ctime = new Date();
var index=0;
var hora = ctime.getHours();
YoutubeLoaded = true;
if(hora >= 20) index = 1;
if(hora <= 12) index =  2;
ymusica.innerHTML =  ResizeFrame(yt[index],30) +

'<br><input  type="button" value="FECHAR" onclick="CloseYoutube()">';
//OpenJamendo();
}  
var JamendoLoaded = false;

function OpenJamendo(){
if(JamendoLoaded) {

CloseJamendo(); return;
}
if(YoutubeLoaded) CloseYoutube();
if(MagLoaded) CloseMagnatune();
JamendoLoaded = true;
var musica = document.getElementById("JPlayer");

if(musica == null) {
alert("Jplayer nao definido");
return;
}

var ctime = new Date();
var index=0;
var hora = ctime.getHours();
if(hora >= 20) index = 1;
if(hora <= 12) index =  2;
 musica.innerHTML = ResizeEmbed(jp[index],12);

}


function CloseJamendo(){
var musica = document.getElementById("JPlayer");
JamendoLoaded = false;
musica.style.display = "none";
musica.innerHTML =" ";
musica.style.display = "inline";
}
 

function LoadMagnatune(){
if(YoutubeLoaded) CloseYoutube();
if(JamendoLoaded) CloseJamendo();
document.getElementById("MagnatuneTitle").innerHTML = mp[0];
document.getElementById("MagnatunePlayer").style.display = "inline";
document.getElementById("MagnatunePlayer").innerHTML = mp[1];
document.getElementById("Description").innerHTML = mp[2];

}

function CloseMagnatune(){
MagLoaded = false;
var span = document.getElementById("MagnatunePlayer");
span.style.display = "none";
span.innerHTML = "";
}
var MagLoaded = false;
function SwitchMagnatune(){
if(MagLoaded){
MagLoaded = false;
 CloseMagnatune();
}
else{

MagLoaded = true;
LoadMagnatune();
}

}


var PlayStop = function(Id,Func,Interv){
this.id = Id;
this.func = Func;
this.started = false;
this.Intervalo =null;
this.time = Interv;
};

PlayStop.prototype.Toggle = function(){
if(this.started == true){
this.started = false;
document.getElementById(this.id).value = "Play";
clearInterval(this.Intervalo);
this.Intervalo = null;
}
else {
this.started = true;
document.getElementById(this.id).value = "Stop";
this.Intervalo = setInterval(this.func,this.time);
}
};


 




