/**
* HTML5 Hack für ältere Browser
**/
document.createElement("header");
document.createElement("section");
document.createElement("nav");
document.createElement("aside");

hurra_startStack=function()
{
	/* futuresign.com durch domainnamen ersetzen */
	hurra_linkTargetSetter('camping-woerthersee.at',new Array(),new Array('.jpg','.jpeg','.png','.gif','.tif','.bmp', '.eps', '.mp3', '.pdf','.doc','.docx','.xls','.xlsx','.zip','.rar'));
	hurra_set_selects();
};
hurra_registerOnLoad = function(func)
{
	var hurraOrgOnLoad = hurra_startStack;
	hurra_startStack = function ()
	{
		hurraOrgOnLoad();
		func();
		return;
	}
}

var SelectList = new Array();
function hurra_set_selects()
{
	SelectList = document.getElementsByTagName("select");
}
function hurra_hide_select_for_ie6()
{
	for(var i = 0; i < SelectList.length; i++)
	{
		SelectList[i].style.visibility = "hidden";
	}
}
function hurra_show_select_for_ie6()
{
	for(var i = 0; i < SelectList.length; i++)
	{
		SelectList[i].style.visibility = "visible";
	}
}

var hurraRanOnload=false; // Flag to determine if we've ran the starting stack already.
if(document.addEventListener)
{ 
	// Mozilla actually has a DOM READY event.
	document.addEventListener
	(
	 	"DOMContentLoaded",
		function(){if (!hurraRanOnload) {hurraRanOnload=true; hurra_startStack();}},
		false
	);
} 
else if(document.all && !window.opera)
{
	// This is the IE style which exploits a property of the (standards defined) defer attribute
	document.write("<scr" + "ipt id='DOMReady' defer=true " + "src=//:><\/scr" + "ipt>");
	document.getElementById("DOMReady").onreadystatechange=function()
	{
		if(this.readyState=="complete"&&(!hurraRanOnload))
		{
			hurraRanOnload=true;
			hurra_startStack();
		}
	}
}
var hurraOrgOnLoad=window.onload;
window.onload=function()
{
	if (typeof(hurraOrgOnLoad)=='function')
	{
		hurraOrgOnLoad();
	}
	if(!hurraRanOnload)
	{
		hurraRanOnload=true;
		hurra_startStack();
	}
}
/* Hilfsfunktion für href ohne return */
function hurra_empty(){}
/* customized alert and confirm */
var HurraLockPageOpacity = 80;
var HurraMSG;
var HurraLockPage;

