var urljs="http://localhost/louisbull/";
var url="http://localhost/louisbull/index.php/";
if(window.location.host=="louisbulltribe.ca"){
	urljs="http://louisbulltribe.ca/";
	url="http://louisbulltribe.ca/index.php/";	
}
if(window.location.host=="www.louisbulltribe.ca"){
	urljs="http://www.louisbulltribe.ca/";
	url="http://www.louisbulltribe.ca/index.php/";	
}

$(document).ready(function(){	
		
	setInterval( function(){
		var $active = $('#slideshow DIV.active');
		
	    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

	    // use this to pull the divs in the order they appear in the markup
	    var $next =  $active.next().length ? $active.next()
	        : $('#slideshow DIV:first');

	    // uncomment below to pull the divs randomly
	    // var $sibs  = $active.siblings();
	    // var rndNum = Math.floor(Math.random() * $sibs.length );
	    // var $next  = $( $sibs[ rndNum ] );


	    $active.addClass('last-active');

	    $next.css({opacity: 0.0})
	        .addClass('active')
	        .animate({opacity: 1.0}, 3000, function() {
	            $active.removeClass('active last-active');
	        });
		
	}, 5000 );
	$('#news').cycle({ 
	    fx: 'scrollUp',
	    speed:  5000 
	});
	if($('.acc_container').length>0){
		$('.acc_container').hide(); //Hide/close all containers
		$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container
		
		$("[name='kmudimg']").attr('src',urljs+'images/yellowleft_arrow.png');
		$('.acc_trigger:first').find("[name='kmudimg']").attr('src',urljs+'images/yellowDw_arrow.png');
		
		//On Click
		$('.acc_trigger').click(function(){				
			if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
				$("[name='kmudimg']").attr('src',urljs+'images/yellowleft_arrow.png');	
				
				$('.acc_trigger').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
				
				$(this).find("[name='kmudimg']").attr('src',urljs+'images/yellowDw_arrow.png');
				
				$(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
			}else{
				$(this).find("[name='kmudimg']").attr('src',urljs+'images/yellowleft_arrow.png');	    	
	
				$('.acc_container').slideUp();
			}
			return false; //Prevent the browser jump to the link anchor    	
	   
		});
		
	}
	
	if($('.acc_container_chief').length>0){
		$('.acc_container_chief').hide(); //Hide/close all containers
		$('.acc_trigger_chief:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container
		
		$("[name='kmudimg']").attr('src',urljs+'images/yellowleft_arrow.png');
		$('.acc_trigger_chief:first').find("[name='kmudimg']").attr('src',urljs+'images/yellowDw_arrow.png');
		
		//On Click
		$('.acc_trigger_chief').click(function(){				
			if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
				$("[name='kmudimg']").attr('src',urljs+'images/yellowleft_arrow.png');	
				
				$('.acc_trigger_chief').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
				
				$(this).find("[name='kmudimg']").attr('src',urljs+'images/yellowDw_arrow.png');
				
				$(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
			}else{
				$(this).find("[name='kmudimg']").attr('src',urljs+'images/yellowleft_arrow.png');	    	
	
				$('.acc_container_chief').slideUp();
			}
			return false; //Prevent the browser jump to the link anchor    	
	   
		});
		
	}
	
	/**** Signup ****/
	$("#signupsubbtn").click(function(){
		
		$("#signupfrm").clvalidate({
			onComplete:function(b){
						if(b){
							var js=$("#signupfrm").serializeArray();
							$.post(url+"signup/sav",js,function(data){
								if(data.result>0){
									$("#signupfrm").html("");
									$("#signupmsg").html(data.msg);
								}else{
									$("#signupmsg").html("Failed...Please try again...");
								}
								$('html, body').animate({scrollTop: '50px'}, 800);
							},"json");
						}
			}			
		});
	});
	/**** Forget Pwd ****/
	$("#fpwdbtn").click(function(){		
		$("#fpwdfrm").clvalidate({
			onComplete:function(b){
						if(b){
							var js=$("#fpwdfrm").serializeArray();
							$.post(url+"forgetpwd/resetpwd",js,function(data){
								if(data.result>0){
									$("#fpwdfrm").html("");
									$("#fpwdmsg").html(data.msg);
								}else{
									$("#fpwdmsg").html(data.msg);
								}
								$('html, body').animate({scrollTop: '50px'}, 800);
							},"json");
						}
			}			
		});
	});
	/**** Dashboard ****/
	
	if($('.acc_container_dashboard').length>0){
		$('.acc_container_dashboard').hide(); //Hide/close all containers
		$('.acc_trigger_dashboard:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container
		
		$("[name='kmudimg']").attr('src',urljs+'images/yellowleft_arrow.png');
		$('.acc_trigger_dashboard:first').find("[name='kmudimg']").attr('src',urljs+'images/yellowDw_arrow.png');
		
		//On Click
		$('.acc_trigger_dashboard').click(function(){				
			if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
				$("[name='kmudimg']").attr('src',urljs+'images/yellowleft_arrow.png');	
				
				$('.acc_trigger_dashboard').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
				
				$(this).find("[name='kmudimg']").attr('src',urljs+'images/yellowDw_arrow.png');
				
				$(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
			}else{
				$(this).find("[name='kmudimg']").attr('src',urljs+'images/yellowleft_arrow.png');	    	
	
				$('.acc_container_dashboard').slideUp();
			}
			return false; //Prevent the browser jump to the link anchor    	
	   
		});
	}
	/**** Signin ****/
	$("#signinbtn").click(function(){
		var js={'un':$("[name=uname]").val(),'pwd':$("[name=pwd]").val()};
		$.post(url+"signin/login",js,function(data){
			if(data.result>0){
				window.location.href=url+"dashboard";
			}else{
				alert("Wrong username or Password!!!");
			}
		},"json");
	});
	/**** Contactus ****/
	$("#contactusbtn").click(function(){
		$("#contactusdiv").clvalidate({
			onComplete:function(b){
				if(b){
					var js=$("#contactusfrm").serializeArray();
					$("#contactusdiv").hide();
					$("#contactusmsg").html("<h3>Please wait while we process...</h3>");
					$.post(url+"contactus/contact",js,function(data){
						if(data.result>0){
							$("#contactusdiv").hide();
							$("#contactusmsg").html("<h3>Thank you....We will get back to you shortly...</h3>");
						}else{
							$("#contactusdiv").show();
						}
					},"json");
				}
		}
		});
		
	});
	$("#contactusclr").click(function(){
		$("#contactusdiv").find(":input").each(function(x,y){
			$(y).val("");
		});
	});
});
	
