//vars
var scroll_faster_txt;
var back_to_page_txt;
var err_msg;
if(Lang=="DE"){
	scroll_faster_txt = 'Klicken Sie schneller zu blättern';
	back_to_page_txt = 'ZURÜCK ZUR SEITE';
	err_msg = 'Die erforderlichen Informationen unvollständig oder fehlerhaft:';
}else{//is en
	scroll_faster_txt = 'Click to scroll faster';
	back_to_page_txt = 'BACK TO PAGE';
	err_msg = 'The required information is incomplete or contains errors:';
}

// (C) www.dhtmlgoodies.com, October 2005
var expandFirstItemAutomatically = false;	// Expand first menu item automatically ?
var initMenuIdToExpand = pageid;	// Id of menu item that should be initially expanded. the id is defined in the <li> tag.
var expandMenuItemByUrl = false;	// Menu will automatically expand by url - i.e. if the href of the menu item is in the current location, it will expand


var initialMenuItemAlwaysExpanded = false;	// NOT IMPLEMENTED YET

var sh_slmenuObj;
var divToScroll = false;
var ulToScroll = false;	
var divCounter = 1;
var otherDivsToScroll = new Array();
var divToHide = false;
var parentDivToHide = new Array();
var ulToHide = false;
var offsetOpera = 0;
if(navigator.userAgent.indexOf('Opera')>=0)offsetOpera=1;	
var slideMenuHeightOfCurrentBox = 0;
var objectsToExpand = new Array();
var initExpandIndex = 0;
var alwaysExpanedItems = new Array();	
	
function popMenusToShow()
{
	var obj = divToScroll;
	var endArray = new Array();
	while(obj && obj.tagName!='BODY'){
		if(obj.tagName=='DIV' && obj.id.indexOf('slideDiv')>=0){
			var objFound = -1;
			for(var no=0;no<otherDivsToScroll.length;no++){
				if(otherDivsToScroll[no]==obj){
					objFound = no;		
				}					
			}	
			if(objFound>=0){
				otherDivsToScroll.splice(objFound,1);	
			}		
		}	
		obj = obj.parentNode;
	}	
}

function showSubMenu(e,inputObj)
{

	if(this && this.tagName)inputObj = this.parentNode;
	if(inputObj && inputObj.tagName=='LI'){
		divToScroll = inputObj.getElementsByTagName('DIV')[0];
		for(var no=0;no<otherDivsToScroll.length;no++){
			if(otherDivsToScroll[no]==divToScroll)return;
		}			
	}
	hidingInProcess = false;
	if(otherDivsToScroll.length>0){
		if(divToScroll){				
			if(otherDivsToScroll.length>0){
				popMenusToShow();
			}
			if(otherDivsToScroll.length>0){	
				autoHideMenus();
				hidingInProcess = true;
			}
		}	
	}		
	if(divToScroll && !hidingInProcess){
		divToScroll.style.display='';
		otherDivsToScroll.length = 0;
		otherDivToScroll = divToScroll.parentNode;
		otherDivsToScroll.push(divToScroll);	
		while(otherDivToScroll && otherDivToScroll.tagName!='BODY'){
			if(otherDivToScroll.tagName=='DIV' && otherDivToScroll.id.indexOf('slideDiv')>=0){
				otherDivsToScroll.push(otherDivToScroll);
									
			}
			otherDivToScroll = otherDivToScroll.parentNode;
		}			
		ulToScroll = divToScroll.getElementsByTagName('UL')[0];
		if(divToScroll.style.height.replace('px','')/1<=1)scrollDownSub();
	}	
	
	//return false;
}