function hurra_alert(title, text, functionOk)
{
	hurra_createMSG('alert', title, text, false, functionOk);
}
function hurra_confirm(title, text, functionOk, functionFalse)
{
	hurra_createMSG('confirm', title, text, functionOk, functionFalse);
}
function hurra_createMSG(type, title, text, functionOk, functionFalse)
{
	hurra_lockPage();
	var pageSize = hurra_getPageSize();
	var pageScroll = hurra_getPageScroll();
	HurraMSG = document.createElement('div');
	HurraMSG.id = 'msg';
	HurraMSG.style.display = 'block';
	document.body.appendChild(HurraMSG);
	var bttnHTML = '';
	switch(type)
	{
		case'confirm':
			var imgSrc = 'pix/msg/icon_frage.gif';
			var bttnHTML = '<img class="msg_bttn_confirmOK" onclick="eval(\''+functionOk+'\'); hurra_closeMSG();" onmouseover="this.src=\'pix/msg/button_ok_over.gif\'" onmouseout="this.src=\'pix/msg/button_ok.gif\'" src="pix/msg/button_ok.gif" /><img class="msg_bttn_confirmAbbr" onclick="eval(\''+functionFalse+'\'); hurra_closeMSG();" onmouseover="this.src=\'pix/msg/button_abbrechen_over.gif\'" onmouseout="this.src=\'pix/msg/button_abbrechen.gif\'" src="pix/msg/button_abbrechen.gif" />';
			break;
		default:
			var imgSrc = 'pix/msg/icon_alert.gif';
			var bttnHTML = '<img class="msg_bttn" onclick="eval(\''+functionFalse+'\'); hurra_closeMSG();" onmouseover="this.src=\'pix/msg/button_ok_over.gif\'" onmouseout="this.src=\'pix/msg/button_ok.gif\'" src="pix/msg/button_ok.gif" />';
			break;			
	}
	
	HurraMSG.innerHTML =
	'<div id="'+HurraMSG.id+'">'
		+'<img id="msg_ico" src="'+imgSrc+'" />'
		+'<div id="msg_top">'
			+'<img id="msg_close" onclick="eval(\''+functionFalse+'\'); hurra_closeMSG();" onmouseover="this.src=\'pix/msg/button_schliessen_over.gif\'" onmouseout="this.src=\'pix/msg/button_schliessen.gif\'" src="pix/msg/button_schliessen.gif" />'
		+'</div>'
		+'<div id="msg_content">'
			+'<div id="msg_title">'
				+title
			+'</div>'
			+text
			+bttnHTML
		+'</div>'
	+'</div>';
	var msgHeight = 0;
	for(var i = 0; i < HurraMSG.childNodes.length; i++)
	{
		if(HurraMSG.childNodes[i].nodeName.toLowerCase() == 'div')
		{
			 msgHeight += HurraMSG.childNodes[i].offsetHeight;	
		}
	}
	try
	{
		HurraMSG.style.top = (pageScroll.yScroll + (pageSize.windowHeight - msgHeight) / 2) + 'px';
		HurraMSG.style.left = ((pageSize.pageWidth - HurraMSG.offsetWidth) / 2) + 'px';
	}
	catch(e){null;}
}
function hurra_closeMSG()
{
	try
	{
		hurra_removeNode(HurraMSG);
		HurraMSG = null;
		hurra_unlockPage();
	}
	catch(e){null;}
}
function hurra_lockPage()
{
	var pageSize = hurra_getPageSize();
	HurraLockPage = document.createElement('div');
	HurraLockPage.id = 'page_lock';
	HurraLockPage.style.display = 'block';
	document.body.appendChild(HurraLockPage);
	try
	{
		hurra_hide_select_for_ie6();
		
		HurraLockPage.style.filter = 'alpha(opacity='+HurraLockPageOpacity +')';
		HurraLockPage.style.opacity = HurraLockPageOpacity/100;
		HurraLockPage.style.height = pageSize.pageHeight + 'px';
		HurraLockPage.style.width = '100%';
	}
	catch(e){null;}
}
function hurra_unlockPage()
{
	try
	{
		hurra_show_select_for_ie6();
		
		hurra_removeNode(HurraLockPage);
		HurraLockPage = null;
	}
	catch(e){null;}
}

