this.initnav = function (e) {



	$(e + ' > ul')	.hover(
						function(){	animnav($(this)) },
						function(){	animnav($(this)) }
					)
					.find('li > ul')
					.css('opacity', 0)
					.end()
					
					.find('> li')
					.hover(
						function(){ $('#navigation > ul > li > a.on').removeClass('on'); $(this).find('a:eq(0)').addClass('on').end().find('ul:eq(0)').stop().show().fadeTo(400, 1) },
						function(){ $(this).find('> ul').stop().fadeTo(700, 0).hide() }
					)
	
	

}

this.navact = false;

this.animnav = function (e) {
	if (animstatus === false) {
		$(e).stop().animate({marginTop: '-18px'}, 200)
		animstatus = true
	}else{
		$(e).stop().animate({marginTop: '0'}, 200)
		animstatus = false
	}
}

this.animstatus = false

$(document).ready(function(){

	$('a#contact').css('cursor', 'pointer')
	if ( $('div#navigation > ul').find('li.on').length ) {
		$('div#navigation > ul').css({marginTop: '-18px'})
								.find('li.on')
								.parent()
								.show()
								.fadeTo(100, 1)
	}
	
	initnav('div#navigation')

	$.preload( '.preload img', {
		onFinish:function(){
			$.scrollTo(0, 0);
			$.scrollTo('#end', 8000, {onAfter:function(){ $.scrollTo(0, 6000) } });
		}
			
	});
	togglelements('instant', 'img.hide', 630, 460);
	//setScreenClass();
});

$(window).resize(function(){
  togglelements('slow', 'img.hide', 630, 460);
  //setScreenClass();
});

/* function to tollge encombrant elements */

function togglelements(speed, klass, y, x){
	
	var docheight = $(window).height();
		
	if (speed == 'instant'){
	
		if (docheight <= y ) {
			$(klass).toggle();
		};
		
	} else {
		
		if (docheight <= y ) {
			$(klass).fadeOut( speed );
		} else if (docheight > y ) {
			$(klass).fadeIn( speed );
		};
		
	};
};
	
/*
	$(class).each( function() {
    var classStr = this.className;
    var classes = {}
    classStr.replace( /(x|y)([0-9]+)/gi,
        function( str, key, val ) {
            classes[key] = val;
        }
    );
    // console.log( classes );
	alert(classes[x]);
});

/*
 * {
 *     width:  '120',
 *     height: '30',
 *     icon:   'Left',
 *     color:  'Red'
 * }
 */
 
/*
// reoltuon configuration



	//  Following transition classes will be declared:
	//
	//	classname		  screenwidth
	//	------------------------------------------
	//	pda_v			  240px			
	//	pda_h			  320px			
	//	ultralow		  320px -  640px	
	//	screen_lo		  640px -  800px	
	//	screen_med		  800px - 1024px	
	//	screen_hi		 1024px - 1280px	
	//	screen_wide				> 1280px			

function setScreenClass(){
	var fmt = document.documentElement.clientWidth;
	var cls = (fmt<=240)?'pda_ver':(fmt>240&&fmt<=320)?'pda_hor':(fmt>320&&fmt<=640)?'screen_ultralow':(fmt>640&&fmt<=800)?'screen_low':(fmt>800&&fmt<=1024)?'screen_med':(fmt>1024&&fmt<=1280)?'screen_high':'screen_wide';
	document.getElementById('count').innerHTML=fmt+'px -> '+cls;
	document.body.className=cls;
	};


// iphone and ipod touch
var size_iphone ={
x:320,
y:480
};

// old computer
var size_oldpc ={
x:800,
y:600
};

// asus eeepc small
var size_epc1 ={
x:960,
y:576
 }
 
// asus eeepc small
var size_15iinch ={
x:960,
y:576
 }
*/



 


// $.scrollTo.window().queue([]).stop(); 