﻿var delayBetweenAnimation = 6000;
var pub_images = new Array();
var pub_links = new Array();
var pub_targets = new Array();
var pub_images_current = 0;

function StartPubAnimation() {
	$(".round").corner();
	if (pub_images.length > 1) {
		setTimeout(switchPubImage, delayBetweenAnimation);
	}
}

function switchPubImage() {
   if (++pub_images_current > pub_images.length - 1) pub_images_current = 0;
   $("#PubImageBG2").css("opacity", "0").css("background", "url(" + pub_images[pub_images_current] + ") no-repeat -900px 0px");
   $("#PubImageBG2").animate({ backgroundPosition: "0px 0px", opacity: "1" }, 1000, function() {
       $("#PubImageBG1").css("background", "url(" + pub_images[pub_images_current] + ") no-repeat 0px 0px");
       $("#PubImageLink").attr("href", pub_links[pub_images_current]);
       $("#PubImageLink").attr("target", pub_targets[pub_images_current]);

       if (pub_links[pub_images_current] == "") {
           $("#PubImageLink").attr("onclick", "return false;");
           $("#PubImageLink").css("cursor", "default");
       } else {
           $("#PubImageLink").attr("onclick", "");
           $("#PubImageLink").css("cursor", "pointer");
       }

       setTimeout(switchPubImage, delayBetweenAnimation);
   });
}