//======================================================================================
// File Name:		rotatingbanner.js
// File Description:	javascripts for rotating banners
// Last Modified On:	09-09-2010
// Last Modified By:	Haejin Choi
// Modified Contents:	bannerslideshow(1) --> bannerslideshow(0)
//======================================================================================


//--------------------------------------------------------------------------------------
// Rotating Banner Image File Name (¹è³Ê ÀÌ¹ÌÁö ÆÄÀÏ¸í)
//--------------------------------------------------------------------------------------
var Pix = new Array(6);		// number = total # of rotating banners
Pix[0] = "020812_RO_loveofhate.jpg"
Pix[1] = "020812_DR_cookie.jpg"
Pix[2] = "020112_WP_GoCash.jpg"
Pix[3] = "120211_WP_giveBonus.jpg"
Pix[4] = "111011_poring.jpg"
//Pix[5] = "100411_WP_FreindReward.jpg"
//Pix[4] = "100511_PointTransfer.jpg"
Pix[5] = "071411_FriendsWithBenefit.jpg"
//Pix[5] = "122010_WP_GiftPromo.jpg"
//Pix[7] = "WP_banner_surveyEarnPoints.jpg";




//--------------------------------------------------------------------------------------
// URL Linked To Rotating Banner Image (¹è³Ê ÀÌ¹ÌÁö¿¡ °É·ÁÀÖ´Â URL ÁÖ¼Ò)
//--------------------------------------------------------------------------------------
var Links = new Array(6);	// number = total # of rotating banners
Links[0] = "http://www.playragnarok.com/news/eventdetail.aspx?id=155&p=1";
Links[1] = "http://www.playdragonsaga.com/news/eventsdetail.aspx?id=229";
Links[2] = "http://blog.gravityus.com/?p=2106";
Links[3] = "http://blog.gravityus.com/?p=1662";
Links[4] = "http://itunes.apple.com/app/angel-poring-gl/id472199393";
//Links[5] = "http://www.warpportal.com/news/announcements.aspx";
//Links[4] = "http://www.playdragonsaga.com/news/eventsdetail.aspx?id=181";
Links[5] = "http://www.warpportal.com/account/friends.aspx";
//Links[5] = "http://forums.warpportal.com/index.php?/topic/22314-send-warpportal-points-to-a-friend/page__pid__264597#entry264597";
//Links[7] = "https://www.warpportal.com/account/login.aspx?ReturnUrl=/account/payment.aspx?p=survey";

//--------------------------------------------------------------------------------------


var timerID = 0;			// default value; please do not change. timer ID.
var slide = 1;				// default value; please do not change. slide ID.
	 	 
	 	 
function startPix() {			// place on <body onload="" />
	bannerslideshow(0);
	timerID = setInterval("bannerslideshow(0)", 3000);	//every 3 seconds; do not change the number inside bannerslideshow() this line!
}

function endPix() {			// place on <body onunload="" />
	if (timerID)
		clearInterval(timerID);
}

function bannerslideshow(x) {			// place on onmouseover=""
	//--------------------------------------------------------------
	//clear the banner button (¹è³Ê ¹öÆ° ÀÌ¹ÌÁö - out)
	//--------------------------------------------------------------
	document.getElementById("bc1").src = "https://www.warpportal.com/images/banner/c1_out.png";
	document.getElementById("bc2").src = "https://www.warpportal.com/images/banner/c2_out.png";
	document.getElementById("bc3").src = "https://www.warpportal.com/images/banner/c3_out.png";
	document.getElementById("bc4").src = "https://www.warpportal.com/images/banner/c4_out.png";
	document.getElementById("bc5").src = "https://www.warpportal.com/images/banner/c5_out.png";
	document.getElementById("bc6").src = "https://www.warpportal.com/images/banner/c6_out.png";
	//document.getElementById("bc7").src = "https://www.warpportal.com/images/banner/c7_out.png";
	//document.getElementById("bc8").src = "https://www.warpportal.com/images/banner/c8_out.png";

	if (x == 0){
		// if random
		//PicCurrentNum = Math.ceil(Math.random() * Pix.length) - 1;

		// if sequential
		PicCurrentNum = slide - 1;   

	} else {
		clearInterval(timerID);
		PicCurrentNum = x - 1;
	}
	
	//--------------------------------------------------------------
	// mark the banner button (¹è³Ê ¹öÆ° ÀÌ¹ÌÁö - over)
	//--------------------------------------------------------------
	imageNum = PicCurrentNum + 1;
	document.getElementById("bc" + imageNum).src = "https://www.warpportal.com/images/banner/c" + imageNum + "_over.png";

      	document.getElementById("ChangingLink").href = Links[PicCurrentNum];
      	document.getElementById("ChangingPix").src = "https://www.warpportal.com/images/banner/" + Pix[PicCurrentNum];

	//--------------------------------------------------------------
	// in case of a sequential rotation
	//--------------------------------------------------------------
	if (x == 0){		// if the banner button has NOT been touched
		if (slide == Pix.length){
			slide = 1;
		} else {
			slide = slide + 1;
		}
	} else {		// if the banner button has been touched
		if (x == Pix.length){
			slide = 1;
		} else {
			slide = x + 1;
		}
	}
}

function delayPix() {			// place on onmouseout=""
	clearInterval(timerID);
	timerID = setInterval("bannerslideshow(0)", 3000);	//every 3 seconds
}
