var mxImg = 10;
function RdImg() {
	var imgSel = Math.random();
	imgSel = Math.ceil(imgSel * mxImg);
	document.write('<img src="templates/5BCA6FFF-8EA8-46DF-8912-4AE39288CE24/images/homepage_' + imgSel + '.jpg" />');
}

var testObj;

function setOpacity(value) { 
	testObj.style.opacity = value/10;
	testObj.style.filter = 'alpha(opacity=' + value*10 + ')';
}

var timeOut;
var waitFor = 4;

function StartSwitchImage() {
	timeOut = setTimeout('SwitchImage()',waitFor*100);
}

var op = 10;
function SwitchImage() {
	var behind = document.getElementById("imageHp1").childNodes[1];
	var above = document.getElementById("imageHp2").childNodes[1];

	testObj = above;
	
	for (var i = 10; i > -1; i--) {
		setTimeout('setOpacity('+i+')',1000-(i*100));
	}
	
	setTimeout('SwitchAbove()',3000);
	setTimeout('SwitchImage()',(waitFor+3)*1000);
}

function SwitchAbove() {
	var behind = document.getElementById("imageHp1").childNodes[1];
	var above = document.getElementById("imageHp2").childNodes[1];

	above.src = behind.src;
	testObj = above;

	setOpacity(10);

	var nums = behind.src.lastIndexOf("_");
	var nume = behind.src.lastIndexOf(".");
	var current = behind.src.substring(nums+1,nume);

	if(current<mxImg)
		current++;
	else
		current=1;

	behind.src = 'templates/5BCA6FFF-8EA8-46DF-8912-4AE39288CE24/images/homepage_' + current + '.jpg';
}

function StyleCalendar()
{//
	
}