function scrolltotop() {
  scrollTo(0,0);
}
function listElements()
{
	for (var i = 0; i < document.getElementById('myDiv').childNodes.length; i++)
	{
	var xx=document.getElementById('myDiv').childNodes[i].id;
		if (xx!=undefined)
		{
		alert(xx);
		}
	}
}


function testForObject(Id, Tag)
{
  var o = document.getElementById(Id);
  if (o)
  {
    if (Tag)
    {
      if (o.tagName.toLowerCase() == Tag.toLowerCase())
      {
        return o;
      }
    }
    else
    {
      return o;
    }
  }
  return null;
}

function changelink(a,b)
{ 

link=document.getElementById(b).href=a;

return link;
	
}

function getHTTPObject(){   
if (window.ActiveXObject) 
return new ActiveXObject("Microsoft.XMLHTTP");   
else if (window.XMLHttpRequest) return new XMLHttpRequest();   
else {      alert("Your browser does not support AJAX.");      
return null;   }
}

var xhr = false;


function OpenFile(v,d,j,z){
var maxnum=110
var idtocheck=z +d;

var subMenu=z+j;
var o = testForObject(idtocheck);

if (o)
{	
document.getElementById(subMenu).className="selected2Menu";
document.getElementById(idtocheck).style.display = "block";

for( loop=100;loop<=maxnum;loop++ )
	  {
	     var elem = document.getElementById( z+loop );
		var elem2 = document.getElementById( z+loop );
	     if( elem )
	     {
	       if( elem.id==idtocheck )
	       {	
	          elem.className = 'selected2Menu';
			  elem.style.display = "block";
	       }
	       else
	       {
				elem2.className="";
	          elem.style.display = 'none';
	       } 
	     } /* if */
	  } /*for*/
	  
for( loop=0;loop<=10;loop++ )
	  {
		var elem2 = document.getElementById( z+loop );

	     if( elem2 )
	     {
	       if( elem2.id==subMenu )
	       {	
	          elem2.className = 'selected2Menu';

	       }
	       else
	       {
				elem2.className="";
	       } 
	     } /* if */
	  } /*for*/
	  
var myArray = ['Timber', 'SheetMat', 'Building','Showroom','HomeIandE','Garden'];

for( t=0;t<=5;t++ )
	  {
		  var getmasterId=myArray[t]+'1';
		  
		var elem3 = document.getElementById(getmasterId);
		
	     if( elem3 )
	     {
	
	       if( myArray[t]==z )
	       {	
			elem3.style.display = 'block';
	       }
	       else
	       {
			elem3.style.display = 'none';
	       } 
	     } /* if */
	  } /*for*/

}



document.getElementById("TextdescriptionSection").innerHTML = "<div class='section1-text' style='background:url(ajax-loader.gif) top no-repeat;'><div style='padding-top:70px; text-align:center'>Retriving page...</div></div>";

fileRequest(v);
return false;	
}
function getNewFile(){
	fileRequest(this.id);
	return false;
}
function fileRequest(number){
	var url ="pages.php?page="+ number;
	if (window.XMLHttpRequest){
		xhr = new XMLHttpRequest();
	}
	else {
		if (window.ActiveXObject){
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}
	if (xhr) {
		xhr.onreadystatechange =showContents;
		xhr.open("GET", url, true);
		xhr.send(null);
	}
	else {
		document.getElementById("TextdescriptionSection").innerHTML = "Sorry, but I could'nt create an XMLHttpRequest";
	}
}
function showContents(){
	
	if (xhr.readyState ==4){
		if (xhr.status == 200){
			var outMsg = (xhr.responseXML && xhr.responseXML.contentType=="text/xml")? xhr.responseXML.getElementsByTagName("choices")[0].textContent : xhr.responseText;
		}
		else{
			var outMsg =document.getElementById("TextdescriptionSection").innerHTML = "<div class='Loader'><img src='ajax-loader.gif'><br />Retriving page...</div>";
		}
		document.getElementById("TextdescriptionSection"). innerHTML =outMsg;

		so_init();
		
		
		
	}
}

function showquestionbox(){
document.getElementById("hidemenuSubPageMenu").style.display = "block";
	}

function Closequestionbox()
	{
document.getElementById("hidemenuSubPageMenu").style.display = "none";
	}

	// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{ 
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 

jQuery(function($) {
		
		$('.gallery_demo_unstyled').addClass('gallery_demo'); // adds new class name to maintain degradability
		
		$('ul.gallery_demo').galleria({
			history   : true, // activates the history object for bookmarking, back-button etc.
			clickNext : true, // helper for making the image clickable
			insert    : '#main_image', // the containing selector for our main image
			onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				
				// fade in the image & caption
				if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
					image.css('display','none').fadeIn(1000);
				}
				caption.css('display','none').fadeIn(1000);
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// fade out inactive thumbnail
				_li.siblings().children('img.selected').fadeTo(500,0.3);
				
				// fade in active thumbnail
				thumb.fadeTo('fast',1).addClass('selected');
				
				// add a title for the clickable image
				image.attr('title','Next image >>');
			},
			onThumb : function(thumb) { // thumbnail effects goes here
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// if thumbnail is active, fade all the way.
				var _fadeTo = _li.is('.active') ? '1' : '0.3';
				
				// fade in the thumbnail when finnished loading
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
				
				// hover effects
				thumb.hover(
					function() { thumb.fadeTo('fast',1); },
					function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
				)
			}
		});
	});
