// CODED BY DJRAVINE
// DATE: 26/04/2009


//AD SETTINGS
var myAdsURL=new Array(4);
	myAdsURL[0]="/colohosting.php"; // Edit this with the 1st ads URL
	myAdsURL[1]="/managedsupport.php"; // Edit this with the 2nd ads URL
	myAdsURL[2]="/dedhosting.php"; // Edit this with the 3rd ads URL
	myAdsURL[3]="/custom.php"; // Edit this with the 4th ads URL

// LEAVE THESE ALONE
var MyAdsCurrent=0;
var myAdsLoc="images/splash/";
var myAds=new Array(4);
	myAds[0]="splash1.png";
	myAds[1]="splash2.png";
	myAds[2]="splash3.png";
	myAds[3]="splash4.png";
var myAdsButton1=new Array(4);
	myAdsButton1[0]="buttons_1_over.png";
	myAdsButton1[1]="buttons_1.png";
	myAdsButton1[2]="buttons_1.png";
	myAdsButton1[3]="buttons_1.png";
var myAdsButton2=new Array(4);
	myAdsButton2[0]="buttons_2.png";
	myAdsButton2[1]="buttons_2_over.png";
	myAdsButton2[2]="buttons_2.png";
	myAdsButton2[3]="buttons_2.png";
var myAdsButton3=new Array(4);
	myAdsButton3[0]="buttons_3.png";
	myAdsButton3[1]="buttons_3.png";
	myAdsButton3[2]="buttons_3_over.png";
	myAdsButton3[3]="buttons_3.png";
var myAdsButton4=new Array(4);
	myAdsButton4[0]="buttons_4.png";
	myAdsButton4[1]="buttons_4.png";
	myAdsButton4[2]="buttons_4.png";
	myAdsButton4[3]="buttons_4_over.png";
var myAdsImages=new Array(4);
	myAdsImages[0] = new Image(); 
	myAdsImages[1] = new Image();
	myAdsImages[2] = new Image();
	myAdsImages[3] = new Image();
	myAdsImages[4] = new Image();
	myAdsImages[5] = new Image();
	myAdsImages[6] = new Image();
	myAdsImages[7] = new Image();
	myAdsImages[8] = new Image();
	myAdsImages[9] = new Image();
	myAdsImages[10] = new Image();
	myAdsImages[11] = new Image();

// TIMER SETTINGS

var TimeForAdSwitch=7; // Set the length of the time for ad switching, in seconds
var secs=TimeForAdSwitch;
var timerID = null;
var timerRunning = false;
var delay = 1000;
var timedelay = secs*delay;

// FADE FUNCTIONS

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function blendimage(divid, imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    
    //set the current image as background
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
    
    //make image transparent
    changeOpac(0, imageid);
    
    //make new image
    document.getElementById(imageid).src = imagefile;

    //fade in image
    for(i = 0; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
} 

// TIMER FUNCTIONS

function InitializeTimer() {
    StopTheClock();
    StartTheTimer();
}

function StopTheClock() {
    if(timerRunning){ clearTimeout(timerID); }
    timerRunning = false;
}

function StartTheTimer() {
    if (secs==0) {
        StopTheClock();
		if (MyAdsCurrent==3) {
			MyAdsCurrent=0;
		} else {
			MyAdsCurrent=MyAdsCurrent+1;
		}
		//alert(MyAdsCurrent);
		select(MyAdsCurrent);
		secs=TimeForAdSwitch;		
    	StartTheTimer();
    } else {
        self.status = secs;
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
}

// AD FUNCTIONS

function preloader() {
	myAdsImages[0].src = myAdsLoc+myAds[0];
	myAdsImages[1].src = myAdsLoc+myAds[1];
	myAdsImages[2].src = myAdsLoc+myAds[2];
	myAdsImages[3].src = myAdsLoc+myAds[3];
	myAdsImages[4].src = myAdsLoc+myAdsButton1[0];
	myAdsImages[5].src = myAdsLoc+myAdsButton2[1];
	myAdsImages[6].src = myAdsLoc+myAdsButton3[2];
	myAdsImages[7].src = myAdsLoc+myAdsButton4[3];
	myAdsImages[8].src = myAdsLoc+myAdsButton1[1];
	myAdsImages[9].src = myAdsLoc+myAdsButton2[0];
	myAdsImages[10].src = myAdsLoc+myAdsButton3[0];
	myAdsImages[11].src = myAdsLoc+myAdsButton4[0];
}

function iClick(img_num) {
	StopTheClock();
	select(img_num);
}

function select(img_num) {
	blendimage('splashbody','adsImage', myAdsLoc+myAds[img_num], 1000);
	//document.getElementById('splashbody').style.background = 'url('+myAdsLoc+myAds[img_num]+')';
	//alert('url('+myAdsLoc+myAds[img_num]+')');
	document.getElementById('adsLink').href = myAdsURL[img_num];
	//alert(myAdsURL[img_num]);
	document.getElementById('s1').style.background = 'url('+myAdsLoc+myAdsButton1[img_num]+')';
	document.getElementById('s2').style.background = 'url('+myAdsLoc+myAdsButton2[img_num]+')';
	document.getElementById('s3').style.background = 'url('+myAdsLoc+myAdsButton3[img_num]+')'; 
	document.getElementById('s4').style.background = 'url('+myAdsLoc+myAdsButton4[img_num]+')'; 
	//alert('url('+myAdsButton1[img_num]+')');
}

// MAIN LOADER

function load() {
	preloader();
	select(MyAdsCurrent);
	InitializeTimer();
	
}