/* Hilfsfunktionen um die Seitengröße und den scrollstand auszumessen */
function hurra_getPageSize()
{
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY)
	{	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if(document.body.scrollHeight > document.body.offsetHeight)
	{// all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else
	{// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if(self.innerHeight)
	{// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if(document.documentElement && document.documentElement.clientHeight)
	{// Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if(document.body)
	{// other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	}
	else
	{ 
		pageHeight = yScroll;
	}
	
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth)
	{	
		pageWidth = windowWidth;
	}
	else
	{
		pageWidth = xScroll;
	}	
	var arrayPageSize = new Object();
	arrayPageSize.pageWidth = pageWidth;
	arrayPageSize.pageHeight = pageHeight;
	arrayPageSize.windowWidth = windowWidth;
	arrayPageSize.windowHeight = windowHeight;
	return arrayPageSize;
}
function hurra_getPageScroll()
{
	var yScroll;
	if (self.pageYOffset)
	{
		yScroll = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{// Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	}
	else if(document.body)
	{// all other Explorers
		yScroll = document.body.scrollTop;
	}
	var arrayPageScroll = new Object(); 
	arrayPageScroll.yScroll = yScroll; 
	arrayPageScroll.xScroll = ''; 
	return arrayPageScroll;
}
function hurra_return_absolute_pos(obj)
{
	var pos = new Object();
	pos.top = 0;
	pos.left = 0;
	while(obj && obj.nodeName.toLowerCase() != 'body')
	{
		pos.top += obj.offsetTop;
		pos.left += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return pos;
}

/* Formularüberprüfungsfunktionen */
function hurra_check_length(string, minLength)
{
	if (string.length < minLength){return false;}
	return true;
}
function hurra_check_mail(string)
{
	var re = /^[a-zA-Z0-9_\.\-]+@([a-zA-Z0-9\-_]|\.)*[a-zA-Z0-9]{2,3}\.[a-zA-Z0-9]{2,4}/;
	if (!re.test(string)){return false;}
	return true;
}

/* Linktargetsetter */
function hurra_linkTargetSetter(domain,forbiddenBlank,allowedBlank)
{
	domain = domain.toLowerCase();
	var doclinks = document.getElementsByTagName("a");
	for (var i = 0; i < doclinks.length; i++)
	{
		var url = doclinks[i].href.toLowerCase();
		if((url.indexOf('javascript') == -1 && url.indexOf(domain) == -1 && hurra_isInTargetSetterArray(forbiddenBlank, url) === false) || (hurra_isInTargetSetterArray(allowedBlank, url) === true))
		{
			doclinks[i].target = "_blank";
		}
		try{doclinks[i].execCommand("BackgroundImageCache",false,true);}catch(err){}

	}
}
function hurra_isInTargetSetterArray(array, value)
{
	for(var i = 0; i < array.length; i++)
	{
		if(value.indexOf(array[i]) != -1)
		{
			return true;	
		}
	}
	return false;	
}

/* Eventhandler */
function hurra_addEvent( obj, type, fn )
{
   obj.fn = fn;
   if (obj.addEventListener) {
      obj.addEventListener( type, fn, false );
   } else if (obj.attachEvent) {
      obj["e"+type+fn] = fn;
      obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
      obj.attachEvent( "on"+type, obj[type+fn] );
   }
}
function hurra_removeEvent( obj, type, fn )
{
   if (obj.removeEventListener) {
      obj.removeEventListener( type, fn, false );
   } else if (obj.detachEvent) {
      obj.detachEvent( "on"+type, obj[type+fn] );
      obj[type+fn] = null;
      obj["e"+type+fn] = null;
   }
}

/* HTML Element eintfernen */
function hurra_removeNode(Node)
{
	var removed = false;
	try
	{
		Node.removeNode(true);
		removed = true;
	}catch(e){}
	try
	{
		Node.parentNode.removeChild(Node);	
		removed = true;
	}catch(e){}
	return removed;
}
/* HTTP Request (=Ajax Request) */
var requestQue = new HttpRequestQue();
function HttpRequestQue()
{
	this.List = new Array();
	this.requestAddWork = false;
	
	this.add = function(http)
	{
		var index = this.List.length;
		this.List[index] = new Http(http.url, http.onreadyst, http.method, http.body, http.headers, http.sync);
		this.List[index].onreadyst = http.onreadyst;
		this.send();
	}
	this.send = function()
	{
		if(this.requestAddWork === false)
		{
			if(this.List.length>0)
			{
				this.requestAddWork = true;
				this.List[0].doRequest();
			}
		}
	}
	this.requExecuted = function()
	{
		var cacheList = new Array();
		for (var i = 0; i < (this.List.length - 1); i ++)
		{
			cacheList[i] = this.List[i+1];
		}
		this.List = cacheList;
		cacheList = null;
		this.requestAddWork = false;
		this.send();
	}
}
var request = null;
function Http(url, onreadyst, method, body, headers, sync)
{
	this.url = url;
	this.onreadyst = onreadyst || function(){};
	this.method = method || 'GET';
	this.body = body || null;
	this.headers = headers || false;
	this.sync = sync || true;
	this.abortReq = false;
	this.req = (window.XMLHttpRequest)
		?
		new XMLHttpRequest()
		:
		((window.ActiveXObject)
		?
		new ActiveXObject("Microsoft.XMLHTTP")
		:
		false
		);
	this.doRequest = function()
	{
		this.req.open(this.method,this.url,this.sync);
		if (this.headers)
		{
			for (var i = 0; i < this.headers.length; i += 2)
			{
				this.req.setRequestHeader(
					this.headers[i], this.headers[i+1]
				);
			}
		}
		this.req.onreadystatechange = this.onreadyst;
		this.req.send(this.body);
	}
}

/* Flashintegration */
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}
function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';
  AC_FL_RunContent_GET = '';
  return str;
}
//fusi extension Set_AC_FL_RunContent_GET(?get=xx); is to use, before calling AC_FL_RunContent
var AC_FL_RunContent_GET = '';
function Set_AC_FL_RunContent_GET(get){AC_FL_RunContent_GET = get;}
function AC_SW_GetSWFObjectForMoz(name)
{
	var embeds = document.getElementsByTagName("embed");
	for(var i = 0; i < embeds.length; i++)
	{
		if(embeds[i].name == name){return embeds[i];}
	}
	return false;
}
//end fusi extension
function AC_FL_RunContent()
{
	var ret = 
	AC_GetArgs
	(
	 	arguments, ".swf"+AC_FL_RunContent_GET, "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash"
	);
	return AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_SW_RunContent()
{
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_GetArgs(args, ext, srcParamName, classid, mimeType)
{
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    
    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
	  	ret.embedAttrs[args[i]] = args[i+1];//mozilla bug - cant catche the Element - have to use AC_SW_GetSWFObjectForMoz(name) if you need the Object
      case "id":
	  	ret.objAttrs[args[i]] = args[i+1];
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
function hurra_flash_detection(required, max)
{
	var required_version = required;
	var max_version = max;
	var available_version = 0;

	if(typeof(navigator.plugins["Shockwave Flash"]) == "object")
	{
		var description = navigator.plugins["Shockwave Flash"].description;
		available_version = description.substr(16, (description.indexOf(".", 16) - 16));
	}
	else if(typeof(ActiveXObject) == "function")
	{
		for(var i = 2; i < (max_version + 1); i ++)
		{
			try
			{
				if(typeof(new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i)) == "object")
				{
					available_version = i;
				}
		   }
		   catch(error)
		   {
		   }
		}
	}
	return [available_version, required_version];
}




/* Smooth scrolling
   Changes links that link to other parts of this page to scroll
   smoothly to those links rather than jump to them directly, which
   can be a little disorienting.
   
   sil, http://www.kryogenix.org/
   
   v1.0 2003-11-11
   v1.1 2005-06-16 wrap it up in an object
*/

var ss = {
  fixAllLinks: function() {
    // Get a list of all links in the page
    var allLinks = document.getElementsByTagName('a');
    // Walk through the list
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if ((lnk.href && lnk.href.indexOf('#') != -1) && 
          ( (lnk.pathname == location.pathname) ||
	    ('/'+lnk.pathname == location.pathname) ) && 
          (lnk.search == location.search)) {
        // If the link is internal to the page (begins in #)
        // then attach the smoothScroll function as an onclick
        // event handler
        ss.addEvent(lnk,'click',ss.smoothScroll);
      }
    }
  },

  smoothScroll: function(e) {
    // This is an event handler; get the clicked on element,
    // in a cross-browser fashion
    if (window.event) {
      target = window.event.srcElement;
    } else if (e) {
      target = e.target;
    } else return;

    // Make sure that the target is an element, not a text node
    // within an element
    if (target.nodeName.toLowerCase() != 'a') {
      target = target.parentNode;
    }
  
    // Paranoia; check this is an A tag
    if (target.nodeName.toLowerCase() != 'a') return;
  
    // Find the <a name> tag corresponding to this href
    // First strip off the hash (first character)
    anchor = target.hash.substr(1);
    // Now loop all A tags until we find one with that name
    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }
    if (!destinationLink) destinationLink = document.getElementById(anchor);

    // If we didn't find a destination, give up and let the browser do
    // its thing
    if (!destinationLink) return true;
  
    // Find the destination's position
    var destx = destinationLink.offsetLeft; 
    var desty = destinationLink.offsetTop;
    var thisNode = destinationLink;
    while (thisNode.offsetParent && 
          (thisNode.offsetParent != document.body)) {
      thisNode = thisNode.offsetParent;
      destx += thisNode.offsetLeft;
      desty += thisNode.offsetTop;
    }
  
    // Stop any current scrolling
    clearInterval(ss.INTERVAL);
  
    cypos = ss.getCurrentYPos();
  
    ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
    ss.INTERVAL =
setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);
  
    // And stop the actual click happening
    if (window.event) {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
    }
    if (e && e.preventDefault && e.stopPropagation) {
      e.preventDefault();
      e.stopPropagation();
    }
  },

  scrollWindow: function(scramount,dest,anchor) {
    wascypos = ss.getCurrentYPos();
    isAbove = (wascypos < dest);
    window.scrollTo(0,wascypos + scramount);
    iscypos = ss.getCurrentYPos();
    isAboveNow = (iscypos < dest);
    if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
      // if we've just scrolled past the destination, or
      // we haven't moved from the last scroll (i.e., we're at the
      // bottom of the page) then scroll exactly to the link
      window.scrollTo(0,dest);
      // cancel the repeating timer
      clearInterval(ss.INTERVAL);
      // and jump to the link directly so the URL's right
      location.hash = anchor;
    }
  },

  getCurrentYPos: function() {
    if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
    if (window.pageYOffset)
      return window.pageYOffset;
    return 0;
  },

  addEvent: function(elm, evType, fn, useCapture) {
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,  NS6 and Mozilla
    // By Scott Andrew
    if (elm.addEventListener){
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent){
      var r = elm.attachEvent("on"+evType, fn);
      return r;
    } else {
      alert("Handler could not be removed");
    }
  } 
}

ss.STEPS = 15;

ss.addEvent(window,"load",ss.fixAllLinks);
