$(document).ready(function () {	
	$("#sitesearchbtn").click(function (){
		alert(1);
	});
	
	//water mark
	$('.searchbox').watermark('watermark');
	
	
	//create scroller for each element with "horizontal_scroller" class...
	$('.horizontal_scroller').SetScroller({velocity: 	 60,
											direction: 	 'horizontal',
											startfrom: 	 'left',
											loop:		 'infinite',
											movetype: 	 'linear',
											onmouseover: 'pause',
											onmouseout:  'play',
											onstartup: 	 'play',
											cursor: 	 'pointer'
	});
	
	
	
	//topstories		
	$("#mainThumbs li").click(function(){
		//alert(this.id);
                for(i=1; i<=4; i++)
		{
                        $("#thumb-"+i).removeClass("selectedli");
                        $("#thumb-"+i).find(".thumb-wrapper").removeClass("selectednews");
                        $("#thumb-"+i).find(".thumb-text p").removeClass("selectedpnews");
                                
			if(this.id == "thumb-"+i )
			{
				$("#"+this.id).addClass("selectedli");
                                $("#"+this.id).find(".thumb-wrapper").addClass("selectednews");
                                $("#"+this.id).find(".thumb-text p").addClass("selectedpnews");
                                $("#mainstory-"+i).css({"display":"block"});
			}
			else
			{
				$("#mainstory-"+i).css({"display":"none"});                               
			}
		}
	
		
	});
	
        $("#yourcomments textarea").keyup(function(){
            if($(this).val().length<256){
                $("#yourcomments h5").html(255 - ($(this).val().length));
            }else{
                $(this).val($(this).val().substr(0,255));
                return false;
            }
        }); 
        
        $("#submitpost").click(function (){
            if ($("#user_name").val()== "" || $("#c_comments").val()=="")
                {
                    alert("please select your name and your comments");
                    return false;    
                }
            if($("#recaptcha_response_field").val()=="")
                {
                    alert("please type in the CAPTCHA code to know your human.");
                    return false;    
                }
	});
        
        
        $(".printpage").click(function (){
            window.print();
            return false;
	});
        
        //breaking news rotation
        var i = 1;
        var articlecount = $(".alertscontent").length;
        
        function hideandshow() {
            var a = $('.alertscontent:visible');
            a.hide('slide');
            if(a.next('.alertscontent').length >0)
            {
                a.next('.alertscontent').delay(5000).show('slide');
            }
            else
            {
                $('.alertscontent:first').delay(5000).show('slide');
            }
                //$('.alertscontent#'+i).slideUp('slow').delay(2000).fadeOut('fast');
               
           
        };
        var timer;
//        function repeat() {
//            hideandshow();
//            timer = setTimeout(repeat, 1000);
//        };
            if($('.alertscontent').length >1)
            timer = setInterval(hideandshow, 5000);
            
             
        $(".dispimg").hover(function (){
            $(".overimg").css({"display":"none"});  
            $(this).find(".overimg").show();
	},function(){
            $(".overimg").css({"display":"none"});  
        });
            

});