function autoHideMenus()
{
	if(otherDivsToScroll.length>0){
		divToHide = otherDivsToScroll[otherDivsToScroll.length-1];
		parentDivToHide.length=0;
		var obj = divToHide.parentNode.parentNode.parentNode;
		while(obj && obj.tagName=='DIV'){			
			if(obj.id.indexOf('slideDiv')>=0)parentDivToHide.push(obj);
			obj = obj.parentNode.parentNode.parentNode;
		}
		var tmpHeight = (divToHide.style.height.replace('px','')/1 - slideMenuHeightOfCurrentBox);
		if(tmpHeight<0)tmpHeight=0;
		if(slideMenuHeightOfCurrentBox)divToHide.style.height = tmpHeight  + 'px';
		ulToHide = divToHide.getElementsByTagName('UL')[0];
		slideMenuHeightOfCurrentBox = ulToHide.offsetHeight;
		scrollUpMenu();		
	}else{
		slideMenuHeightOfCurrentBox = 0;
		showSubMenu();			
	}
}


function scrollUpMenu()
{

	var height = divToHide.offsetHeight;
	height-=15;
	if(height<0)height=0;
	divToHide.style.height = height + 'px';

	for(var no=0;no<parentDivToHide.length;no++){	
		parentDivToHide[no].style.height = parentDivToHide[no].getElementsByTagName('UL')[0].offsetHeight + 'px';
	}
	if(height>0){
		setTimeout('scrollUpMenu()',5);
	}else{
		divToHide.style.display='none';
		otherDivsToScroll.length = otherDivsToScroll.length-1;
		autoHideMenus();			
	}
}	

function scrollDownSub()
{
	if(divToScroll){			
		var height = divToScroll.offsetHeight/1;
		var offsetMove =Math.min(15,(ulToScroll.offsetHeight - height));
		height = height +offsetMove ;
		divToScroll.style.height = height + 'px';
		
		for(var no=1;no<otherDivsToScroll.length;no++){
			var tmpHeight = otherDivsToScroll[no].offsetHeight/1 + offsetMove;
			otherDivsToScroll[no].style.height = tmpHeight + 'px';
		}			
		if(height<ulToScroll.offsetHeight)setTimeout('scrollDownSub()',5); else {
			divToScroll = false;
			ulToScroll = false;
			if(objectsToExpand.length>0 && initExpandIndex<(objectsToExpand.length-1)){
				initExpandIndex++;
				
				showSubMenu(false,objectsToExpand[initExpandIndex]);
			}
		}
	}
}
	
function initSubItems(inputObj,currentDepth)
{		
	divCounter++;		
	var div = document.createElement('DIV');	// Creating new div		
	div.style.overflow = 'hidden';	
	div.style.position = 'relative';
	div.style.display='none';
	div.style.height = '1px';
	div.id = 'slideDiv' + divCounter;
	div.className = 'slideMenuDiv' + currentDepth;		
	inputObj.parentNode.appendChild(div);	// Appending DIV as child element of <LI> that is parent of input <UL>		
	div.appendChild(inputObj);	// Appending <UL> to the div
	var menuItem = inputObj.getElementsByTagName('LI')[0];
	while(menuItem){
		if(menuItem.tagName=='LI'){
			var aTag = menuItem.getElementsByTagName('A')[0];
			aTag.className='slMenuItem_depth'+currentDepth;	
			var subUl = menuItem.getElementsByTagName('UL');
			if(subUl.length>0){
				initSubItems(subUl[0],currentDepth+1);					
			}
			aTag.onclick = showSubMenu;				
		}			
		menuItem = menuItem.nextSibling;						
	}		
}

