/*
 * AES.INFO JS
 */
 
// on page load call AES_init
$(document).ready(AES_init);


// AES init
function AES_init(){



	$('a#link_information').click(function(event){
		$('#information').toggle();
		return false;
	});

	$('a#link_informationclose').click(function(event){
		$('#information').hide();
		return false;
	});


/*	
	$('.link_switch').click(function(){
		aes_switch($(this));
		return false;
	});

*/


 	//$('#thecontent').fadeIn('fast');
 	
 	/*
	$('img').onload = function(){
		$('img').fadeIn('slow');
		};
	*/
	
	//imgPreloader = new Image();
	//imgPreloader.onload = function() {
	
	
	
	/*
	$('a#section-next').click(function(event){
	
		if (pagecurr < (pagecount-1)) {
			//alert('stay on this page');
			pagecurr++;
			window.location.href = '#' + (pagecurr+1);
			eval("pg = " + pagenum + "+" + pagecurr + " + 1;");
			switchcontent(pagecurr, pg);
			return false;
		} else {
			location.href=linknext;
			return false;
			//alert('go to next project');
		};
	});
	

	$('a#section-prev').click(function(event){
		if (pagecurr > (0)) {
			//alert('stay on this page');
			pagecurr--;
			window.location.href = '#' + (pagecurr+1);
			eval("pg = " + pagenum + "+" + pagecurr + " + 1;");
			switchcontent(pagecurr, pg);
			return false;
		} else {
			location.href=linkprev;
			return false;
			//alert('go to previous project');
		
		};
	});
	*/

  //aeshomepage = 'true';
  //alert('AES Homepage: ' + aeshomepage);
  
  //if (typeof(aeshomepage) == 'undefined') alert('No Homepage');

	window.onresize=function(){resizer();}


}
    
    
    
    
    
    
function resizer() {
	aesheight=$(window).height();
	aeswidth=$(window).width();
	aescontact=$('#section-contact').offset();
	aescontactwidth=$('#section-contact').width();
	$('#section-contact').css('width', $('#section-contact').width() + 'px');
	

	$('#status').html('Window: ' + aeswidth + '&times;' + aesheight + '<br>' + 'Contact: ' + aescontact.left + ' / W: ' + aescontactwidth);


	if (aescontact.left < 470) $('#section-contact').css({'right':'auto','left':'470px'});
	if (aeswidth > 480 + aescontactwidth) $('#section-contact').css({'right':'10px','left':'auto'});

	if (aesheight < 640 && typeof(aeshomepage) == 'undefined') {
		$('#section-title').css({'bottom':'auto','left':'2px','position':'relative','float':'left'});
		$('#section-page').css({'bottom':'auto','right':'0px','position':'relative','float':'right'});

		$('#section-menu').css({'position':'absolute'});
		$('#section-nextprev').css({'position':'absolute'});
		
		if (aescontact.left < 470) $('#section-contact').css({'position':'absolute','left':'470px'});
		if (aeswidth > 480 + aescontactwidth) $('#section-contact').css({'position':'absolute','float':'right'});

		};
	if (aesheight > 640 && typeof(aeshomepage) == 'undefined') {
		$('#section-title').css({'top':'auto','bottom':'10px','left':'12px','position':'fixed'});
		$('#section-page').css({'top':'auto','bottom':'10px','right':'10px','position':'fixed'});
		};


}


pages = 1;


function updateitems(pages,pages_total) {

	//global pagenumber;
	pages_now = pagenumber * pages;
	if (pages_now > pages_total) pages_now = pages_total;
	//pages_now = pagenumber;
	$('#section-title').html("Displaying "+pages_now+" of "+pages_total+" items");
	//alert('PAGESZ');
	window.pagenumber = eval(pagenumber+"+1");
	
	$('.item_slideshow').unbind();
	$('.item_slideshow').cycle();
	
	$('.link_switch').unbind('click');
	$('.link_switch').click(function(){
		aes_switch($(this));
		return false;
	});

}


function aes_switch(what) {

	//alert(what);
	aes_parent = $(what.parent());
	
	aes_parent.find('.item_image').toggle();
	aes_parent.find('.item_content').toggle();
	
	return false;

}












function switchcontent(page, pg) {
  //$('#thecontent').fadeOut('fast',function(){$('#thecontent').html(pages[page]).fadeIn('fast');});
  $('#thecontent').html(pages[page]);
  $('#section-page').html("Pg. "+pg);
};




function fader() {
  //$('#thecontent').fadeOut('fast');
};



function status_on(id) {
  $('#section-page').html('Pg. ' + status_page[id]);
  $('#section-title').html(status_title[id]);
};


function status_off() {
  $('#section-page').html('Pg. 1');
  //$('#section-title').html(status_title_this);
  $('#section-title').html('Contents');
};
