var scrollerStep = 30;
var interval = 100;
var scrollContentStep = 55;
var scrollerPosition = 0;
var maxScrollerPosition = 119;
var minScrollerPosition = 0;

function cancelBubbling(evt) {
	evt = evt || window.event;
	evt.cancelBubble = true;
}

$("#news_content").mousewheel(
		function(e, delta){
	    	sign = (delta > 0) ? ("-") : ("+");
			scroll(scrollerStep, scrollContentStep, interval, sign);
		}
	);

function scroll(scrollerStep, scrollContentStep, interval, sign){
	if(sign == "+"){
		if(scrollerPosition >= maxScrollerPosition){						
			return;
		}
		else if( scrollerPosition + scrollerStep > maxScrollerPosition){
			scrollerStep = scrollerStep - (scrollerPosition + scrollerStep - maxScrollerPosition);
		}
	}
	else if(sign == "-"){
		if(scrollerPosition <= minScrollerPosition){
			return;											
		}
		else if(scrollerStep - scrollerPosition > minScrollerPosition){
			scrollerStep = scrollerPosition;
		}
	}
	$("#scroller").animate({top: sign + "=" + scrollerStep + "px"}, interval);
	$("#news_content_data").animate({top: getOppositeSign(sign) + "=" + scrollContentStep + "px"}, interval);
	scrollerPosition += parseInt(sign + scrollerStep);
}

function getOppositeSign(sign){
	return (sign == "+") ? ("-") : ("+");
}
function writeInput(name, id, type, value, sClass){
	document.write('<table class="reg_input_table" cellpadding="0" cellspacing="0" border="0"><tr><td class="reg_input_border_top" colspan="3"></td></tr><tr><td class="reg_input_border_left"></td><td><input type="' + type + '" name="' + name + '" id="' + id + '" value="' + value + '" class="' + sClass + '"></td><td class="reg_input_border_right"></td></tr><tr><td class="reg_input_border_bottom" colspan="3"></td></tr></table>');
}
function writeComixPreview(){
	document.write('<img src="' + comixPagesLocation + 'cxprv_' + (Math.ceil(Math.random() * comixPageCount)) + '.png" width="200", height="90" border="0">');
}
