function startPlay(url){
	url = url.replace(/http:\/\/(www)?(stage|test)?(\.)?(provo)?(\.)?novell\.com/, "");
//	_gaq.push(['_trackEvent','Video Plays', url, window.location.href]);
}

function stopPlay(url, percentage, seconds){
	url = url.replace(/http:\/\/(www)?(stage|test)?(\.)?(provo)?(\.)?novell\.com/, "");

	//percentage played	
//	_gaq.push(['_trackEvent','Percentage Played', url, window.location.href, percentage]);

	//seconds played
//	_gaq.push(['_trackEvent','Seconds Played', url, window.location.href, seconds]);
}

function newsRotator(container, switcher) {
	var news = container.find("p");
	var current =  container.find("p:first");
	var timer = null;
	var startTimer = function() {
		timer = setTimeout(switcher + '.rotate()', 5000);
	};
	this.rotate = function() {
		current.fadeOut("normal", function(){
			current = current.next("p");
			if(current.size() == 0) current = container.find("p:first");
			current.fadeIn();
			startTimer();
		});
	};
	this.start = function() {
		startTimer();
	};
}

function rotatingHighlight(container, switcher) {
	var terms = container.find("h5 strong");
	terms.each(function(){
		// preaload image for each term
		var termId = $(this).attr("id").substring(7);
		var imagePreloader = $('<img />').attr('src', "/common/img/micro/icon_"+termId+".png");
	});
	var current =  container.find("h5 strong.color");
	var img = container.find(".highlight_image img");
	var timer = null;
	var startTimer = function() {
		timer = setTimeout(switcher + '.rotate()', 5000);
	};
	this.rotate = function() {
		img.animate({opacity: 0}, 1000, function() {
			current.removeClass("color");
			current = current.next("strong");
			if(current.size() == 0) {
				current = container.find("h5 strong:first");
			}
			var uniqueId = current.attr("id").substring(7);
			img.attr("src","/common/img/micro/icon_"+uniqueId+".png");
			container.find("div.default").removeClass("default");
			current.addClass("color");
			container.find("#rotate_content_"+uniqueId).addClass("default");
			img.animate({opacity: 1}, 1000, function() {
				startTimer();
			});
		});
	};
	this.start = function() {
		startTimer();
	};
}

function showRolloverContent() {
	$(this).parent().parent().find(".content_rollover_block").find("p:first").hide().parent().removeClass("active");
	$(this).css("cursor","pointer").parent().addClass("active").find("p:first").show();

}

function rolloverRotation(container, switcher) {
	var rotationTime = 5000;
	var rollovers = container.find("div.content_rollover_block");
	var current =  container.find("div.active");
	var timer = null;
	rollovers.mouseover(function() {
			clearTimeout(timer);
		}).mouseout(function() {
			timer = setTimeout(switcher + '.rotate()', rotationTime);
			current =  container.find("div.active");
		}
	);
	var startTimer = function() {
		timer = setTimeout(switcher + '.rotate()', rotationTime);
	};
	this.rotate = function() {
		clearTimeout(timer);
		current.find("p:first").fadeOut("slow",function() {
			current.removeClass("active");
			current = current.next("div");
			if(current.hasClass("clr")) {
				current = container.find("div:first");
			}
			current.find("p:first").hide();
			current.addClass("active");
			current.find("p:first").fadeIn("slow",function() {
				startTimer();
			});
		});
	};
	this.start = function() {
		startTimer();
	};
}

$(document).ready(function(){
	if($(".buzz").size() > 0) {
		nwsRotate = new newsRotator($(".buzz"), "nwsRotate");
		nwsRotate.start();
	}

//	if(!($.browser.msie && parseInt(jQuery.browser.version) < 7)) {
		$("#micro_nav a").each(function(){
			if(!$(this).parent().hasClass("active")) {
				$(this).corner("4px");
			} else {
				$(this).corner("tr tl 4px");
			}
		});
//	}

	$(".content_rollover h5").hover(showRolloverContent).append('<img src="/common/img/micro/rollover_active_withbg.png" alt="" />');
	$("#requestcall h3").corner("5px tr tl");
	$("#requestcall_salesphone").corner("5px br bl");
	$(".content_media, .content_media_item").corner("5px");/* .filter(".content_media_item").css("cursor","pointer").hover(function(){
			$(this).addClass("active");
		},function(){
			$(this).removeClass("active");
		}).click(function() {
			location.href=$(this).find("a").attr("href");
		}
	); */
	if($("#rotatinghighlight").size() > 0) {
		rHighlight = new rotatingHighlight($("#rotatinghighlight"), "rHighlight");
		rHighlight.start();
	}
	if($(".content_rollover").size() > 0) {
		rotation = new rolloverRotation($(".content_rollover"), "rotation");
		rotation.start();
	}
});