// http://www.parkerfox.co.uk/labs/css-webkit-animation-jquery-proof-of-concept.html
$.fn.animate2 = function(css, speed, fn) {
	if(speed === 0) { // differentiate 0 from null
	  this.css(css)
	  window.setTimeout(fn, 0)
	} else {
	  if($.browser.safari) {
		var s = []
		for(var i in css) 
			s.push(i)
	  
		this.css({ webkitTransitionProperty: s.join(", "),
				  webkitTransitionDuration: speed+ "ms" });
	  
		window.setTimeout(function(x,y) {
		  x.css(y)
		},0, this, css) // have to wait for the above CSS to get applied
		window.setTimeout(fn, speed)
	  } else {
		this.animate(css, speed, fn)
	  }
	}
  }
  
  
  
/*//
$(this).animate2({width: (w+50), height: h+50}, 1000, function(x) {//alert('callback') 
})*/ 

function showelementhideclass(myid,myclass){
	///$("#debug").text($("#debug").text()+"\n"+myid+" "+myclass); 
	
	$("."+myclass).css({display: 'none',position:'absolute'})	
	$("#"+myid).show()
	
	
}



function slidecontent(myitem,increment){
	//alert(parseInt($('#visits-content-'+id).css("left")));
		
		
	m = parseInt($("#"+myitem).css('marginLeft'));
	target = m+increment
	//$("#debug").text($("#debug").text()+"\n"+myitem+" "+increment+" "+maxleft+" "+target); 
	
	
	if(target > 0){
		target = 0
	}
	if(target <= -maxleft+640){
		target = -maxleft+640
	}
	
	
	$("#"+myitem).animate2({marginLeft:target},300)	
	/*
	var locked = $('body').data("bubblebox").locked;
	//var locked = $('body').data('locked').is;
	//alert(locked)
	if(locked != 'yes'){
			
			if(gettransformleft('visits-content-'+id) +increment >= 940){
				//$('#visits-content-'+id).animate({left:'30px'})
				//resetContent(id)
				//mywidth = 0;
				//$('#visits-content-'+id).animate({left:'+='+increment+'px'})
			}
			else{
				animate(id,increment)
				//$('#visits-content-'+id).animate({left:'+='+increment+'px'})
				
				if(increment < 0){
					//currpos++
					//$('body').data('visits-content-'+id,{currpos: currpos});
					//mywidth = parseInt($('#page-indicator-'+id).css("width"))+parseInt($('#page-indicator-'+id).css("marginLeft"));
				}else{
					//currpos--
					//$('body').data('visits-content-'+id,{currpos: currpos});
					//mywidth = -parseInt($('#page-indicator-'+id).css("width"))+parseInt($('#page-indicator-'+id).css("marginLeft"));
				}
			}
			
			//alert(currpos+" "+Math.floor(totalslides/2));
			updateindicator(id)
	}
	*/
	//if(parseInt($('#visits-content-'+id).css("left"))  <= -884){
		//$('#page-slide-left-'+id).hide()
	//}
	//$('#page-indicator-'+id).hide();
		
	
	//alert(mywidth)
	//$('#page-indicator-'+id).css({margin-left:mywidth+'px'});
	
}

function gettransformleft(myel){
//	alert(myel)
	var theTransform = window.getComputedStyle(document.getElementById(myel)).webkitTransform;
	matrix = theTransform.split(',');
	//alert(matrix[4])
	if(matrix[4] == undefined){
		left = 0
	}
	else{
		left = parseInt(matrix[4]);
	}
	
	
	return left
}
