function ad_ajax(pos){
	jQuery.ajax({
		url:HOST_PATH + 'ad/get.html',
		type:'POST',
		data:'pos='+pos,
		success:function(html){
			if(pos==1){
				obj_id = '#ad_left';
			}else{
				obj_id = '#ad_right';
			}
			jQuery(obj_id).html(html);
		}
	});
}

function ad_counter(id){
	jQuery.ajax({
		url:HOST_PATH + 'ad/view.html',
		type:'POST',
		data:'id='+id,
		success:function(msg){
			if(msg!='#'){
				window.open(msg,'_blank');
			}
		}
	});
	return true;
}

function product_scroll(){
	var $products = jQuery('#product-ticker');
	$products.serialScroll({
		items:'div',
		duration:700,
		force:true,
		axis:'y',
		lazy:true,//NOTE: it's set to true, meaning you can add/remove/reorder items and the changes are taken into account.
		interval:5000, //yeah! I now added auto-scrolling
		step:1 //scroll 2 news each time
	});
}


var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;

hotproducts_scroll = function(){
	headline_count = jQuery("div.headline").size();
	jQuery("div.headline:eq(" + current_headline + ")").css('top','5px');
	headline_interval = setInterval(product_rotate,5000);
	jQuery("#scrollup").hover(function(){
		clearInterval(headline_interval);
	},
	function(){
		headline_interval = setInterval(product_rotate,5000);
		product_rotate();
	});
}

function product_rotate(){
	current_headline = (old_headline + 1) % headline_count;
	jQuery("div.headline:eq(" + old_headline + ")").animate({top: -205},"slow", 
	function() {
		$(this).css('top', '210px');
	});
	jQuery("div.headline:eq(" + current_headline + ")").animate({top:5},"slow");
	old_headline = current_headline;
}
ad_ajax(1);
ad_ajax(2);
product_scroll();
jQuery('ul#portfolio').innerfade({
	speed: 1000,
	timeout: 5000,
	type: 'sequence',
	containerheight: '290px'
});