var lang='en';
var url;
var ie6=($.browser.msie && $.browser.version=='6.0')?true:false;

$(window).load(function () {
	$('#loading').fadeOut('fast');
});

$(document).ready(function(){

	// css
	var w = $(window).width();
	var h = $(window).height();

	$('#site,#loading').css({
		width: w,
		height: h
	});

	// scrollTo click
	$('#next').click(function(){ block(2); });

	// :hover ie fix :(
	if($.browser.msie) {
		$('.menu').mouseover(function(){ $(this).addClass('hover'); }).mouseout(function(){ $(this).removeClass('hover'); });
	}

});

// scroll
var scrollWorking = false;
function block(id) {

	if(!scrollWorking) {
		// check scroll working
		scrollWorking = true;

		// scroll
		$('#site').scrollTo('#block_'+id, {
			duration:500,
			axis: 'x',
			onAfter: function(){ scrollWorking = false; }
		});

		// check left
		if(id>1 && $('#prev').is(':hidden')) {
			$('#prev').fadeIn('fast');
		} else if (id==1) {
			$('#prev').fadeOut('fast');
		}

		// onClick set
		if(id==1) {
			$('#next').unbind('click').click(function(){ block(2); });

		} else if(id==2) {

			$('#prev').unbind('click').click(function(){ block(1); });
			$('#next').unbind('click').click(function(){ block(3); });

		} else if(id==3) {

			$('#prev').unbind('click').click(function(){ block(2); });
			$('#next').unbind('click').click(function(){ block(4); });

		} else if(id==4) {

			$('#prev').unbind('click').click(function(){ block(3); });
			$('#next').unbind('click').click(function(){ block(5); });
			
		} else if(id==5) {

			$('#prev').unbind('click').click(function(){ block(4); });
			$('#next').unbind('click').click(function(){ block(6); });
			
		} else if(id==6) {

			$('#prev').unbind('click').click(function(){ block(5); });
			$('#next').unbind('click').click(function(){ block(7); });
			
		} else if(id==7) {

			$('#prev').unbind('click').click(function(){ block(6); });
			$('#next').unbind('click').click(function(){ block(8); });
			
		} else if(id==8) {

			$('#prev').unbind('click').click(function(){ block(7); });
			$('#next').unbind('click').click(function(){ block(9); });
			
		} else if(id==9) {

			$('#prev').unbind('click').click(function(){ block(8); });
			$('#next').unbind('click').click(function(){ block(10); });
			
		} else if(id==10) {

			$('#prev').unbind('click').click(function(){ block(9); });
			$('#next').unbind('click').click(function(){ block(1); });
		}
		
		
	}

}

// project list


// resize div to full window size
$(document).ready(function(){
	$('#site') .css({'height': ($(window).height())+'px'});
	$(window).resize(function(){
		$('#site') .css({'height': ($(window).height())+'px'});
		$('#site') .css({'width': ($(window).width())+'px'});
	});
});


window.onload = function() {
  setLinks();
}

function setLinks() {
  if (!document.getElementsByTagName) return false;
  var links = document.getElementsByTagName("a");
  if (links.length == 0) return false;
  for (var i = 0; i < links.length; i++) {
    var relation = links[i].getAttribute("rel");
    if (relation == "external") {
      links[i].onclick = function() {
        return !window.open(this.href);
      }
    }     
  }
}
