
// JavaScript Document
// for www.bjornart.com ver 1.0.1
// author : ivan.maruca@gmail.com

$(function(){
	
	// create table for contents
	$("#container").wrapInner(document.createElement("tr"));
	$("#container").wrapInner(document.createElement("table"));
	$("figure").wrap("<td>");
	
	// lazy load implement
	if(navigator.appName != "Microsoft Internet Explorer"){
	$("img").lazyload({ 
		effect : "fadeIn" 
	});}
	
	// drag document
	var intX = null;
	var once = 0;
	
	$('#container').mousedown( function( event ) {
		$('html,body').stop();
		intX = event.pageX;
		return false; // disable selection
	});

	$(document).mousemove( function( event ) {
		if( intX !== null ) {
			var moveX = $(window).scrollLeft() + -(event.pageX - intX);
			$(window).scrollLeft(moveX); 

			if($(window).scrollLeft() == 0 ){
				if(!once){
					intX = event.pageX;
					once = 1;
				}
				$('#container').css({ left: -moveX });
			}

			$(this).css({ 'MozUserSelect' : 'none' }); // // disable selection in Firefox Win
			return false; // // disable selection in Safari Mac, Firefox Mac, IE7
		}
	});

	$(document).mouseup( function( event ) {
		if( intX !== null ) {
			once = 0;
			intX = null;		
			
		}
	});

	// enabled selection foundamental elements
	$('input, select, option, label, textarea, button').mousedown( function(){
		$( this ).focus();
	});
	
	// scrollTo	
	$('#arrow_right').mousedown(function(){
	 var scroller = $('html,body');
	 if ($.browser.opera)scroller = $('html');
	 var positionNow = $(window).scrollLeft();
	 var positionTo = positionNow + 500 ;
	 scroller.animate({scrollLeft: positionTo, scrollTop: '0'},1000);
  });
  $('#arrow_left').mousedown(function(){
	 var scroller = $('html,body');
	 if ($.browser.opera)scroller = $('html');
	 var positionNow = $(window).scrollLeft();
	 var positionTo = positionNow - 500 ;
	 scroller.animate({scrollLeft: positionTo, scrollTop: '0'},1000);
  });
  
  // Animate fb logo
  $('#fb').mouseover(function(){
    var logo = $('#fb');
    logo.stop().animate({"top": "75"},500);
  });
  $('#fb').mouseout(function(){
    var logo = $('#fb');
    logo.stop().animate({"top": "30"},800);
  });
  
  // Get Firefox feuture
  
  var info_box = document.getElementById('info');
  var fireConfig = document.getElementById('FireIcon');
  if(navigator.appName != 'Netscape' && fireConfig.value != 'disabled'){
    info_box.innerHTML = '<a href="http://www.getfirefox.com"><img class="firefox" id="getFire" src="images/getfirefox_out.png" align="left" border="none"></a>' + info_box.innerHTML ;
    $('#getFire').mouseover(function(){
      $('#getFire').attr('src','images/getfirefox_over.png');
    });
    $('#getFire').mouseout(function(){
      $('#getFire').attr('src','images/getfirefox_out.png');
    });
  }
	/*
	// scrollTo	
	$('#bio').click( function() {
		var parentEl = $('html,body');
		if ($.browser.opera){
			parentEl = $('html');
		}
		parentEl.stop().animate({scrollLeft: '0', scrollTop: '0' }, 1000);
		return false;
	});
	$('#contact').click( function() {
		var parentEl = $('html,body');
		if ($.browser.opera){
			parentEl = $('html');
		}
		parentEl.stop().animate({scrollLeft: '1000', scrollTop: '0' }, 1000);
		return false;
	});
	$('#comics').click( function() {
		var parentEl = $('html,body');
		if ($.browser.opera){
			parentEl = $('html');
		}
		parentEl.stop().animate({scrollLeft: '2560', scrollTop: '0' }, 1000);
		return false;
	});*/

});



