	 $(document).ready(function() {

		//var h = History();
		//h.init();
		//h.set_location('');
		

		//loadStartPage();

    	//$('#nav li ul').addClass('firstlevel'); // starts menu
		
		//$('#nav li').hover(function () { //mouse over
  		//		    $(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
  		//		},function (){ // mouse away
		//			$(this).find('ul:first').css({visibility: "hidden"});
  		//});  //end $('#nav li').hover
   	}); //  $(document).ready 
  		 
	window.onload = function(){
		
		//var h = History();
		//h.init();
		//h.set_location('');
		

		loadStartPage();

    	$('#nav li ul').addClass('firstlevel'); // starts menu
		
		$('#nav li').hover(function () { //mouse over
  				    $(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
  				},function (){ // mouse away
					$(this).find('ul:first').css({visibility: "hidden"});
  		});  //end $('#nav li').hover
		
		
	}  	

	function loadStartPage(){
					init();
					startCycle();
					

	} // end LoadStartPage

	function startCycle(){
		try 
					{
						$('#pics')
							.cycle('stop')
							.after('<div id="pager" />').after('<br class="trick" />')
							.cycle({
								fx: 'fadeZoom',
								pager:'#pager',
								speed:300,
								timeout:10000,
								pause:1
								
							});
					}
					catch(er)
					{
						alert('error');
					} // end Try Catch
	} // end function startcycle()
   function init(){
   			
			$('#pics').cycle('stop')
			
  		    $('li a').unbind(); //reset's all events for onclick			
  		    $('li a').click(function(e){	
  		    	var qstring;
  		    	var rel  = this.rel
				if (!this.rel){
		   			qstring = (this.href +' div'); 
		   			rel = 'div';
				}else{
					if (this.rel == 'no'){
						return false;
						
					} else if (this.rel == 'link') {
						return true;
					
					
					} else {
					  	qstring = this.href +" '." + this.rel + "'";
					  	rel = "." + this.rel;	
					} // end if
				} //end if


				
				var thref = this.href
				var a = thref.split("#")
				
				if (a.length==2){
					thref = a[0];
					rel = "#" + a[1];
				}
				
				var pos = $('#page_content').position();
				//alert(thref + ' ' + rel);
				
				$('<div id="overlay" />')
					.css({	
							top:pos.top , 
							left: pos.left,
							height:$('#page_content').height(),
							width:$('#page_content').width()
						}) 
					.appendTo('#page_content')
					.fadeIn('400',function(){
									$.ajax({
										type: 'GET',
										url: thref ,
										data:'',
										cashe:false,
										success:function(data){
											$('#page_content').empty();				
											$('<div />').append(data).find(rel).appendTo('#page_content');
											$('#overlay').fadeOut(400,function(){
												$(this).remove()
											}); // end kill overlay
											init();
											startCycle();
										}, // end success
										error : function(data){
											$('<div />').append(data).appendTo('#page_content');
											$('#overlay').fadeOut(400,function(){
												$(this).remove()
											}); // end kill overlay
										}// end error
									}); // end $.ajax
					}); // end fadeIn $('<div id="overlay" />)
			return false
   	});   // end   $('li a').click(function(e){
} // end init();

