// Changes main navigation according to the site content
function setupMainNavi(sUrl) {
	var p = new Flog.UriParser(sUrl);
	var sColor = '#D6E342';
	
  if (p.pathname == '/index.php') {
    $('mainNavSearch').style.color = sColor;
  } else {
    if ($('mainNavAboutID') != undefined) {
      $('mainNavAbout').style.color = sColor;
    }
    if ($('mainNavServicesID') != undefined) {
      $('mainNavServices').style.color = sColor;
    }
    if ($('mainNavPhotographersID') != undefined) {
      $('mainNavPhotographers').style.color = sColor;
    }
    if ($('mainNavImagesID') != undefined) {
      $('mainNavImages').style.color = sColor;
    }
  }
}

// Marking actual sub navigation as active
function changeNaviItem(sUrl, sIdPrefix, sAddClassName) {
		var p = new Flog.UriParser(sUrl);
		aNameFields = p.pathname.split('.');
		sIdName = sIdPrefix +aNameFields[0].substring(1);

		if ($(sIdName) != undefined) {
			$(sIdName).addClassName(sAddClassName);
		}
}

function initInfoButton() {
   $('searchInfo').observe('mouseover', function() {
       $('searchInfoTxt').style.display = 'block';
       $('hpInfo').style.display = 'none';
   });
   $('searchInfo').observe('mouseout', function() {
       $('searchInfoTxt').style.display = 'none';
       $('hpInfo').style.display = 'block';
   });
}

// Change layout specific content
function setupLayout (sUrl, oUserAgent) {
	var iPhone=((oUserAgent.match(/iPhone/i)) || (oUserAgent.match(/iPod/i)));
	var iPad=oUserAgent.match(/iPad/i);
	var p = new Flog.UriParser(sUrl);

  if ((p.pathname == '/index.php' && p.querystring.length > 0) || p.pathname == '/site_suchergebnis.shtml') {
    // Change Layout for Searchpage
		if (iPhone || iPad) {
			$('footer').style.display = 'none';
			$('footerBg').update($('footer').innerHTML);
			$('footerBg').addClassName('footerLine');
      $('startSearchButton').src = 'http://img.visualimpact.ch/public/userfiles/image/go_pad.png';
		}

    // Change View specific
    if (p.querystring['module'] == 'result') {
      initInfoButton();

    	$('entireSearch').style.display = 'block';

      // Fade out link
      $$('#extendedSearchLink a').each(function(d){
          d.style.color = '#ccc';
      });
    	
    	$('content').style.marginLeft = '370px';
    	$('siteContent').style.width = ($('headerBg').getWidth() - 370) + 'px';
    	$('firstSearchFormBorder').style.marginTop = '-1px';

      // Remove Lightbox functionality for IPad
  		if (iPhone || iPad) {
  			$('footerBg').style.display = 'none';
        $$('div.resultThumbLinkBox').each(function(d){
          d.style.display = 'none';
        });
        $('lightbox_header').style.display = 'none';
        $('lightbox_content_table').style.display = 'none';
        $('add_lightbox').style.display = 'none';
  		}
    }
  } else if (p.pathname == '/index.php' || p.pathname == '/') {
    initInfoButton();

    // Change Layout for homepage (identified by "/" or "/index.php")
    if (iPhone || iPad) {
      $('startSearchButton').src = 'http://img.visualimpact.ch/public/userfiles/image/go_pad.png';    
  	}

  	$('entireSearch').style.display = 'block';
  	$('entireSearch').style.left = '20px';
  	$('entireSearch').style.top = '160px';
  	
  	// Change search field looking
  	toggleExtendedSearchForm();			
  }
}