function initSlideDownMenu()
{
	sh_slmenuObj = document.getElementById('sh_slidedown_menu');
	sh_slmenuObj.style.visibility='visible';
	var mainUl = sh_slmenuObj.getElementsByTagName('UL')[0];		
	var mainMenuItem = mainUl.getElementsByTagName('LI')[0];
	mainItemCounter = 1;
	while(mainMenuItem){			
		if(mainMenuItem.tagName=='LI'){
			var aTag = mainMenuItem.getElementsByTagName('A')[0];
			aTag.className='slMenuItem_depth1';	
			var subUl = mainMenuItem.getElementsByTagName('UL');
			if(subUl.length>0){
				mainMenuItem.id = 'mainMenuItem' + mainItemCounter;
				initSubItems(subUl[0],2);
				aTag.onclick = showSubMenu;
				mainItemCounter++;
			}				
		}			
		mainMenuItem = mainMenuItem.nextSibling;	
	}		
	
	if(location.search.indexOf('mainMenuItemToSlide')>=0){
		var items = location.search.split('&');
		for(var no=0;no<items.length;no++){
			if(items[no].indexOf('mainMenuItemToSlide')>=0){
				values = items[no].split('=');
				showSubMenu(false,document.getElementById('mainMenuItem' + values[1]));	
				initMenuIdToExpand = false;				
			}
		}			
	}else if(expandFirstItemAutomatically>0){
		if(document.getElementById('mainMenuItem' + expandFirstItemAutomatically)){
			showSubMenu(false,document.getElementById('mainMenuItem' + expandFirstItemAutomatically));
			initMenuIdToExpand = false;
		}
	}

	if(expandMenuItemByUrl)
	{
		var aTags = sh_slmenuObj.getElementsByTagName('A');
		for(var no=0;no<aTags.length;no++){
			var hrefToCheckOn = aTags[no].href;				
			if(location.href.indexOf(hrefToCheckOn)>=0 && hrefToCheckOn.indexOf('#')<hrefToCheckOn.length-1){
				initMenuIdToExpand = false;
				var obj = aTags[no].parentNode;
				while(obj && obj.id!='sh_slidedown_menu'){
					if(obj.tagName=='LI'){							
						var subUl = obj.getElementsByTagName('UL');
						if(initialMenuItemAlwaysExpanded)alwaysExpanedItems[obj.parentNode] = true;
						if(subUl.length>0){								
							objectsToExpand.unshift(obj);
						}
					}
					obj = obj.parentNode;	
				}
				showSubMenu(false,objectsToExpand[0]);
				break;					
			}			
		}
	}
			
	if(initMenuIdToExpand)
	{
		objectsToExpand = new Array();
		var obj = document.getElementById(initMenuIdToExpand)
		while(obj && obj.id!='sh_slidedown_menu'){
			if(obj.tagName=='LI'){
				var subUl = obj.getElementsByTagName('UL');
				if(initialMenuItemAlwaysExpanded)alwaysExpanedItems[obj.parentNode] = true;
				if(subUl.length>0){						
					objectsToExpand.unshift(obj);
				}
			}
			obj = obj.parentNode;	
		}
		
		showSubMenu(false,objectsToExpand[0]);

	}		
}
	
currentFullImage = 0;// set what the main image in the popup currently is
	
	function showPreview(imageArrayPos){
		
		preciewArrayCount = pageImages.length;
		
		currentFullImage = imageArrayPos;// set what the main image in the popup currently is
		
		document.fullImage.src=pageImages[imageArrayPos];
		
		backHTML = '<a href="#" onClick="SwapImg(\'backImg\'); return false;">'+'<img src="'+pathToImg+'prev_arrow.png" name="imgBack" id="imgBack"> Previous'+'</a>';
		
		closeHTML = '<a href="#" onClick="showPage(); return false;">Close</a>';

		forwardHTML = '<a href="#" onClick="SwapImg(\'forwardImg\'); return false;">'+'Next <img src="'+pathToImg+'next_arrow.png" name="imgForward" id="imgForward">'+'</a>';
		
		if(preciewArrayCount<=1){
			fullHTML = '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="10">&nbsp;</td><td width="180" align="left">&nbsp;</td><td width="500" align="center">'+closeHTML+'</td><td width="180" align="right">&nbsp;</td><td width="10">&nbsp;</td></tr></table>';
		}else{
			fullHTML = '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="10">&nbsp;</td><td width="180" align="left">'+'</td><td width="500" align="center">'+backHTML+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+closeHTML+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+forwardHTML+'</td><td width="180" align="right">'+'</td><td width="10">&nbsp;</td></tr></table>';
		}
		
		document.getElementById('galleryImageNav').innerHTML = fullHTML;
		
		document.getElementById('MainContent').style.left= '-370px';
		document.getElementById('MainImage').style.left= '-2000px';
		countG = 0-(880-240);
		showGallery();
		scroll(0,0);
	}
	function SwapImg(Type){
		
		arrayCount = pageImages.length - 1;
		
		if(Type == 'forwardImg'){
			moveToArrayElement = currentFullImage + 1;
			if(moveToArrayElement>arrayCount){
				moveToArrayElement = 0;
			}
		}else{
			moveToArrayElement = currentFullImage - 1;
			if(moveToArrayElement<0){
				moveToArrayElement = arrayCount;
			}
		}
		currentFullImage = moveToArrayElement;
		document.fullImage.src=pageImages[moveToArrayElement];
		
	}
	
	var countG = 0-(880-240);
	
	function showGallery(){
		
		document.getElementById('ImageGallery').style.left = countG+'px';
		
		width = 240;	
		
		if(countG < (width-60)){
			countG = countG+14;
			setTimeout(showGallery,2);
		}else if(countG < (width-30)){
			countG = countG+6;
			setTimeout(showGallery,2);
		}else if(countG < width){
			countG = countG+2;
			setTimeout(showGallery,2);
		}
		
	}

	function showPage() {
		countG = 0-(880-240);
		document.getElementById('ImageGallery').style.left= '-2000px';
		count2 = 0-mainContentWidth;
		SetImage('load',880);	
	}
	//window.onload = initSlideShow;
