//
// (C)2011 MARCEL SCHMITZ. ALL RIGHTS RESERVED. IF YOU WANT TO USE THIS CODE, FEEL FREE TO ASK FIRST. THANKS!
//


// APPLE DEVICES, WORKS ON ALL OF THEM
var IsiPhone = navigator.userAgent.indexOf("iPhone") != -1 ;
var IsiPod = navigator.userAgent.indexOf("iPod") != -1 ;
var IsiPad = navigator.userAgent.indexOf("iPad") != -1 ;

// DETECT IE
function getInternetExplorerVersion() {
	var rv = -1; // Return value assumes failure.
	if (navigator.appName == 'Microsoft Internet Explorer') {
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null) rv = parseFloat( RegExp.jQuery1 );
		}
	return rv;
}

// DETECT ELEMENT'S APPEARENCE IN DOCUMENT WINDOW, FOR HORIZONTAL SCROLLING
function isScrolledIntoView(elem) {
    var docViewLeft = jQuery(window).scrollLeft();
    var docViewRight = docViewLeft + jQuery(window).width();
    var elemLeft = jQuery(elem).offset().left;
    var elemRight = elemLeft + jQuery(elem).width();
    return ((elemRight >= docViewLeft) && (elemLeft <= docViewRight));
}

// LOAD MORE PICS
function loadmore(currentPage) {			

	jQueryslideshow = jQuery("#slideshow ul");
	jQuerycurrentURL = location.href.replace("/index.php","");
	jQuerygetURL = jQuerycurrentURL + "/page/" + String(currentPage);

	// MISSING EXCEPTION FOR SINGLE POSTS
	jQuery.get(jQuerygetURL, function(data) { jQueryslideshow.append(jQuery(data)); });
	jQuery("a[rel=\'viewbig\']").colorbox({transition:"none", width:"100%", height:"80%", returnFocus:false });	
	

}
	
// SHOW INFO ABOUT NAVIGATION

function infoScreen() {
	
	jQuery.blockUI({ message:'click on a photo or use the arrow keys to scroll', css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#000', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .5, 
            color: '#fff' 
        } }); 
 
 		jQuery(window).click(function() {jQuery.unblockUI();});
        setTimeout(jQuery.unblockUI, 5000); 

}
	

	
// FOR IE USERS
function WarnIE() { alert("Dude, for real? You're using Internet Explorer? Get Firefox, or Safari, or Chrome.");};

// FOR APPLE DEVICES
function BlockMove(event) {event.preventDefault() ;}
function WarnPortrait() { if(window.orientation==0) alert("Best viewed horizontally, just sayin'..."); };
function WarnClick() { alert("Click on a photo to scroll, it works, believe me."); };

// SHOW HOW TO SCROLL
function ShowHowToScroll() {jQuery(window).oneTime(15000, function() {infoScreen();});}
	
jQuery(document).ready(function () {

	// EVERYTHING IS DEFINED, LET'S ROLL


	// BIG COLORBOX
	jQuery(document).bind("cbox_open", function (e) {
		jQuery("body").css("overflow","hidden");
	});
	jQuery(document).bind("cbox_closed", function (e) {
		jQuery("body").css("overflow","auto");
	});
	jQuery("a[rel='viewbig']").colorbox({transition:"none", width:"100%", height:"80%", returnFocus:false });	


});
