// page object namespace - contains global vars and functions
		var PO = {						
			webkit:true,
			FF:false,
			OO:false,
			IE:false
		};	
		
		/************************************ xml for menu **************************************/
		PO.getWebkit = function(){
			PO.webkit = true;
			PO.FF = /Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent);
			PO.OO = /Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent);
			PO.IE = /MSIE[\/\s](\d+\.\d+)/.test(navigator.userAgent);
			
			if (PO.FF || PO.OO || PO.IE) {
				//test for Firefox and OPERA and IE
				PO.webkit = false;
			}
		}
		
		PO.resetVars = function(){
					    // whether the section has been loaded (ie the text)
		}
		
		$(window).resize(function() {
  			PO.doResize();
		});
		
		PO.adjustCSS = function(){
			if(PO.IE){
				return;	
			}
			$('#wrapper').css({'min-height':500});
			$('#wrapper').css({'min-height': $(document).height()-140});
			$('#home-link').attr("href", $('#home-link').attr("href") + "?lang=" + langObject.lang + "");
		}
		
		// read xml and create the main menu
		PO.readMainXML = function(pName){
			$.ajax({
			  type: "GET",
				 url: "content/struttura.xml",
				 dataType: "xml",
				 success: function(xml) {
					$("#mainMenu ul").empty();
					$("#rightMenu ul").empty();
					
					$(xml).find('localization').each(function(){
						if($(this).attr('lang') == langObject.lang){
							//create menu
							var numSections = $(this).find('mainMenu').children().length;
							var counter = 0;
							$(this).find('mainMenu section').each(function(){
								var id=$(this).attr("id");
								$("#mainMenu ul").append('<li><a href="' + $(this).attr("page") + '"  id="' + id + '-link">' + $(this).attr("title").toUpperCase() + '</a></li>');
								counter ++;
								if(counter < numSections){
									$("#mainMenu ul").append('<li class="divider">/</li>');
								}
								if(pName == id){
									$('#' + id + '-link').addClass('selected');
								}
							});
							
							numSections = $(this).find('secondaryMenu').children().length;
							counter = 0;
							$(this).find('secondaryMenu section').each(function(){
								var id=$(this).attr("id");
								$("#rightMenu ul").append('<li><a href="' + $(this).attr("page") + '"  id="' + $(this).attr("id") + '-link">' + $(this).attr("title").toUpperCase() + '</a></li>');
								counter ++;
								if(counter < numSections){
									$("#rightMenu ul").append('<li class="divider">/</li>');
								}	
								if(pName == id){
									$('#' + id + '-link').addClass('selected');
								}
							});
						}
					});
					
					
					$("#mainMenu ul").append('<li><a href="new_products_2011.htm?lang=' + langObject.lang + '"  id="new_2011-link" class="novita">' + langObject.new_2011 + '</a></li>');
					if(pName=='new_products_2011'){
						$('#new_2011-link').addClass('selected');
					}
				 },
				 error:function(e){
					 //console.log(e);
				}
			}); //close $.ajax(	
			PO.checkIE();
		}
		
		PO.checkIE = function(){
			
			if( $.cookie("hideIE") != "yes" && PO.IE && $.browser.version < 8){
				$('#avviso').html(langObject.avviso);
				$('#avvisoLeft').html(langObject.avvisoLeft);
				$('#avvisoRight').html('<a href="javascript:PO.hideAvviso();void(0);">' + langObject.avvisoRight + '</a>');
				$('#avvisoIE').slideDown(300);
			}
		}
		
		PO.hideAvviso = function(){
			$('#avvisoIE').slideUp(300, function(){
												 
			});
			$.cookie("hideIE", "yes");
		}
		
		PO.readHeader = function(){
			 var div = $('<div class="socialNetwork"></div>');
			 	div.append('<a href="http://www.issuu.com/livingdifferent" rel="ISSUU" target="_blank"><img src="img/social_icons/issuu_small.jpg"></a>')
					.append('<a href="http://www.delicious.com/save?v=5&noui&jump=close&url=www.serralunga.com&title=Serralunga%20Living%20Different" rel="DELICIOUS" target="_blank"><img src="img/social_icons/delicious_small.jpg"></a>')
					.append('<a href="http://www.flickr.com/photos/livingdifferent" rel="FLICKR" target="_blank"><img src="img/social_icons/flickr_small.jpg"></a>')
                    .append('<a href="http://twitter.com/livingdifferent" rel="TWITTER" target="_blank"><img src="img/social_icons/twitter_small.jpg"></a>')
                    .append('<a href="http://www.facebook.com/serralungalivingdifferent" rel="FACEBOOK" target="_blank"><img src="img/social_icons/facebook_small.jpg"></a>')
                    .append('<div id="socialText"></div>');
              $('header').append(div);
			  
			  $('.socialNetwork a').bind({
				mouseenter: function() {
					$('#socialText').html($(this).attr('rel'));
  				},
				mouseleave: function() {
    				$('#socialText').html("");
  				}
			})
		}
		
		PO.readFooter = function(){
			$.ajax({
			  type: "GET",
				 url: "include/footer.htm",
				 dataType: "html",
				 success: function(result) {
					$("footer .content").empty();
					$("footer .content").html(result);
					if(pageName!=''){
						$("a#EN").attr("href" , pageName + ".htm?lang=en");
						$("a#IT").attr("href" , pageName + ".htm?lang=it");
					}
					$("#footer_azienda").html(langObject.azienda);
					$("#footer_showroom").html(langObject.showroom);
					$("#datiSocietariLink").html(langObject.dati_societari_link);
					
					$('#datiSocietariLink').click(function(e){
						e.preventDefault();
						
						if($('#datiSocietari').is(':hidden')){
							if(PO.FF || PO.IE){
								$('html').animate({ scrollTop: $(document).height()}, 800, 'easeOutExpo');
							}else{
								$('body').animate({ scrollTop: $(document).height()}, 800, 'easeOutExpo');
							}
						}
						$('#datiSocietari').slideToggle(800, 'easeOutExpo');
					})
					if(langObject.lang=='en'){
						$("a#EN").hide();
					}else{
						$("a#IT").hide();
					}
				 }
			});
			PO.readDatiSocietari();
			
		}
		
		PO.readDatiSocietari = function(){
			$.ajax({
			  type: "GET",
				 url: "include/dati_societari.htm",
				 dataType: "html",
				 success: function(result) {
					$("#datiSocietari .content").empty();
					$("#datiSocietari .content").html(result);
					$("#datiSocietari #dati_text").html(langObject.dati_text);
					$("#datiSocietari #rag_soc_text").html(langObject.rag_soc_text);
					$("#datiSocietari #sede_text").html(langObject.sede_text);
					$("#datiSocietari #cod_fisc_text").html(langObject.cod_fisc_text);
					$("#datiSocietari #cap_soc_text").html(langObject.cap_soc_text);
					$("#datiSocietari #reg_text").html(langObject.reg_text);
					$("#datiSocietari #rea_text").html(langObject.rea_text);
					
				 }
			});
		}
		
		PO.doLangChange = function(){
			
		}
		/************************************* sections *****************************************/
		
		PO.loadNewSection = function(){
			
		}
		
		PO.loadNewSubSection = function(){
			
		}
		
		PO.animateSection = function(){
			
		}	
				
		/********************************* resize *****************************************/
		
		PO.doResize = function(){
			PO.adjustCSS();
		}
		
		PO.resizeElement = function(elem){
			
						  
		 }