// SCROLLING layer script

var timeout;
var delay = 10;

function recScroll(elementId, direction, speed) { 
  clearTimeout(timeout);
  var intElemScrollTop = window.document.getElementById(elementId).scrollTop;
  if (direction == 'down') {
    window.document.getElementById(elementId).scrollTop = intElemScrollTop + speed;
  } else {
    window.document.getElementById(elementId).scrollTop = intElemScrollTop - speed;
  }
  if (intElemScrollTop != window.document.getElementById(elementId).scrollTop ) {
    timeout=setTimeout("recScroll('"+elementId+"', '"+direction+"', "+speed+");",delay);
  } else {
    recScrollLimit(elementId,direction);
  }
}
function recScrollStop() {
  clearTimeout(timeout);
}
function recScrollLimit(elementId, direction) {
  //alert("You can't keep scrolling "+elementId+" "+direction+".");
}

function recScrollBy(elementId, direction, pixels, speed) { 
  clearTimeout(timeout);
  if (pixels > 0) {
    var intElemScrollTop = window.document.getElementById(elementId).scrollTop;
    if (direction == 'down') {
      window.document.getElementById(elementId).scrollTop = intElemScrollTop + speed;
    } else {
      window.document.getElementById(elementId).scrollTop = intElemScrollTop - speed;
    }
    pixels = pixels - speed;
    timeout=setTimeout("recScrollBy('"+elementId+"', '"+direction+"', "+pixels+", "+speed+");",delay);
  }
}

function scrollWheel(event){
  var delta = 0;
  var pixelsPerEvent = 40;
  var elementId = 'MainText';

  /* Delta is a multiple of 120 (except for Mozilla where it is a multiple of 3) */
  /* In Opera and Mozilla the delta is negative compared to IE. */
  if (!event) /* Get the event for IE. */
    event = window.event;
  if (event.wheelDelta) { /* IE/Opera. */
    delta = event.wheelDelta/120;
    if (window.opera)
      delta = -delta;
  } else if (event.detail) { /* Mozilla */
    /* I'm not going to divide by 3 since Mozilla's scrolling is so slow. */
     delta = -event.detail;
  }

  /* Act if delta != 0 */
  if (delta) {
    if (delta < 0) {
      direction = 'down';
      delta = -delta;
    } else {
      direction = 'up';
    }
    pixels = pixelsPerEvent * delta;
    speed = delta * 5;
    //alert("Scrolling "+elementId+" "+direction+" by "+pixels); /* for debugging */
    recScrollBy(elementId,direction,delta,speed);
  }
}

