
// vars
var URL = 'http://www.werderpark.de/einkaufen-in-werder-havel/';
var URLCMS = 'http://www.werderpark.de/2728/';

function toggleAMenu()
{
	var nWitdh = document.getElementById('archive_navi').style.width;
	
	if(nWitdh == '10px')
	{
		document.getElementById('archive_naviitems').style.visibility = 'visible';
		document.getElementById('archive_navi').style.width = '130px';
		document.getElementById('archive_content').style.width = '450px';
		document.getElementById('archive_switch').innerHTML = '<a href="javascript:void(0);" onclick="toggleAMenu();">Men&uuml; ausblenden<img src="'+URL+'img/a_sm_right.gif" border="0" title="Men&uuml; ausblenden" align="top" /></a>';
	}
	else
	{
		document.getElementById('archive_naviitems').style.visibility = 'hidden';
		document.getElementById('archive_navi').style.width = '10px';
		document.getElementById('archive_content').style.width = '590px';
		document.getElementById('archive_switch').innerHTML = '<a href="javascript:void(0);" onclick="toggleAMenu();"><img src="'+URL+'img/a_sm_left.gif" border="0" title="Men&uuml; einblenden" align="top" /></a>';
	}
}

function toggleNews(ename,maximum){
	
	for(i=0;i<maximum;i++)
	{
		document.getElementById('newspreview_'+i).style.height = '22px';
	}
	document.getElementById(ename).style.height = 'auto';
}

function textLetterCount(elem,cnt,amountMax){ 
	var amount = document.getElementById(elem).value.length; 
	if (amount > amountMax) { 
		document.getElementById(elem).value = document.getElementById(elem).value.substring(0,amountMax); 
		amount = 0;
	}else{ 
		amount = amountMax - amount; 
	} 
	//document.getElementById(cnt).value = amount;
	document.getElementById(cnt).innerHTML = amount;
}

/* ///////////////////////////////////////////////////////////////////////////////////// */
// mouse position
var mousex
var mousey;

function getXY(e)
{
    if(!e) e = window.event;
	var body = (window.document.compatMode && window.document.compatMode == "CSS1Compat") ? window.document.documentElement : window.document.body || null;
	
	mousey = e.pageY ? e.pageY : e.clientY + body.scrollTop;
	mousex = e.pageX ? e.pageX : e.clientX + body.scrollLeft;
} 

function pMouseOverInit() {
    if (window.event) {
        if (document.captureEvents){
          document.captureEvents(Event.MOUSEMOVE);
        } else {
          window.captureEvents(Event.MOUSEMOVE);
        }
    }
  document.onmousemove = getXY;
}

// shop-info-layer
function pInf(elem,sw,e)
{
	var num = elem.getAttribute('num');
	
	if(sw=='off')
	{
		document.getElementById('item_info_box').innerHTML = '';
		document.getElementById('item_info').style.display = 'none';
	}
	else if(sw=='on')
	{
		$('#item_info_box').load(URL + 'ajax_shopinfo.php?num='+num);
		document.getElementById('item_info').style.display = 'block';
	}
	else
	{
		if (navigator.appVersion.indexOf("Mac")!=-1)
		{
			document.getElementById('item_info').style.left = (mousex-435)+'px';
			document.getElementById('item_info').style.top = (mousey-555)+'px';
		}
		else
		{
			document.getElementById('item_info').style.left = (mousex-835)+'px';
			document.getElementById('item_info').style.top = (mousey-555)+'px';
		}
	}
}

// click on hot-spot
function pGo(elem)
{
	var num = elem.getAttribute('num');
	var uri = URL + 'ekz-werderpark/geschaefte/uebersicht/num/'+num+'/#content';
	location.href = uri;
}

function pPreloadPlans()
{
	var HTML = '';
	
	for(i=0; i<=6; i++) // 0-5, 0 = default, 1-5 = categories, 6 = all
	{
		HTML = HTML + '<img src="' + URLCMS + 'img/admin/centerplan/centerplan_' + i + '.gif" />';
	}
	
	document.getElementById('plan_loader').innerHTML = HTML;
}

function pLoadPlan(id)
{
	//document.getElementById('centerplan').style.backgroundImage = 'url(' + URLCMS + 'img/admin/centerplan/centerplan_' + id + '.gif)';
	document.getElementById('centerplan').src = URLCMS + 'img/admin/centerplan/centerplan_' + id + '.gif';
}

function bLoadBanner(bPt,bPtMax)
{
	// load content
	var id = bAr[bPt];
	
	$('#banner').load(URL + 'ajax_banner.php?id='+id);
	
	// init new
	var bPtNext = (bPt+1 > bPtMax) ? 0 : bPt+1;// loop loading
	
	setTimeout('bLoadBanner('+bPtNext+','+bPtMax+');',15000);
}

function bLoadFirm(bPt,bPtMax)
{
	// load content
	var id = bAr[bPt];
	
	$('#randomfirm').load(URL + 'ajax_randomfirm.php?id='+id);
	
	// init new
	var bPtNext = (bPt+1 > bPtMax) ? 0 : bPt+1;// loop loading
	
	setTimeout('bLoadFirm('+bPtNext+','+bPtMax+');',5000);
}

