var hashes = window.location.hash;
function hashesFunc(hashess) {
	//alert(hashess);
	bodyclass = hashess.replace('#', '');
	$('body').removeClass().addClass(bodyclass);
}
function lightmefunc(lightTarget) {
	$('#lightme').lightbox_me({centered: true, onLoad: function() { 
		if	(lightTarget.indexOf("http://") == 0){
			$('#lightme #lightmein').append('<iframe id="lightmeframe" src="' + lightTarget + '"></iframe>'); 
		} else if (lightTarget.indexOf("#") == 0){
			$('#lightme #lightmein').append($(lightTarget).show());
		} else {
			//$('#lightme #lightmein').load(lightTarget);
			$('#lightme #lightmein').append('<img src="' + lightTarget + '"/>'); 
		}
	}, onClose: function() { $('#lightme #lightmein').html(''); }
	});
}

$(document).ready(function() {
	var deviceAgent = navigator.userAgent.toLowerCase();
	var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
	if (agentID) {
		$.getScript("/Scripts/iscroll.js", function(){
			document.addEventListener('touchmove', function(e){ e.preventDefault(); }, false);
			var scroll01;
			var scroll02;
			//var scroll03;
			var scroll04;
			var scroll05;
			scroll01 = new iScroll('s01');
			scroll02 = new iScroll('s02');
			//scroll03 = new iScroll('s03');
			scroll04 = new iScroll('s04');
			scroll05 = new iScroll('s05');
		 });
		$("head").append($("<link rel='stylesheet' href='/Styles/ipad.css' type='text/css' media='screen' />"));

		$('.item').each(function() {
			var count = 0;
			 $(this).click(function() {
				 count++;
				 var isEven = function(someNumber) {
					  return (someNumber % 2 === 0) ? true : false;
				 };
				 if (isEven(count) === false) {
					  $(this).find('img').attr('src', 'Images/portfolio/' + $(this).attr('id') + '.png').fadeIn("slow");
					  return false;
				 } else if (isEven(count) === true) {
					  $(this).find('img').fadeOut("slow");
				 }
			});
		});
	} else {
		/*$('.item a').each(function() {
			$(this).hover(function() {$(this).find('img').fadeIn("slow")},function() {$(this).find('img').fadeOut("slow")});
		});*/
		//$('.item').find('img').attr('src', 'Images/portfolio/' + $(this).attr('id') + '.png');
		$('.item').hover(function() {$(this).find('img').attr('src', 'Images/portfolio/' + $(this).attr('id') + '.png').fadeIn("slow")},function() {$(this).find('img').fadeOut("slow")});

	}
	
	/*if (hashes) {
		hashesFunc(hashes);
	} else {
		hashesFunc('#vert');
	}	
	$('.orient').live('click',function(){
		hashesFunc($(this).attr('href'))
	});*/
	
	//$("a[rel^='prettyPhoto']").live('click',function(){
	/*$(".item img").live('click',function(){
		lightmefunc($(this).attr('src'));
		//alert($(this).attr('src'));
		return false;
	})*/

	/*if ( (navigator.userAgent.indexOf('iPad') != -1) ) {
    document.location = "http://www.bracketslash.com/app.php";
  }*/


});