/* Initialization code. */
/* Mozilla browsers use DOMMouseScroll which listens for scrolling _anywhere_ on the window */
if (window.addEventListener)
  window.addEventListener('DOMMouseScroll', scrollWheel, false);
  /* document.getElementById('thumbnails').addEventListener('DOMMouseScroll', scrollWheel, false); */

/* The following will listen for scrolling _anywhere_ in the window */
/* It is therefore preferable to assign this as an event for the area you wish to scroll */
/* e.g. <DIV ID="thumbnails" onmousewheel="wheel()"> */
//window.onmousewheel = document.onmousewheel = scrollWheel;


function insertScroll(){
	document.getElementById('scrollButtons').innerHTML=writeScrollButtons();
	//alert('insert scroll called');
}

function writeScrollButtons(){
	if (parseInt(document.getElementById('MainText').offsetHeight) < parseInt(document.getElementById('MainText').scrollHeight)) {
     	ScrollText = '<div id="scrollHolder">  <a href="#" onmousedown="recScroll(\'MainText\',\'up\',5);" onmouseup="recScroll(\'MainText\',\'up\',1);" onmouseover="recScroll(\'MainText\',\'up\',1);MM_swapImage(\'arrowUp\',\'\',\''+pathToImg+'arrow_up_over.png\',0);" onmouseout="recScrollStop();MM_swapImgRestore();" onclick="return false;"><img src="'+pathToImg+'arrow_up.png" title="'+scroll_faster_txt+'" width="40" height="16" style="padding:5px" id="arrowUp" name="arrowUp"></a><a href="#" onmousedown="recScroll(\'MainText\',\'down\',5);" onmouseup="recScroll(\'MainText\',\'down\',1);" onmouseover="recScroll(\'MainText\',\'down\',1);MM_swapImage(\'arrowDown\',\'\',\''+pathToImg+'arrow_down_over.png\',0);" onmouseout="recScrollStop();MM_swapImgRestore();" onclick="return false;"><img src="'+pathToImg+'arrow_down.png" title="'+scroll_faster_txt+'" width="40" height="16" style="padding:5px" id="arrowDown" name="arrowDown"></a></div>';
	}else{
		ScrollText = '<div id="scrollTextAlt" style="height:30px;"></div>';
	}
	return ScrollText;
}



// SLIDE out the main boxes
function SetClass(Type){
	
	if(Type==1){
		document.getElementById('FullImage').className='FullImageHover';
	}else{
		document.getElementById('FullImage').className='FullImage';
	}

}


var count3;

var runInit3='yes';

function SetImage(Type,imgWidth){

	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	myWidth = window.innerWidth;
   		myHeight = window.innerHeight;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	myWidth = document.documentElement.clientWidth;
    	myHeight = document.documentElement.clientHeight;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    	//IE 4 compatible
    	myWidth = document.body.clientWidth;
    	myHeight = document.body.clientHeight;
  	}

	ImageWidth = myWidth - (240 + mainContentWidth) + 3;
	
	//alert(ImageWidth+' - '+imgWidth);
	
	if(ImageWidth>0){
		//InnerText = '<a href="#" id="FullImage" style="float:right" onClick="showPreview(0); return false;"><img src="'+pathToImg+'view_full_image_'+Lang+'.png"></a>';
		InnerText = '';
		if(imgWidth>=ImageWidth){
			document.getElementById('MainImage').innerHTML = InnerText;
		}
		document.getElementById('MainImage').style.width = ImageWidth+'px'; //set how much available space there is for the img
	}else{
		document.getElementById('MainImage').innerHTML = '';	
	}
	
	DivHeight = (myHeight - 660)/2;
	
	if((myHeight - 660)<0){
		document.getElementById('ContentSpcr').style.height = '0px';
		if(navigator.appName == "Netscape"){
			ImageWidth=ImageWidth-17; // if netscape acount for js not knowing about scroll bars
			document.getElementById('MainImage').style.width = ImageWidth+'px'; //set how much available space there is for the img
		}
	}else{
		document.getElementById('ContentSpcr').style.height = DivHeight+'px';
		setsession('spcrHeight',DivHeight);
	}
	
	
	count3 = 0-ImageWidth;
	
	
	if(ImageWidth>0){
		if(Type=='load'){
	
			document.getElementById('MainMenu').style.left = '0px';	
			init2();
			if(bgImg=='yes'){
				init3();
				//setTimeout(init3,500);
				runInit3='no';
			}
	
		}else if(Type=='Siteload'){
		
			init1();
			init2();
			init3();
			//setTimeout(init3,500);
			runInit3='no';
		
		}else if(Type=='resize'){
			if(runInit3=='yes'){
				if(bgImg=='yes'){
					init3();
					//setTimeout(init3,500);
					runInit3='no';
				}
			}
		}
		checkThis = 240 + mainContentWidth;
		if(ImageWidth>checkThis){
			if(runInit3=='yes'){
				if(bgImg=='yes'){
					init3();
					//setTimeout(init3,500);
					runInit3='no';
				}
			}
		}
		
	}else{
		document.getElementById('MainMenu').style.left = '0px';
		document.getElementById('MainContent').style.left = '240px';
		runInit3='yes';
	}
	document.getElementById('MainTour').style.width=(myWidth-240)+'px';
}

