/**
 * 
 * Handle Dropdown Menu
 * 
 * @param id
 * @return nix
 * @author punger
 */
function handleMenuEvent(id, permalink) {

	var currentPath = $(location).attr('href');
	
	if(currentPath.search(/overview_item.+/) != -1)
	{
		currentPath = currentPath.split('&');
		currentPath = currentPath[0];
	}
	
	if(currentPath != permalink)
	{	
		$(location).attr('href',permalink + '#overview_item=' + id + '|permalink=' + permalink);
	}
	
	window.location.hash = '';
	var position = $('#overview_item_'+id).position();
	if(position !== null) $('html,body').animate({scrollTop: position.top},{duration: 1000});
}

/**
 * 
 * Get Parameter from URL
 * 
 * @param name
 * @return
 */
function gup( name, indicator )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?"+indicator+"]"+name+"=([^&|]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}



/**
 * Process header-form 
 * 
 * @return
 */
function processForm() {
	
	var von 			= $('#von').val();
	var bis 			= $('#bis').val();
	var erwachsene 		= $('#erwachsene').val();
	var kinder     		= $('#kinder').val();
	var appartement 	= $('#appartement_wahl').val();
	appartement = appartement.replace(' ','~~~');
	
	var redirect = 'http://www.seeappartement.com/kontakt/';

	if($(location).attr('href').match(/\en\//)) var redirect='http://www.seeappartement.com/en/kontakt/';

	//alert(redirect + '#fromHeader=true|von='+von+'|bis='+bis+'|erwachsene='+erwachsene+'|kinder='+kinder+'|appartement='+appartement+'|');
	
	if($(location).attr('href').replace('#','') != redirect)
	{
		$(location).attr('href', redirect + '#fromHeader=true|von='+von+'|bis='+bis+'|erwachsene='+erwachsene+'|kinder='+kinder+'|appartement='+appartement+'|');
	}
	else {
	
		$('#von_kontaktform').val(von);
		$('#bis_kontaktform').val(bis);
		$('#erwachsene_kontaktform').val(erwachsene);
		$('#kinder_kontaktform').val(kinder);
		$('#appartement_wahl_kontaktform').val(appartement);

		var position = $('#nav_main').position();

		$('html,body').animate({scrollTop: (position.top+20) +'px'},{duration: 1000,complete:function(){
			
			if(!$('#buchungsanfrage').is(':visible')) {
				$('#buchungsanfrage').show('fast');
			}
		}});
	}
}








