var count = 0;
var antchecked = 'n';
var firstcheck = 1;
var changechecked = 0;

function first_status(){
		$('.iPhoneCheckLabelOn').css({'width': '0px','display': 'block'});
		$('.iPhoneCheckHandle').css({'width': '0px', 'left': '0px'});
		$('input').attr('checked', false); 
}


function scrolling(sl){
	if(sl == 'websites'){
			$(function() {		
				 var sw = $("div.scrollablewebsites").scrollable({
						api: true,
						size: 1,
						interval: 12000,
						loop: true, 
						clickable: true,
						items: '.itemwebsites',
						speed: 800,
						navi:'#portfolio .naviwebsites'
					});	
			});
	}else{
			$(function() {	
					var sb = $("div.scrollablebrands").scrollable({
						api: true,						
						size: 1,
						interval: 12000,
						loop: true, 
						clickable: true, 
						items: '.itembrands',
						speed: 800,
						navi:'#portfolio .navibrands'
					});	
					
			});
	}
    $(document).ready(function() {
        $(".naviwebsites").click(function() { 
            $(".scrollablewebsites").scrollable().turnOff();
        }); 
        
        $(".navibrands").click(function() { 
          $(".scrollablebrands").scrollable().turnOff();
        });  
    });    
}

function slideimg(slidesh){
	var sl = slidesh; 
	
	if($('#firstatus').html() == 'yes'){
		first_status();
		$('#firstatus').html('');
	}
	
	if(slidesh == undefined){
		if(firstcheck == 0){
			antchecked = 'y';
		}else{
			firstcheck = 0;	
		}
			if ($("#workresult").html() == 'brands'){
				sl = "websites";
				$("#workresult").html("websites");
			}else{
				sl = "brands";
				$("#workresult").html("brands");
			}
		}
	if ($('input:checked').length == '1') {
  		sl = "brands";
				$('.naviwebsites').hide();
				$('.navibrands').show();
				$('.scrollablewebsites').hide();
				$('.scrollablebrands').show();
//				$('.navibrands > a:first').click();
				if (count >= 2){
					$('.scrollablebrands').scrollable().begin();
					$(".scrollablewebsites").scrollable().turnOff();
		 			$(".scrollablebrands").scrollable().turnOn();
				}
	}else{
		sl = "websites";
				$('.naviwebsites').show();
				$('.navibrands').hide();
				$('.scrollablewebsites').show();
				$('.scrollablebrands').hide();
//				$('.naviwebsites > a:first').click();
				if (count >= 2){
					$('.scrollablewebsites').scrollable().begin();
					$(".scrollablebrands").scrollable().turnOff();
					$(".scrollablewebsites").scrollable().turnOn();
				}					
	}
	
	
	count = count + 1;
	if(count < 3){
		$(document).ready(function(){	
					var param = "slidesh="+sl;
					 $.ajax({
					   type: "POST",
					   url: "/embeds/slider.php",
					   contentType: "application/x-www-form-urlencoded",
					   data: param,
					   beforeSend: inicioEnvio = function(){
						$(".scrollablebrands").html("<div style='width: 940px; height: 360px; float: left; margin-top: 150px; margin-left: 450px'><img src='/images/images/loader.gif' border='0'></div>"); 
					   },
					   cache: false,
					   success: getmessage = function(html){ 
						  if(sl == "websites"){
							$(".scrollablewebsites").html(html);
							scrolling(sl);
						  }else{
							$(".scrollablewebsites").scrollable().turnOff();
							$(".scrollablebrands").html(html);
							scrolling(sl);
							$('.scrollablebrands').scrollable().begin();
						  }
					   }
					 });
					 return false;
			})
	}
}

/*
function changeslidecheck(){
	if($(".scrollablewebsites").scrollable().getConf().interval == 0){
		$(".scrollablewebsites").scrollable().getConf().interval = 6000;
	}
	
	if(count > 3){
		if($(".scrollablewebsites").scrollable().getConf().interval == 0){
			$(".scrollablebrands").scrollable().getConf().interval = 6000;
		}
	}
}
*/


