// SCRIPT FOR LAYOVERS WITH IMAGES, FORMS AND VIDEOS
var ie=document.all
var ns6=document.getElementById&&!document.all

function ietruebody()
	{
		return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body
	}

// ENLARGE IMAGES, WEBCAMS ETC
function enlarge(which, type, str1, str2, str3)
	{
		if(type=="form")
			{
				var imgwidth=str1;
				var imgheight=str2;
			}
		else if(type=="image")
			{
				var current=str1;
				var imgarray=str2;
				// WHAT IS IN THE ARRAY: village title, img url, width, height, title short, id (only for type==webcam)
				var imgtype=str3;
				// GET THE CONTENT USING THE FUNCTION SLIDESHOW
				var contentarray=slideshow(current,imgarray,imgtype);
				var content=contentarray[0];
				var imgwidth=contentarray[1];
				var imgheight=contentarray[2];
				
			}	
			
		var message_close="Click to close";
		var message_image="Click to close";

		if (ie||ns6)
			{
				crossobj=document.getElementById("showimage");
				
				// CALCULATE POSITION
                // USE GETPAGESIZE FUNCTION (TOTALWIDTH, TOTALHEIGHT, WINDOWWIDTH, WINDOWHEIGHT )
                var arrayPageSize = this.getPageSize();
				horzpos=(arrayPageSize[2]/2)-(imgwidth/2);
                vertpos=100;

				// STRETCH SEMI TRANSPARENT OVERLAY TO FILL THE PAGE				
				document.getElementById("fade").style.display="block";				
				document.getElementById("fade").style.width=arrayPageSize[0] + "px";
				document.getElementById("fade").style.height=arrayPageSize[1] + "px";
				

				crossobj.style.left=horzpos+"px"
				crossobj.style.top=vertpos+"px"
				crossobj.style.height=imgheight+"px";
				crossobj.style.width=imgwidth+"px";
                crossobj.style.padding="0px 20px 60px 20px";
                crossobj.style.border="1px solid #CCCCCC";
				
				if(type=="image")
					{
					
						crossobj.innerHTML='<div id="dragbar" style="width:'+imgwidth+'px;"></div>';
                        crossobj.innerHTML+='<div id="close" onclick="javascript:closepreview()"></div>';
						crossobj.innerHTML+='<div id="screenshot"><a href="javascript:closepreview();" title="'+message_image+'">';
						crossobj.innerHTML+=content;
						crossobj.innerHTML+='</a></div>';
					}
				else if(type=="video")
					{
						crossobj.innerHTML='<div id="dragbar" style="width:'+imgwidth+'px;"></div>';
                        crossobj.innerHTML+='<div id="close" onclick="javascript:closepreview()"></div>';
						crossobj.innerHTML+='<div id="screenshot"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+imgwidth+'" height="'+imgheight+'" id="player_screencast" align="middle"><param name="movie" id="param_file" value="'+which+'.swf?id=1"><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="bgcolor" value="#ffffff"/><param name="autoStart" value="false" /><embed src="'+which+'?id=1" autostart="false" swliveconnect="true" quality="high" scale="noscale" bgcolor="#ffffff" width="'+imgwidth+'" height="'+imgheight+'" name="player_screencast" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/></object></div>';
					}
				else if(type=="form")
					{
						crossobj.innerHTML='<div id="dragbar" style="width:'+imgwidth+'px;"></div>';
                        crossobj.innerHTML+='<div id="close" onclick="javascript:closepreview()"></div>';
						crossobj.innerHTML+='<div id="wrapper_contribute_form">'+which+'</div>';
					}					
			
			// AND DISPLAY
			crossobj.style.display="block";
            document.location = "#top";
			//return false
			}

		//if NOT IE 4+ or NS 6+, simply display image in full browser window
		else 
		return true
	}

		
	function closepreview(e)
		 {
			crossobj.style.display="none";
			document.getElementById("fade").style.display="none";
		 }


	function drag_drop(e)
		{
			 if (ie&&dragapproved)
				{
					 crossobj.style.left=tempx+event.clientX-offsetx+"px"
					 crossobj.style.top=tempy+event.clientY-offsety+"px"
				 }
			 else if (ns6&&dragapproved)
				{
					 crossobj.style.left=tempx+e.clientX-offsetx+"px"
					 crossobj.style.top=tempy+e.clientY-offsety+"px"
				 }
			 return false
		}


	function initializedrag(e)
		{
			 if (ie&&event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar")
				 {
					 offsetx=ie? event.clientX : e.clientX
					 offsety=ie? event.clientY : e.clientY
					 tempx=parseInt(crossobj.style.left)
					 tempy=parseInt(crossobj.style.top)
					 dragapproved=true
					 document.onmousemove=drag_drop
				 }
		}
	
		document.onmousedown=initializedrag
		document.onmouseup=new Function("dragapproved=false")
		document.ondblclick=closepreview;

/*
	function slideshow(current,array_images,imgtype)
		{
			var imgtype=imgtype;
			var previous;
			var next;
			var new_width;
			var new_height;
			var extra_height;
			var new_height_margin;
            var root;
            if(imgtype=="webcam")
				{root="";}
            else
				{root="http://www.myslopes.com/images/";}
			// DEFINE CONTENT, IT GETS THE HTML TO ITS PLACE IN THE DIV "image"
			var content="";;
            var filetype;
            if(imgtype=="webcam")
				{filetype="";}
			else
				{filetype=".jpg";}
			
			// USE GETPAGESIZE FUNCTION TO GET INNERWIDTH
			var arrayPageSize = this.getPageSize();
			frameWidth = arrayPageSize[2];
			frameHeight = arrayPageSize[3];
		
           	// LOOP OVER THE ARRAY WITH IMAGES
			for (i=1;i<array_images.length;i++)
					{ 
						if(i==current)
						{
							// CHECK TO SEE IF THE IMAGE SIZE IS LARGER THAN INNER SCREEN SIZE, IF SO DISPLAY A LINK TO THE FULL IMAGE
							if (frameWidth < array_images[i][2])
								{
									var new_width = frameWidth-100;
									var factor=frameWidth/array_images[i][2];
									var new_height = Math.round(array_images[i][3]*factor);
								}
							else
								{
									new_width = array_images[i][2];
									new_height = array_images[i][3];	
								}
							 
							
							previous=current-1;
							next=current+1;
													
							content+='<div class="slideshow_div_with_background">';
							if(imgtype=="webcam"){content+='<div id="webcam_holder_overlay_'+array_images[i][5]+'" class="webcam_image_holder" style="width:'+array_images[i][2]+'px; height: '+array_images[i][3]+'px;">';}
							content+='<img id="'+imgtype+'_overlay_'+array_images[i][5]+'" src="'+root+array_images[i][1]+filetype+'" width='+new_width+' height='+new_height+' alt="click to close" class="slideshow_image"  onclick="javascript:closepreview()">';
							if(imgtype=="webcam"){content+='</div>';}
							content+='<div class="clearboth"></div>';
							content+='</div>';
							
							// SET PREVIOUS
							if(current>1)
								{
									if(imgtype=="slope")
										{content+='<div class="slideshow_previous" onClick="enlarge(\'slideshow\',\'image\','+previous+',array_slope,\''+imgtype+'\');"></div>';}
									else if(imgtype=="webcam")
										{content+='<div class="slideshow_previous" onClick="enlarge(\'slideshow\',\'image\','+previous+',array_webcam,\''+imgtype+'\');"></div>';}                                    
									else
										{content+='<div class="slideshow_previous" onClick="enlarge(\'slideshow\',\'image\','+previous+',array_image,\''+imgtype+'\');"></div>';}
								}
								
                                
                             // DISPLAY IMAGE TITLE AND ENLARGE LINK
                             content+='<div class="slideshow_title" style="width:'+new_width+';">'+array_images[i][0];
							if (frameWidth < array_images[i][2])
								{
									content+=' <a href="'+root+array_images[i][1]+'.jpg" target="_blank">Larger version</a>';
								}   
                            content+='</div>';    
                            
							//  REFRESH BUTTON
							if(imgtype=="webcam"){content+='<div class="webcam_option"><img class="webcam_option_icon" onclick="change(\'refresh_webcam\',\''+array_images[i][5]+'\',\'overlay\')" alt="refresh webcam " src="http://www.mijnsneeuw.nl/pix/icon_refresh.gif"/></div>';}
                                
                            // DISPLAY NEXT    
							if(i<array_images.length-1)	
								{ 
									if(imgtype=="slope")
										{content+='<div class="slideshow_next" onClick="enlarge(\'slideshow\',\'image\','+next+',array_slope,\''+imgtype+'\');"></div>';}
									else if(imgtype=="webcam")
										{content+='<div class="slideshow_next" onClick="enlarge(\'slideshow\',\'image\','+next+',array_webcam,\''+imgtype+'\');"></div>';}                                    
									else
                                    	{content+='<div class="slideshow_next" onClick="enlarge(\'slideshow\',\'image\','+next+',array_image,\''+imgtype+'\');"></a></div>';}
								}
							
							
							//return content;
						 	return [content,new_width,new_height];
						}
		
				}
	}
*/

function slideshow_thumbs(current,array_images,type)
	{
		var previous=current-1;
		var next=current+1;
		var total=array_images.length-1;
		
		var image_thumb=document.getElementById('slideshow_thumb_'+type+'_placeholder');
		var image_thumb_link=document.getElementById('thumb_link_'+type+'');
		var image_thumb_link_previous=document.getElementById('thumb_link_'+type+'_previous');
        var image_thumb_button_previous=document.getElementById('slideshow_controls_'+type+'_left');
		var image_thumb_link_next=document.getElementById('thumb_link_'+type+'_next');
        var image_thumb_button_next=document.getElementById('slideshow_controls_'+type+'_right');
		var image_thumb_title=document.getElementById('slideshow_thumb_'+type+'_title');
		
		var root="http://www.mijnsneeuw.nl/images/";


					// display current
					// Effect.Fade('image_thumb', { duration: 3.0 });
                    image_thumb.setAttribute("src",""+root+array_images[current][1]+"t.jpg"); 
					image_thumb.setAttribute("alt",array_images[current][2]);
					//Effect.Appear('image_thumb', { duration: 3.0 });
                    
					image_thumb_link.setAttribute("href","javascript:enlarge('slideshow','image',"+current+",array_"+type+",'"+type+"');");
					image_thumb_title.innerHTML=array_images[current][4]+" ("+current+"/"+total+")";
					
					
					if(current>1)
						{
                        	image_thumb_button_previous.style.display='block';
							image_thumb_link_previous.style.display='block';
							image_thumb_link_previous.setAttribute("href","javascript:slideshow_thumbs("+previous+",array_"+type+",'"+type+"');");
						}
					else 
						{
							image_thumb_button_previous.style.display='none';
						}
					
					if(next!=array_images.length)
						{			
                        	image_thumb_button_next.style.display='block';		
							image_thumb_link_next.style.display='';
							image_thumb_link_next.setAttribute("href","javascript:slideshow_thumbs("+next+",array_"+type+",'"+type+"');");
							image_thumb_link_previous.setAttribute("href","javascript:slideshow_thumbs("+previous+",array_"+type+",'"+type+"');");
						}
					else
						{
							image_thumb_button_next.style.display='none';
						}
	}



// SUBMIT A FORM
 function form_submit(form_name) 
 	{
		document.getElementById('searchform').submit(); 
	}
//END SUBMIT


//HIDE ELEMENT, USED AFTER SENDING TESTIMONIAL
	function hide(id,timeout)
		{
        	if(timeout)
            	{
					setTimeout("document.getElementById(id).style.display='none'", timeout);	
                }
              else
              	{
                 	document.getElementById(id).style.display='none';
                 }  
		}
//END HIDE ELEMENT

function slideshow_highlight(direction,slide)
	{
			var thumb_layover=document.getElementById(slide);
			if(direction=="in")
				{
					if (!isIE)
						{
							//thumb_layover.setAttribute("class", "slideshow_thumb_over");
						}
					else
						{
							//thumb_layover.setAttribute("className", "slideshow_thumb_over");
						}
				}
			if(direction=="out")
				{
					if (!isIE)
						{
							//thumb_layover.setAttribute("class", "slideshow_thumb");
						}
					else
						{
							//thumb_layover.setAttribute("className", "slideshow_thumb");
						}
				}				
	}



// COPIED FROM LIGHTBOX
function getPageSize() 
 	{

	 	var xScroll, yScroll;

		 if (window.innerHeight && window.scrollMaxY) 
			{
				 xScroll = window.innerWidth + window.scrollMaxX;
				 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
				if(document.documentElement.clientWidth)
					{
						 windowWidth = document.documentElement.clientWidth;
					 } 
				else 
					{
						 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 = xScroll;
			} 
		else 
			{
				pageWidth = windowWidth;
			}

 	return [pageWidth,pageHeight,windowWidth,windowHeight];
 }
//SCRIPT FOR LAYOVERS WITH IMAGES AND VIDEOS,


//LIVESEARCH... INITIATED ONLOAD

var liveSearchReq = false; 
var t = null; 
var liveSearchLast = ""; 
var isIE = false; 

	
function liveSearchStart() 
	{ if (navigator.userAgent.indexOf("Safari") > 0) 
		{ 
		document.getElementById('livesearch').addEventListener("keydown",liveSearchKeyPress,false); 
		document.getElementById('livesearch').setAttribute("autocomplete","off"); 
		} 
	else if (navigator.product == "Gecko") 
		{ 
		document.getElementById('livesearch').addEventListener("keypress",liveSearchKeyPress,false); 
		document.getElementById('livesearch').setAttribute("autocomplete","off"); 
		} 
	else 
		{ 
		document.getElementById('livesearch').attachEvent('onkeydown',liveSearchKeyPress); 
		isIE = true; 
		document.getElementById('livesearch').setAttribute("autocomplete","off"); 
		} 
	} 
	
function liveSearchKeyPress(event) 
	{ 
		if (event.keyCode == 40) 
		//KEY DOWN 
			{ 
				highlight = document.getElementById("livesearch_highlight"); 
			
				if (!highlight) 
					{ 
						highlight = document.getElementById("livesearch_result").firstChild.firstChild; 
					} 
				else 
					{ 
						highlight.removeAttribute("id"); 
						highlight = highlight.nextSibling; 
					} 
				
				if (highlight) 
					{ 
						//alert('set');
						//highlight.removeAttribute("id");
						highlight.setAttribute("id","livesearch_highlight"); 
					} 
				
				if (!isIE) 
					{ 
						event.preventDefault(); 
					} 
			} 
		
		//KEY UP 
		else if (event.keyCode == 38 ) 
		{ 
			highlight = document.getElementById("livesearch_highlight"); 
			if (!highlight) 
				{ 
					highlight = document.getElementById("livesearch_result").firstChild.firstChild; 
				} 
			else 
				{ 
					highlight.removeAttribute("id"); 
					highlight = highlight.previousSibling; 
				}

		 	if (highlight) 
				{ 
					highlight.setAttribute("id","livesearch_highlight"); 
				} 
			
			if (!isIE) { 
				event.preventDefault(); 
				} 
			
		} 
		
		
		// ESC 
		else if (event.keyCode == 27) 
			{ 
				highlight = document.getElementById("livesearch_highlight"); 
				if (highlight) 
					{ 
						highlight.removeAttribute("id"); 
					} 
				document.getElementById("livesearch_result").style.display = "none"; 
				document.forms.searchform.livesearch.value = ''; 
			} 
	} 


		function liveSearchSubmit() 
			{ 
				var highlight = document.getElementById("livesearch_highlight");  
				if (highlight) 
					{ 

						// GET THE URL FROM THE CHILD ELEMENT
						// USE GET FIRSTCHILD FUNCTIE TO CHECK THE TYPE OF THE NODE
						url_div=get_firstchild(get_firstchild(highlight));
						url_redirect=url_div.getAttribute("href");	
						window.location = url_redirect; return false; 
					} 
				else 
					{ 
						//alert ('no highlight');
						return true; 
					} 
			}
		
	//check if the first node is an element node
	function get_firstchild(n)
		{
			x=n.firstChild;
			while (x.nodeType!=1)
				{
			  	x=x.nextSibling;
			  	}
			return x;
		}		
			
		
		function closeResults() 
			{ 
				document.getElementById("livesearch_result").style.display = "none";
		 	}
//END LIVESEARCH INITIATED ONLOAD


//TESTIMONIAL ADD
	function testimonial_add(direction)
		{
			//the form... 
			var testimonial_add = document.getElementById("testimonial_add"); 
			var testimonial_link = document.getElementById("testimonial_link"); 
			var testimonial_image = document.getElementById("testimonial_image"); 
			var testimonial_wrapper = document.getElementById("testimonial_wrapper"); 
			var testimonial_ad = document.getElementById("testimonial_ad"); 
				
			if(direction=="show")
				{
					//make visible
					if (!isIE)
						{
							testimonial_add.style.display="block";
							testimonial_wrapper.style.display="none";
							testimonial_ad.style.display="none"; 
						}
					else
						{
							testimonial_add.style.display="block";
							testimonial_wrapper.style.display="none";
							testimonial_ad.style.display="none"; 
						}					
					
					testimonial_link.setAttribute("href", "javascript:testimonial_add('hide')");
					testimonial_link.innerHTML="<img src=\"http://www.myslopes.com/pix/icon_close.png\" alt=\"Sluit formulier\" border=0> sluit formulier";
			
				}	
			else if(direction=="hide")
				{
					//make visible
					
					if (!isIE)
						{
							testimonial_add.style.display = "none";
							testimonial_wrapper.style.display="block";
							testimonial_ad.style.display="block"; 
						}
					else
						{
							testimonial_add.style.display = "none";
							testimonial_wrapper.style.display="block";
							testimonial_ad.style.display="block";
						}						
		
					//change the testimonial link and the image
					testimonial_link.setAttribute("href", "javascript:testimonial_add('show')");
					testimonial_link.innerHTML="<img src=\"http://www.myslopes.com/pix/icon_add.png\" alt=\"Voeg ervaring toe\" border=0> Voeg ervaring toe";
				}
		}
	//END TESTIMONIAL ADD	
	
	
	// CHECK IF VARIABLE EXISTS
	function isSet(variable)
		{
			return( typeof( variable ) != 'undefined' );
		}	
	// END CHECK IF VAR EXISTS
		
	// TOGGLE COMMENT
	function toggle(name,id)
		{
			var div=document.getElementById(name+"_"+id); 
			var img=document.getElementById(name+"_icon_"+id); 
			
			// SHOW IF HIDDEN
			if(div.style.display=="hidden" || div.style.display=="none" || div.style.display=="")
				{				
					div.style.display = "block";
					img.setAttribute("src", "http://www.myslopes.com/pix/icon_collaps_off.gif");			
				}	
			// HIDE IF SHOWN
			else
				{
					div.style.display = "none";
					img.setAttribute("src", "http://www.myslopes.com/pix/icon_expand_off.gif");					
						
				}
		}
	// END TOGGLE COMMENT

	//TOGGLE WEATHER OR AVALANCHE OR ANYTHING ELSE
	function toggle_weather(direction,id,type)
		{
			if(isSet(type))
				{
					var type=type;
				}
			else 
				{
					var type="weather";
				}
			
			var row = document.getElementById(type+"_text_"+id); 
			var img = document.getElementById(type+"_img_"+id); 
			var link_toggle = document.getElementById(type+"_toggle_link_"+id);
			var link_text_toggle = document.getElementById(type+"_toggle_link_text_"+id);
			
			if(direction=="out")
				{
					if (!isIE)
						{							
						row.style.display = "table-row";
						}
					else
						{
						row.style.display = "block";
						}
					//point the arrow down		
					img.setAttribute("src", "http://www.myslopes.com/pix/icon_collaps_off.gif");	
					//reset the link
					link_toggle.setAttribute("href", "javascript:toggle_weather('in',"+id+",'"+type+"');");
					link_text_toggle.setAttribute("href", "javascript:toggle_weather('in',"+id+",'"+type+"');");
				}	
			else if(direction=="in")
				{
					row.style.display = "none";
					//point the arrow back right 
					img.setAttribute("src", "http://www.myslopes.com/pix/icon_expand_off.gif");	
					//reset the link
					link_toggle.setAttribute("href", "javascript:toggle_weather('out',"+id+",'"+type+"');");
					link_text_toggle.setAttribute("href", "javascript:toggle_weather('out',"+id+",'"+type+"');");
				}					
		}
//END TOGGLE WEATHER	

//TOGGLE GENERIC
	function toggle_div(type,direction,id,str1,str2)
		{
			
			if(type=="accooffer")
				{
					var acco_id=id;
					var provider_id=str1;
					var number_of_offers=str2;
					var link_id=document.getElementById("acco_offer_link_"+acco_id+"_"+provider_id+"");
					var img_id=document.getElementById("acco_offer_image_"+acco_id+"_"+provider_id+"");
					
					
					for(z=1;z<number_of_offers;z++)
						{
							var div_id=document.getElementById("acco_offer_"+acco_id+"_"+provider_id+"_"+z);
							//alert("acco_offer_"+acco_id+"_"+provider_id+"_"+z);
							if(direction=="out")
								{
									link_id.setAttribute("href", "javascript:toggle_div('"+type+"','in',"+id+","+str1+","+str2+");");
									img_id.setAttribute("src", "http://www.myslopes.com/pix/icon_collaps_off.gif");
									div_id.className="acco_offer";					
								}	
							else if(direction=="in")
								{
									link_id.setAttribute("href", "javascript:toggle_div('"+type+"','out',"+id+","+str1+","+str2+");");
									img_id.setAttribute("src", "http://www.myslopes.com/pix/icon_expand_off.gif");
									div_id.className="acco_offer_hidden";		
								}	
						}
				}				
		}
//END TOGGLE GENERIC


//TOGGLE AREAS
	function toggle_area(direction,id,children)
		{
 
			var img = document.getElementById("img_"+id); 
			var link_toggle = document.getElementById("toggle_link_"+id); 
			var link_title_toggle = document.getElementById("toggle_link_title_"+id);
            var dots = document.getElementById("dots"+id); 			
			
			if(direction=="out")
				{
			 		for(z=1;z<=children;z++)
	 					{
							var row = document.getElementById("text_"+id+"_"+z);								
						
                            if (!isIE)
								{
									row.setAttribute("class", "expand_table_tr_active");
								}
							else
								{	
									row.style.display = "block";
								}	
                             
                            //last row    							
                            if(z==children)
                            	{
                                	var last_td=row.childNodes[0];
 		                            last_td.setAttribute("style", "border-bottom:1px solid #dddddd");
                                }
                         }

					//point the arrow down		
					img.setAttribute("src", "http://www.myslopes.com/pix/icon_collaps_off.gif");	
                    dots.setAttribute("style", "background: transparent url('http://www.mijnsneeuw.nl/pix/icon_collaps_dots.gif') repeat-y");
					//reset the link
					link_toggle.setAttribute("href", "javascript:toggle_area('in',"+id+","+children+");");
					if(link_title_toggle!=undefined)
						{
							link_title_toggle.setAttribute("href", "javascript:toggle_area('in',"+id+","+children+");");
						}
				}	
			else if(direction=="in")
				{
								 		for(z=1;z<=children;z++)
	 					{
							var row = document.getElementById("text_"+id+"_"+z);								
							if (!isIE)
								{
                            		row.setAttribute("class", "expand_table_tr");
                                 }
                             else { row.style.display = "none"; }
						}
					//point the arrow back right 
					img.setAttribute("src", "http://www.mijnsneeuw.nl/pix/icon_expand_on.gif");	
					//reset the link
					link_toggle.setAttribute("href", "javascript:toggle_area('out',"+id+","+children+");");
					if(link_title_toggle!=undefined)
						{
							link_title_toggle.setAttribute("href", "javascript:toggle_area('out',"+id+","+children+");");
						}
				}					
		}
//END TOGGLE AREAS	



//START CHANGE SCRIPT
var xmlHttp
var action
var cat_number

function change(to_do,str,str1,str2,str3,str4,str5,str6,str7,str8,str9,str10)
	{ 
		xmlHttp=GetXmlHttpObject()
		action=to_do
		cat_number=str
		url_number=str
		image=str1
		//for testimonial
		type=str1
		field=str2
		value=str3

		current=str3	
	
	        
		//if browser does support http request...		
		if (xmlHttp==null)
			 {
				 alert ("Browser does not support HTTP Request")
				 return
			 }
		
		if (action=='live_search')
			{
				//only start search if string lenght > 2
				if (str.length>2)
					{
						//check to see if the query string has changed, if not... then abort the request..
						if (liveSearchLast != str) 
							{
							
								if ( str == "") 
									{ 
										document.getElementById("livesearch_result").style.display = "none"; 
										highlight = document.getElementById("livesearch_highlight"); 
										if (highlight) 
											{ 
												highlight.removeAttribute("id"); 
											} 
										return false; 
									} 				
								
								else 
									{
										var url="act_live_search.php"
										//str is the id of the CMR
										url=url+"?q="+str
										url=url+"&sid="+Math.random()	
										liveSearchLast=str							
									}
							}
						else
							{
								//search string is the same as the last search string.. so exit from requesting new data
								return;
								return;
							}
					}
				//check for string length, if too short return false
				else
					{
						return false;	
					}
			}				
			
	
		else if (action=='testimonial')
			{
            	direction=str2
                
				var url="act_rating_item.php"
				url=url+"?id="+str
				url=url+"&type="+type
				url=url+"&field="+field
				url=url+"&value="+value
				url=url+"&sid="+Math.random()
			}						
		
		else if (action=='top10')
			{
                type1=str2
                top10=str1
                id=str
                amount=str3            
            
				var url="act_top10.php"
				url=url+"?top10="+top10
				url=url+"&type="+type1
				url=url+"&id="+id
				url=url+"&sid="+Math.random()
			}			

		else if (action=='language')
			{
            	language_to=str	
                
				var url="act_language_switch.php"
				url=url+"?language_to="+language_to
				url=url+"&sid="+Math.random()
			}				
			
		else if (action=='contribute')
			{
            	type1=str
				id=str1	
                
				var url="dsp_contribution_form.php"
				url=url+"?type1="+type1
				url=url+"&id="+id
				url=url+"&sid="+Math.random()
			}			
			
		else if (action=='breadcrum_fold')
			{
            	direction=str1
                type=str
                id=str2
                
				var url="act_breadcrum_fold.php"
				url=url+"?type="+str
				url=url+"&direction="+str1  
                url=url+"&where_id="+str2  
				url=url+"&current="+str3              
				url=url+"&sid="+Math.random()
			}	            
 
		else if (action=='selection_query')
			{
                key=str;
				direction=str1;
                value=str2;
                current_selection=str3;
				type=str4;
				id=str5;
				selection_options=str6;
				all_options=str7;
				selection=str8;
				if(isSet(str9)){start_at=str9;} else{start_at=acco_pages;}
				if(isSet(str10)){acco_limit=str10;} else{acco_limit=10;}
				
				// CHECK IF SELECTION TYPE IS SET (ACCO OR WEBCAM)... DEFAULT TO ACCO
				if(selection==""){selection="acco";}

				// CONVERT ALL OPTIONS ARRAY TO STRING
				var all_string="";
				for (i=0;i<all_options.length;i++)
					{				
						all_string+=all_options[i].toString();
						if(i!=all_options.length-1){all_string+="|";}
					}

				// CONVERT CURRENT MD ARRAY TO STRING
				var current_string="";
				for (i=0;i<current_selection.length;i++)
					{				
						current_string+=current_selection[i].toString();
						if(i!=current_selection.length-1){current_string+="|";}
					}				
				
				// CONVERT SELECTION OPTIONS TO STRING
				var options_string="";
				for (i=0;i<selection_options.length;i++)
					{				
						options_string+=selection_options[i].toString();
						if(i!=selection_options.length-1){options_string+="|";}
					}	
			
				var url="act_"+selection+"_query.php"
				url=url+"?key="+key
				url=url+"&direction="+direction
                url=url+"&value="+value  
				url=url+"&current_selection="+current_string
				url=url+"&all_options="+all_string
				url=url+"&type="+type 
				url=url+"&id="+id
				url=url+"&selection_options="+options_string
				url=url+"&start_at="+start_at
				url=url+"&acco_limit="+acco_limit
				url=url+"&sid="+Math.random()
				
				// DISPLAY PROCESSING ICON
				var wrapper=document.getElementById("wrapper_"+selection);
				wrapper.innerHTML = '<div id="processing">Processing request</div>';					
			}				
			
		else if (action=='snow_query')
			{
                //key=str
                order_by=str1
                order_direction=str2
				type=str3
				id=str4
                
				var url="act_snow_query.php"
				url=url+"?order_by="+order_by
                url=url+"&order_direction="+order_direction  
				url=url+"&type="+type 
				url=url+"&id="+id
				url=url+"&sid="+Math.random()
			}				


		else if (action=='refresh_webcam')
			{
                webcam_id=str;
				position=str1;
				
				var url="act_webcam_refresh.php"
				url=url+"?webcam_id="+webcam_id
				url=url+"&position="+position
				url=url+"&sid="+Math.random()
				
				// REMOVE IMAGE OF WEBCAM, THAT SHOWS THE BACKGROUND IMAGE
				var webcam_div=document.getElementById('webcam_holder_'+position+'_'+webcam_id);
				webcam_div.innerHTML="";
				
			}	


xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}



function stateChanged() 
	{ 
		
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

			if (action=='live_search')
					{	
						var resultdiv = document.getElementById("livesearch_result"); 
						resultdiv.style.display = "block"; 
						resultdiv.innerHTML = xmlHttp.responseText;
					}	
			

			else if (action=='testimonial')
					{

						for(z=1;z<=10;z++)
			 				{
			 					i = document.getElementById(field + "_" + z);
							
					 	if(z<=value)
				
				 					//check to see if it is an even or odd number..
									if (z%2 == 0)
										{
											image = "http://www.myslopes.com/pix/icon_testimonial_right_blue.gif";
										}
									else
										{
											image = "http://www.myslopes.com/pix/icon_testimonial_left_blue.gif";
										}	
 								else
 									//check to see if it is an even or odd number..
									if (z%2 == 0)
										{
											image = "http://www.myslopes.com/pix/icon_testimonial_right_grey.gif";
										}
									else
										{
											image = "http://www.myslopes.com/pix/icon_testimonial_left_grey.gif";
										}	 
 
 						i.setAttribute("src", image);
						i.setAttribute("onmouseover", null);
						i.setAttribute("onmouseout", null);
						i.setAttribute("onClick", null);
						 }
					}	
				
					
			else if (action=='top10')
					{
					var topten_ID=document.getElementById("topten");
					topten_ID.innerHTML = xmlHttp.responseText;
					}		
                    
			else if (action=='language')
					{
						//refresh page
						location.reload(true);
                   	}	

			else if (action=='breadcrum_fold')
					{
                    var breadcrum_parent=document.getElementById("breadcrum_"+type);
					var breadcrum_foldout=document.getElementById("breadcrum_foldout");
                    var breadcrum_link=document.getElementById("breadcrum_link_"+type);
					var breadcrum_icon=document.getElementById("breadcrum_icon_"+type);
                                        
                    	if(direction=='out')
                        	{
                            	breadcrum_foldout.style.display = "block";
                           		breadcrum_foldout.innerHTML = xmlHttp.responseText;
                                breadcrum_link.setAttribute("href","javascript:change('breadcrum_fold','"+type+"','in',"+id+",'"+current+"')");
                                breadcrum_icon.setAttribute("src","http://www.mijnsneeuw.nl/pix/icon_collaps_off.gif");

                               	/* RESET THE IMAGES ABOVE THE OTHER TYPES*/
                                   if(type!="country")
                                   	{
                                       	document.getElementById("breadcrum_icon_country").setAttribute("src","http://www.mijnsneeuw.nl/pix/icon_expand_off.gif");
									}
                                   if(type!="area" && document.getElementById("breadcrum_icon_area")!=undefined)
                                   	{
                                       	document.getElementById("breadcrum_icon_area").setAttribute("src","http://www.mijnsneeuw.nl/pix/icon_expand_off.gif");
									}  
                                   if(type!="village" && document.getElementById("breadcrum_icon_village")!=undefined)
                                   	{
                                       	document.getElementById("breadcrum_icon_village").setAttribute("src","http://www.mijnsneeuw.nl/pix/icon_expand_off.gif");
									}   
                                  /* MOVE THE FOLDOUT TO THE NEW PARENT DIV */
                                  breadcrum_parent.appendChild(breadcrum_foldout);                                     
                            }
                         else
                         	{
                            	breadcrum_foldout.innerHTML ="";
                                breadcrum_foldout.style.display="none";
                                breadcrum_link.setAttribute("href","javascript:change('breadcrum_fold','"+type+"','out',"+id+",'"+current+"');");
                                breadcrum_icon.setAttribute("src","http://www.mijnsneeuw.nl/pix/icon_expand_off.gif");
                            }   
					
					}
					
				else if (action=='contribute')
					{
						// OPEN LAYER
                       return enlarge(xmlHttp.responseText, 'form', 650, 550);
					}
					
					
					
					
				else if (action=='selection_query')
					{
						
						// NOW RESET THE LINKS IN ACTION AND IN LAYOUT
						// i DEFINES WHERE TO START IN THE LOOP TO CHANGE THE LINKS
						// 0 accotype
						// 1 accoprice
						// 2 accovillage
						// 3 accosnow
						// 4 accoslopelength	
						
						// remove this script, loop over selection_options and try to match, use the place of the match
						/*
						if(key=="accoprice" && !isIE)
							{
								start=1;
								key_id=selection_options.indexOf(key);
							}
						else if(!isIE)
							{
								start=0;
								key_id=selection_options.indexOf(key);
							}	
						else if(key=="accoprice" && isIE)
							{
								start=1;
								key_id=1;
							}
						else if(isIE)
							{
								start=0;
								key_id=0;
							}
						*/
						// INDEX_OF NOT SUPPORTED BY MOST IEs THEREFORE HARDCODE THE PLACE OF THE CURRENT SELECTOR
						// IN THE ARRAY OF SELECTION OPTIONS... BAH
						if(key=="accotype"){start=0; key_id=0;}
						else if(key=="accoprice"){start=1; key_id=1;}
						else if(key=="accovillage"){start=0; key_id=2;}
						else if(key=="accoslopelength"){start=1; key_id=3;}
						
						
						// SET CLASS OF LINKS OF CURRENT KEY (IE ALL LINKS ABOUT ACCOTYPE)
						if(key!='')
							{
								for (i=start;i<all_options[key_id].length;i++)
									{
										var img_checkbox=document.getElementById("checkbox_"+key+"_"+i);
										var div_link=document.getElementById(key+"_"+i);
			
										if(direction=="only")
											{
												if(value!=all_options[key_id][i])
													{
														div_link.setAttribute("href","javascript:change('selection_query','"+key+"','add','"+all_options[key_id][i]+"',current,'"+type+"',"+id+",selection_options,all_options,'"+selection+"');");
														div_link.className="acco_option_inactive";
		
													}
												// SET A DIFFERENT LINK FOR THE ITEM THAT WAS JUST CLICKED
												else
													{
														div_link.setAttribute("href","javascript:change('selection_query','"+key+"','remove','"+all_options[key_id][i]+"',current,'"+type+"',"+id+",selection_options,all_options,'"+selection+"');");
														img_checkbox.setAttribute("src","http://www.myslopes.com/pix/icon_checked.gif");
													}
											}
										else if(direction=="add")
											{
												if(value==all_options[key_id][i])
													{
														div_link.setAttribute("href","javascript:change('selection_query','"+key+"','remove','"+value+"',current,'"+type+"',"+id+",selection_options,all_options,'"+selection+"');");
														img_checkbox.setAttribute("src","http://www.myslopes.com/pix/icon_checked.gif");	
													}
											}
											
										else if(direction=="remove")
											{
												// CHECK TO SEE IF THIS IS NOT THE LAST VALUE IN THE CURRENT 
												// ARRAY, IF SO SET THE DIRECTION OF ALL LINKS IN THE CAT TO 'ONLY' 
												// AND NOT JUST THE CURRENT ONE TO 'ADD'										
												if(value==all_options[key_id][i] && current[key_id].length>1)
													{
														img_checkbox.setAttribute("src","http://www.myslopes.com/pix/icon_check.gif");
														div_link.setAttribute("href","javascript:change('selection_query','"+key+"','add','"+value+"',current,'"+type+"',"+id+",selection_options,all_options,'"+selection+"');");
													}
												else
													{
														if(value==all_options[key_id][i] && current[key_id].length==1)
															{
																img_checkbox.setAttribute("src","http://www.myslopes.com/pix/icon_check.gif");
																//SET DIRECTION TO ONLY INSTEAD OF ADD
																div_link.setAttribute("href","javascript:change('selection_query','"+key+"','only','"+value+"',current,'"+type+"',"+id+",selection_options,all_options,'"+selection+"');");
															}
														else if(value!=all_options[key_id][i] && current[key_id].length==1)
															{
																img_checkbox.setAttribute("src","http://www.myslopes.com/pix/icon_check.gif");
																//SET DIRECTION TO ONLY INSTEAD OF ADD
																div_link.setAttribute("href","javascript:change('selection_query','"+key+"','only','"+all_options[key_id][i]+"',current,'"+type+"',"+id+",selection_options,all_options,'"+selection+"');");
															}
													}
											}									
									}
							} // END IF KEY EMPTY


						// DEFINE NEW ARRAY - NEEDED IN THE ADJUSTED LINKS 
						if(direction=="only")
							{
								//DELETE ALL FROM THIS KEY EXCEPT FOR THE SELECTED ONE
								current[key_id].splice(0,current[key_id].length,value);
							}
						else if(direction=="add")
							{
								// add the selected value to the query	
								current[key_id].splice(0,0,value);
							}
						
						else if(direction=="remove")
							{
								// remove is used for currently made selections
								// get the indexOf (position in the array and the use splice)
								// var remove_id=current[key_id].indexOf(value);
								for (z=0;z<current[key_id].length;z++)
									{	
											if(current[key_id][z]==value){remove_id=z;}
									}								
								
								current[key_id].splice(remove_id,1);
								// reset to the full array if all values are removed
								if(current[key_id].length==0)
									{
										for (i=start;i<all_options[key_id].length;i++)
											{	
												current[key_id][i]=all_options[key_id][i];
											}
									}
							}
						
						// SORT ALL EXCEPT FOR VILLAGES
						if(key!='')
							{
								if(selection_options[key_id]!="accovillage")
									{
										current[key_id].sort(sortNumber);	
									}
							}
	
						
						// AND DISPLAY THE NEW CONTENT
						var wrapper=document.getElementById("wrapper_"+selection);
						wrapper.innerHTML = xmlHttp.responseText;	
						
					}					
					
					
				else if (action=='snow_query')
					{
						var wrapper_top100=document.getElementById("wrapper_top100");
						wrapper_top100.innerHTML = xmlHttp.responseText;						
					}	
					
				else if (action=='refresh_webcam')
					{
						// SHOW THE IMAGE
						var webcam_div=document.getElementById('webcam_holder_'+position+'_'+webcam_id);
						webcam_div.innerHTML=xmlHttp.responseText;
					}
				/*	
				else if (action=='acco_count')
					{
						// DO NOTHING :)
						
					}	*/

	}
//END MULTIPURPOSE CHANGE SCRIPT

// FUNCTION TO SORT BY NUMBER USING SORT
function sortNumber(a,b)
{
return a - b;
}
//	END FUNCTION TO SORT BY NUMBER USING SORT

//AJAX XMLHTTP request.. needed for change script above...
function GetXmlHttpObject()
	{
		var xmlHttp=null;
		try
	 		{
				// Firefox, Opera 8.0+, Safari
				xmlHttp=new XMLHttpRequest();
			 }
		catch (e)
 			{
				//Internet Explorer
				 try
					  {
					  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					  }
						 catch (e)
						  {
						  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
						  }
			 }
	return xmlHttp;
	}
// END AJAX XMLHTTP request


// FOR COPYING WITHOUT REFERENCE OF MULTI-DIMENSIONAL ARRAYS 
// SEE http://my.opera.com/GreyWyvern/blog/show.dml/1725165
/*
Object.prototype.clone = function() {
  var newObj = (this instanceof Array) ? [] : {};
  for (i in this) {
    if (i == 'clone') continue;
    if (this[i] && typeof this[i] == "object") {
      newObj[i] = this[i].clone();
    } else newObj[i] = this[i]
  } return newObj;
};
*/

function acco_select(key,direction,value,current_selection,type,id,selection_options,all_options)
	{
		// convert current md array to string
		var current_string="";
		for (i=0;i<current_selection.length;i++)
			{				
				current_string+=current_selection[i].toString();
				if(i!=current_selection.length-1){current_string+="|";}
			}
		
				
		// convert selection options array to string
		var options_string="";
		for (i=0;i<selection_options.length;i++)
			{				
				options_string+=selection_options[i].toString();
				if(i!=selection_options.length-1){options_string+="|";}
			}
	}

function display_accos(object)
	{
		var accoss="accos";
		var test="";
		var z=0;
		for(var accoss in accos)
			{
				test+=accos['acco_'+z].title;
				//z++;
			}
		alert(test);
	}
