﻿var no = 5;var hidesnowtime = 0;var snowdistance = "windowheight";var noimages = 3;var bubbleimages = new Array();
var ie4up = (document.all) ? 1 : 0;
var ns6up = (document.getElementById&&!document.all) ? 1 : 0;

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

// preload images
simplePreload("resources/sacouri.png", "resources/sacouri.png", "resources/sacouri.png");
bubbleimages[0] = "resources/sacouri.png";
bubbleimages[1] = "resources/camasi.png";
bubbleimages[2] = "resources/draperii.png";
bubbleimages[3] = "resources/rochii.png";
bubbleimages[4] = "resources/lenjerie.png";
bubbleimages[5] = "resources/sacouri.png";
bubbleimages[6] = "resources/camasi.png";
bubbleimages[7] = "resources/draperii.png";
bubbleimages[8] = "resources/rochii.png";
bubbleimages[9] = "resources/lenjerie.png";
// initialize bubbles
var dx, xp, yp, am, stx, sty,snowindex;
var i, doc_width = 1024, doc_height = 800; 

if (ns6up) {
  doc_width = self.innerWidth;
  doc_height = self.innerHeight;
} else if (ie4up) {
  doc_width = iecompattest().clientWidth;
  doc_height = iecompattest().clientHeight;
}
dx = new Array();xp = new Array();yp = new Array();am = new Array();stx = new Array();sty = new Array();snowindex = new Array();

for (i = 0; i < no; ++ i) {  
  dx[i] = 0;
  if (Math.floor(Math.random()*2) == 0)
  	xp[i] = doc_width-80-Math.random()*100;
  else
  	xp[i] = Math.random()*100;
  yp[i] = 600 - Math.random()*300;
  am[i] = Math.random()*10;
  stx[i] = 0.002 + Math.random()/15;
  sty[i] = -(0.03 + Math.random()/2);
  snowindex[i] = Math.floor(Math.random()*noimages);
	if (ie4up||ns6up) {
      document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+bubbleimages[i]+"' border=\"0\"><\/div>");
  }
}

function snowIE_NS6() {
  doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;
	doc_height=(window.innerHeight && snowdistance=="windowheight")? window.innerHeight : (ie4up && snowdistance=="windowheight")?  iecompattest().clientHeight : (ie4up && !window.opera && snowdistance=="pageheight")? iecompattest().scrollHeight : iecompattest().offsetHeight;
  for (i = 0; i < no; ++ i) {
    yp[i] += sty[i];
    if (yp[i] < -300) {
	  if (Math.floor(Math.random()*2) == 0)
		xp[i] = doc_width-80-Math.random()*100;
	  else
		xp[i] = Math.random()*100;
	  yp[i] = 600;
	  am[i] = Math.random()*20;
	  stx[i] = 0.002 + Math.random()/15;
	  sty[i] = -(0.03 + Math.random()/2);
	  snowindex[i] = Math.random()*noimages;
    }
    dx[i] += stx[i];
    document.getElementById("dot"+i).style.top=yp[i]+"px";
    document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+"px";  
  }
  snowtimer=setTimeout("snowIE_NS6()", 20);
}
function hidesnow(){
	if (window.snowtimer) clearTimeout(snowtimer)
	for (i=0; i<no; i++) document.getElementById("dot"+i).style.visibility="hidden"
}
if (ie4up||ns6up){
  snowIE_NS6();
	if (hidesnowtime>0)
	setTimeout("hidesnow()", hidesnowtime*1000)
}

function startBubbles()
{
	snowIE_NS6();
}