var count1 = -240;
	
function init1() {
	
	document.getElementById('MainMenu').style.left = count1+'px';
	
	width = 0;	
	
	if(count1 < (width-30)){
		count1 = count1+14;
		setTimeout(init1,2);
	}else if(count1 < (width-15)){
		count1 = count1+6;
		setTimeout(init1,2);
	}else if(count1 < width){
		count1 = count1+2;
		setTimeout(init1,2);
	}
}

var count2 = 0-mainContentWidth;
	
function init2() {
	
	if(countG<(1-(880-240))){
	
		document.getElementById('MainContent').style.left = count2+'px';
		
		width = 236;	
		
		if(count2 < (width-60)){
			count2 = count2+14;
			setTimeout(init2,2);
		}else if(count2 < (width-30)){
			count2 = count2+6;
			setTimeout(init2,2);
		}else if(count2 < width){
			count2 = count2+2;
			setTimeout(init2,2);
		}
	
	}
}
	
function init3() {
	
	if(countG<(1-(880-240))){
	
		document.getElementById('MainImage').style.left = count3+'px';
		
		width = 236+mainContentWidth;	
		
		
		if(count3 < (width-60)){
			count3 = count3+14;
			setTimeout(init3,2);
		}else if(count3 < (width-30)){
			count3 = count3+6;
			setTimeout(init3,2);
		}else if(count3 < width){
			count3 = count3+2;
			setTimeout(init3,2);
		}
	}
}
//tour funcs
function tour(tourId){
	
	var flashvars = {};
	var params = {};
	params.loop = "false";
	params.menu = "false";
	params.quality = "best";
	params.scale = "noscale";
	params.salign = "tl";
	params.wmode = "transparent";
	var attributes = {};
	attributes.id = "TourHolder";
	swfobject.embedSWF(pathRoot+"tour/"+pageTours[tourId], "TourHolder", "100%", "100%", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
	
	document.getElementById('MainContent').style.display='none';
	document.getElementById('MainImage').style.display='none';
	document.getElementById('MainTour').style.display='block';
}
function closeTour(){
	TheHtml = '<div id="TourHolder" style="width:100%; height:100%; position:absolute"></div><div style="width:150px; height:50px; position:absolute; right:0; top:10px; text-align:right;"><a href="#" onClick="closeTour(); return false" style="font-weight:bold; color:#FFF; text-decoration:none;">'+back_to_page_txt+'</a>&nbsp;&nbsp;&nbsp;&nbsp;</div>';
	
	document.getElementById('MainTour').innerHTML = TheHtml;
	document.getElementById('MainTour').style.display='none';
	document.getElementById('MainContent').style.display='block';
	document.getElementById('MainImage').style.display='block';
}

// Image rollovers
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)}
  document.MM_returnValue = (s=='');
}