function sifrRules() {
	if(typeof sIFR == "function"){
		sIFR.replaceElement(named({sSelector:"h2.title", sFlashSrc:"/_flash/cochin.swf", sColor:"#bb9c6d", sLinkColor:"#bb9c6d", sBgColor:"#FFFFFF", sHoverColor:"#bb9c6d", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0&offsetLeft=20"}));
		sIFR.replaceElement(named({sSelector:"h1.title", sFlashSrc:"/_flash/cochin-italic.swf", sColor:"#000", sLinkColor:"#000", sBgColor:"#FFFFFF", sHoverColor:"#000", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0&offsetLeft=20"}));
	};
}



function customScrollbar() {
	$('#copy').jScrollPane();
}



function cycleModules() {
	$(".slideshow-slide").cycle({ 
		timeout: 0, 
	    fx: "fade", 
	    speed: 500, 
		prev: "#more-winners .prev",
		next: "#more-winners .next"
	});
	 
	while ($('ul.dsq-widget-list > li[class!="li_group"]:lt(3)').length >= 1) {
	    $('ul.dsq-widget-list > li[class!="li_group"]:lt(3)').wrapAll('<li class="li_group"><ul></ul></li>');
	    $('.li_group ul li:last').addClass("nomargin");
	}
	
	$(".dsq-widget-list").cycle({ 
		timeout: 0, 
	    fx: "fade", 
	    speed: 500, 
		prev: "#comment-list .prev",
		next: "#comment-list .next"
	});
}



/* overlay */

function overlayModule() {

	var overlayBGWidth = $(document).width() +"px";
	var overlayBGHeight = $(document).height() +"px";
	var overlayMargin = ($(window).width() - 600)/2 +"px";
	
	// activate login popup when "login" or "register" button is clicked
	$(".overlay-trigger").click(function() {
		
		//set bg dimension to cover the whole browser
		$(".overlay").css({"width":overlayBGWidth,"height":overlayBGHeight});		
		
		//set login module's position
		$(".overlay-container").css({"left":overlayMargin});
		$(".overlay").fadeIn(200);
		$(".overlay-container").fadeIn(200);
		//force disqus to reload (firefox issue)
		var getIframeAddress = $(".overlay-container iframe").attr("src");
		$(".overlay-container iframe").attr("src",getIframeAddress);
		return false;
	});

	// redo functions on window resize (so the bg still covers the screen & the login module is positioned correctly)
	$(window).resize(function() {
		var overlayBGWidth = $(document).width() +"px";
		var overlayBGHeight = $(document).height() +"px";
		var overlayBGHeight = ($(window).width() - 600)/2 +"px";
		$(".overlay").css({"width":overlayBGWidth,"height":overlayBGHeight});		
		$(".overlay-container").css({"left":overlayMargin});
	});
	
	// emulate "position:fixed" (ie6)
	$(window).scroll(function() {
	    $(".overlay-container").css("top", $(window).scrollTop() + 50 + "px");
	});	
	
	// close overlay module when the user clicks anywhere on the body...
	$(document).click(function() {
		$(".overlay").fadeOut(200);
		$(".overlay-container").fadeOut(200);
	});
	// ...except the overlay module itself
	$(".overlay-container").click(function(event){
	    event.stopPropagation();
	});

}



function swfReload() {
	//alert("test");
	//var getVideoSrc = $("embed#sponsor-video").attr("src");
	//var randomNumberXml = ".xml?" + Math.floor(Math.random()*10000);
	//var randomNumberVideo = "DCMediaPlayer.swf?" + Math.floor(Math.random()*10000);
	//var videoEdit1 = getVideoSrc.replace(".xml", randomNumberXml);
	//var videoEdit2 = videoEdit1.replace("DCMediaPlayer.swf", randomNumberVideo);
	//$("embed#sponsor-video").attr("src", videoEdit1);
	//$(".jScrollPaneContainer").html(videoEdit1);
	$("embed#sponsor-video").css({
    	'background-color' : '#ddd',
    	'font-size' : '12px',
    	'color' : 'rgb(0,40,244)'
    });	
}



$(document).ready(function(){
	sifrRules();
	customScrollbar();
	cycleModules();
	overlayModule();
	//swfReload();
});
