// JavaScript Document
function getTitle(page){
	var xmlhttp=false; //Clear our fetching variable
			try {
					xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
			} catch (e) {
					try {
							xmlhttp = new
							ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
				} catch (E) {
					xmlhttp = false;
							}
			}
			if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
					xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
			}
			var file = 'js/getTitle.php?'; //This is the path to the file we just finished making *
		xmlhttp.open('GET', file + page, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
					var content = xmlhttp.responseText; //The content data which has been retrieved ***
					if( content ){ //Make sure there is something in the content variable
						  document.getElementById('title_content').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
					}
			}
			}
			xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}

function getSub(page){
	var xmlhttp=false; //Clear our fetching variable
			try {
					xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
			} catch (e) {
					try {
							xmlhttp = new
							ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
				} catch (E) {
					xmlhttp = false;
							}
			}
			if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
					xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
			}
			var file = 'js/getSub.php?'; //This is the path to the file we just finished making *
		xmlhttp.open('GET', file + page, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
					var content = xmlhttp.responseText; //The content data which has been retrieved ***
					if( content ){ //Make sure there is something in the content variable
						  document.getElementById('sub_left').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
					}
			}
			}
			xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}


function ajaxLoader(url,id) {
 if (document.getElementById) {
   var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
 }
 if (x) {
   x.onreadystatechange = function() {
     if (x.readyState == 4 && x.status == 200) {
       el = document.getElementById(id);
       el.innerHTML = x.responseText;
     }
   }
   x.open("GET", url, true);
   x.send(null);
 }
}

function imgover(imgname,picname){
	imgname.src = picname;
}
function imgout(imgname,picname){
	imgname.src = picname;
}
function bgover(imgname,picname){
	imgname.background = picname;
}

function trim(text){
	var text1="";
	var text2="";
	
	for(var i=0; i<text.length;i++){
		if(text.charAt(i)!=" "){
			text1 = text.substr(i);
			break;
		}
	}
	var j = (text1.length)-1;
	while(j>=0){
		if(text1.charAt(j)!=" "){
			text2 = text1.substr(0,j+1);
			break;
		}
		j--;
	}
	return text2;
}

function validateEmail(email)
{
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}   

function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}
function checkNumber(val) {
  var strPass = val.value;
  var strLength = strPass.length;
  var lchar = val.value.charAt((strLength) - 1);
  var cCode = CalcKeyCode(lchar);

  /* Check if the keyed in character is a number
     do you want alphabetic UPPERCASE only ?
     or lower case only just check their respective
     codes and replace the 48 and 57 */

  if (cCode < 48 || cCode > 57 ) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  return false;
}

function handleEnter (field, event) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		var i;
		for (i = 0; i < field.form.elements.length; i++)
			if (field == field.form.elements[i])
				break;
		i = (i + 1) % field.form.elements.length;
		field.form.elements[i].focus();
		return false;
	} 
	else
	return true;
} 

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 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 verifyContact() {
	var flag=true;
	var themessage = "You are required to complete the following fields: ";
	if (document.frmContact.c_name.value=="" || trim(document.frmContact.c_name.value)=="") {
		themessage = themessage + " - Name";
		document.frmContact.c_name.value = trim(document.frmContact.c_name.value);
		document.frmContact.c_name.focus();
	}
	else if(!validateEmail(document.frmContact.c_email.value)){
		themessage = themessage + " - Email";
		document.frmContact.c_email.value = trim(document.frmContact.c_email.value);
		document.frmContact.c_email.focus();
	}
	else if(document.frmContact.c_message.value=="" || trim(document.frmContact.c_message.value)==""){
		themessage = themessage + " - Message";
		document.frmContact.c_message.value = trim(document.frmContact.c_message.value);
		document.frmContact.c_message.focus();
	}
	//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ") {
		document.frmContact.c_name.value = trim(document.frmContact.c_name.value);
		document.frmContact.c_message.value = trim(document.frmContact.c_message.value);
		document.frmContact.submit();
	}
	else {
		alert(themessage);
		return false;
	}
	/*if (flag) {
		//document.frmContact.frmSubmit.value = "finish";
		document.frmContact.submit();
	}
	else {
		document.getElementById('error1').style.visibility = 'visible';
		return false;
	}*/
}
function resetContact(){
	//document.getElementById('error1').style.visibility = 'hidden';
	document.frmContact.reset();
	document.frmContact.c_name.focus();
}

function verifyOrder() {
	var flag=true;
	var themessage = "You are required to complete the following fields: ";
	if (document.frmContact.c_name.value=="" || trim(document.frmContact.c_name.value)=="") {
		themessage = themessage + " - Your Full Name";
		document.frmContact.c_name.value = trim(document.frmContact.c_name.value);
		document.frmContact.c_name.focus();
	}
	else if(!validateEmail(document.frmContact.c_email.value)){
		themessage = themessage + " - Your Email Address";
		document.frmContact.c_email.value = trim(document.frmContact.c_email.value);
		document.frmContact.c_email.focus();
	}
	else if (document.frmContact.c_tel.value=="" || trim(document.frmContact.c_tel.value)=="") {
		themessage = themessage + " - Your Contact Number";
		document.frmContact.c_tel.value = trim(document.frmContact.c_tel.value);
		document.frmContact.c_tel.focus();
	}
	else if(document.frmContact.c_message.value=="" || trim(document.frmContact.c_message.value)==""){
		themessage = themessage + " - Comments";
		document.frmContact.c_message.value = trim(document.frmContact.c_message.value);
		document.frmContact.c_message.focus();
	}
	//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ") {
		document.frmContact.c_name.value = trim(document.frmContact.c_name.value);
		document.frmContact.c_message.value = trim(document.frmContact.c_message.value);
		document.frmContact.submit();
	}
	else {
		alert(themessage);
		return false;
	}
	/*if (flag) {
		//document.frmContact.frmSubmit.value = "finish";
		document.frmContact.submit();
	}
	else {
		document.getElementById('error1').style.visibility = 'visible';
		return false;
	}*/
}
function resetOrder(){
	//document.getElementById('error1').style.visibility = 'hidden';
	document.frmContact.reset();
	document.frmContact.c_name.focus();
}

function trim(text){
	var text1="";
	var text2="";
	
	for(var i=0; i<text.length;i++){
		if(text.charAt(i)!=" "){
			text1 = text.substr(i);
			break;
		}
	}
	var j = (text1.length)-1;
	while(j>=0){
		if(text1.charAt(j)!=" "){
			text2 = text1.substr(0,j+1);
			break;
		}
		j--;
	}
	return text2;
}

//News Scroll
var toScroll=new Array()
var ie=document.all
var dom=document.getElementById
var firstNews_obj;
var secondNews_obj;

function newsScroll(name){
  var c=this; c.name=name; c.mc=0; c.i=2;
  return this;
}

newsScroll.prototype.addItem = function(text,link,font,fontSize,fontStyle){
  var c = this;
  if (link !=''){
    if (font != '')
      toScroll[c.mc]="<a href='"+link+"'><font face='"+font+"' size='"+fontSize+"' Class='"+fontStyle+"'>"+text+"</font></a>";
    else
      toScroll[c.mc]="<a href='"+link+"'><font Class='"+fontStyle+"'>"+text+"</font></a>";
  }
  else { 
    if (font != '')
      toScroll[c.mc]="<font face='"+font+"' size='"+fontSize+"' Class='"+fontStyle+"'>"+text+"</font>";
    else
      toScroll[c.mc]="<font Class='"+fontStyle+"'>"+text+"</font>";
  }
  c.mc++;
}

newsScroll.prototype.construct = function(){
  var c = this; theWidth = c.scrollerwidth; theHeight=c.scrollerheight; thebgColor = c.scrollerbgcolor; theBackground =c.scrollerbackground; theDelay=c.scrollerdelay;
  scroll_obj=eval(c.name);        
  if (ie||dom){
    document.writeln('<div id="main2" style="position:relative;width:'+theWidth+';height:'+theHeight+';overflow:hidden;background-color:'+thebgColor+' ;background-image:url('+theBackground+')">')
    document.writeln('<div style="position:absolute;width:'+theWidth+';height:'+theHeight+';clip:rect(0 '+theWidth+' '+theHeight+' 0);left:0;top:0">')
    document.writeln('<div id="firstNews" style="position:absolute;width:'+theWidth+';left:0;top:1">')
    document.write(toScroll[0])
    document.writeln('</div>')
    document.writeln('<div id="secondNews" style="position:absolute;width:'+theWidth+';left:0;top:0;visibility:hidden">')
    document.write(toScroll[dyndetermine=(toScroll.length==1)? 0 : 1])
    document.writeln('</div>')
    document.writeln('</div>')
    document.writeln('</div>')
  }
}

newsScroll.prototype.move = function(whichdiv){
  var c = this; theDelay = c.scrollerdelay; theHeight = c.scrollerheight; 
  scroll_obj=eval(c.name);
  tdiv=eval(whichdiv)

  if (parseInt(tdiv.style.top)>0&&parseInt(tdiv.style.top)<=5){
    tdiv.style.top=0+"px"
    setTimeout("scroll_obj.move(tdiv)",theDelay)
    setTimeout("scroll_obj.move2(secondNews_obj)",theDelay)
    //document.write('Got Milk?')
  return
  }
  if (parseInt(tdiv.style.top)>=tdiv.offsetHeight*-1){
    tdiv.style.top=parseInt(tdiv.style.top)-5+"px"
    setTimeout("scroll_obj.move(tdiv)",50)
  }
  else {
    tdiv.style.top=parseInt(theHeight)+"px"
    tdiv.innerHTML=toScroll[c.i]
    if (c.i==toScroll.length-1)
      c.i=0
    else
      c.i++
  }
}

newsScroll.prototype.move2 = function(whichdiv){
  var c = this; theDelay = c.scrollerdelay; theHeight= c.scrollerheight;
  scroll_obj=eval(c.name);
  tdiv2=eval(whichdiv)

  if (parseInt(tdiv2.style.top)>0&&parseInt(tdiv2.style.top)<=5){
    tdiv2.style.top=0+"px"
    setTimeout("scroll_obj.move2(tdiv2)",theDelay)
    setTimeout("scroll_obj.move(firstNews_obj)",theDelay)
    return
  }
  if (parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1){
    tdiv2.style.top=parseInt(tdiv2.style.top)-5+"px"
    setTimeout("scroll_obj.move2(secondNews_obj)",50)
  }
  else {
    tdiv2.style.top=parseInt(theHeight)+"px"
    tdiv2.innerHTML=toScroll[c.i]
    if (c.i==toScroll.length-1)
      c.i=0
    else
      c.i++
  }
}

newsScroll.prototype.startScroll = function(){
  var c = this;
  scroll_obj=eval(c.name);        
  
  if (toScroll.length >2)
    c.i = 2;
  else
    c.i = 0;
  
  firstNews_obj=ie? firstNews : document.getElementById("firstNews")
  secondNews_obj=ie? secondNews : document.getElementById("secondNews")
  setTimeout("scroll_obj.move(firstNews_obj)",c.scrollerDelay);
  secondNews_obj.style.top=theHeight;
  secondNews_obj.style.visibility='visible'
}

//Slide Show

var slideshow2_noFading = false;
var slideshow2_timeBetweenSlides = 2000;	// Amount of time between each image(1000 = 1 second)
var slideshow2_fadingSpeed = 30;	// Speed of fading	(Lower value = faster)

var slideshow2_galleryContainer;	// Reference to the gallery div
var slideshow2_galleryWidth;	// Width of gallery
var slideshow2_galleryHeight;	// Height of galery
var slideshow2_slideIndex = -1;	// Index of current image shown
var slideshow2_slideIndexNext = false;	// Index of next image shown
var slideshow2_imageDivs = new Array();	// Array of image divs(Created dynamically)
var slideshow2_currentOpacity = 100;	// Initial opacity
var slideshow2_imagesInGallery = false;	// Number of images in gallery
var Opera = navigator.userAgent.indexOf('Opera')>=0?true:false;
function createParentDivs(imageIndex)
{
	if(imageIndex==slideshow2_imagesInGallery){			
		showGallery();
	}else{
		var imgObj = document.getElementById('galleryImage' + imageIndex);	
		if(Opera)imgObj.style.position = 'static';
		slideshow2_imageDivs[slideshow2_imageDivs.length] =  imgObj;
		imgObj.style.visibility = 'hidden';	
		imageIndex++;
		createParentDivs(imageIndex);	
	}		
}

function showGallery()
{
	if(slideshow2_slideIndex==-1)slideshow2_slideIndex=0; else slideshow2_slideIndex++;	// Index of next image to show
	if(slideshow2_slideIndex==slideshow2_imageDivs.length)slideshow2_slideIndex=0;
	slideshow2_slideIndexNext = slideshow2_slideIndex+1;	// Index of the next next image
	if(slideshow2_slideIndexNext==slideshow2_imageDivs.length)slideshow2_slideIndexNext = 0;
	
	slideshow2_currentOpacity=100;	// Reset current opacity

	// Displaying image divs
	slideshow2_imageDivs[slideshow2_slideIndex].style.visibility = 'visible';
	if(Opera)slideshow2_imageDivs[slideshow2_slideIndex].style.display = 'inline';
	if(navigator.userAgent.indexOf('Opera')<0){
		slideshow2_imageDivs[slideshow2_slideIndexNext].style.visibility = 'visible';
	}
	
	if(document.all){	// IE rules
		slideshow2_imageDivs[slideshow2_slideIndex].style.filter = 'alpha(opacity=100)';
		slideshow2_imageDivs[slideshow2_slideIndexNext].style.filter = 'alpha(opacity=1)';
	}else{
		slideshow2_imageDivs[slideshow2_slideIndex].style.opacity = 0.99;	// Can't use 1 and 0 because of screen flickering in FF
		slideshow2_imageDivs[slideshow2_slideIndexNext].style.opacity = 0.01;
	}		
	

	setTimeout('revealImage()',slideshow2_timeBetweenSlides);		
}

function revealImage()
{
	if(slideshow2_noFading){
		slideshow2_imageDivs[slideshow2_slideIndex].style.visibility = 'hidden';
		if(Opera)slideshow2_imageDivs[slideshow2_slideIndex].style.display = 'none';
		showGallery();
		return;
	}
	slideshow2_currentOpacity--;
	if(document.all){
		slideshow2_imageDivs[slideshow2_slideIndex].style.filter = 'alpha(opacity='+slideshow2_currentOpacity+')';
		slideshow2_imageDivs[slideshow2_slideIndexNext].style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity)+')';
	}else{
		slideshow2_imageDivs[slideshow2_slideIndex].style.opacity = Math.max(0.01,slideshow2_currentOpacity/100);	// Can't use 1 and 0 because of screen flickering in FF
		slideshow2_imageDivs[slideshow2_slideIndexNext].style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity/100)));
	}
	if(slideshow2_currentOpacity>0){
		setTimeout('revealImage()',slideshow2_fadingSpeed);
	}else{
		slideshow2_imageDivs[slideshow2_slideIndex].style.visibility = 'hidden';	
		if(Opera)slideshow2_imageDivs[slideshow2_slideIndex].style.display = 'none';		
		showGallery();
	}
}

function initImageGallery()
{
	slideshow2_galleryContainer = document.getElementById('imageSlideshowHolder');
	slideshow2_galleryWidth = slideshow2_galleryContainer.clientWidth;
	slideshow2_galleryHeight = slideshow2_galleryContainer.clientHeight;
	galleryImgArray = slideshow2_galleryContainer.getElementsByTagName('IMG');
	for(var no=0;no<galleryImgArray.length;no++){
		galleryImgArray[no].id = 'galleryImage' + no;
	}
	slideshow2_imagesInGallery = galleryImgArray.length;
	createParentDivs(0);		
	
}

	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, November 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/

	var timeBeforeAutoHide = 700;	// Microseconds to wait before auto hiding menu(1000 = 1 second)
	var slideSpeed_out = 10;	// Steps to move sub menu at a time ( higher = faster)
	var slideSpeed_in = 10;
		
	
	var slideTimeout_out = 25;	// Microseconds between slide steps ( lower = faster)
	var slideTimeout_in = 10;	// Microseconds between slide steps ( lower = faster)
	
	var showSubOnMouseOver = true;	// false = show sub menu on click, true = show sub menu on mouse over
	var fixedSubMenuWidth = false;	// Width of sub menu items - A number(width in pixels) or false when width should be dynamic
	
	var xOffsetSubMenu = 0; 	// Offset x-position of sub menu items - use negative value if you want the sub menu to overlap main menu
	
	var slideDirection = 'right';	// Slide to left or right ?
	
	/* Don't change anything below here */
	
	var activeSubMenuId = false;
	var activeMainMenuItem = false;
	var currentZIndex = 1000;		
	var autoHideTimer = 0;
	var submenuObjArray = new Array();
	var okToSlideInSub = new Array();
	var subPositioned = new Array();
	

	function stopAutoHide()
	{
		autoHideTimer = -1;
	}
	
	function initAutoHide()
	{
		autoHideTimer = 0;
		if(autoHideTimer>=0)autoHide();
	}
	
	function autoHide()
	{
		
		if(autoHideTimer>timeBeforeAutoHide)
		{
			
			if(activeMainMenuItem){
				activeMainMenuItem.className='';
				activeMainMenuItem = false;
			}
			
			if(activeSubMenuId){
				var obj = document.getElementById('subMenuDiv' + activeSubMenuId);
				showSub();
			}
		}else{
			if(autoHideTimer>=0){
				autoHideTimer+=50;
				setTimeout('autoHide()',50);
			}
		}
	}	
	
	function getTopPos(inputObj)
	{		
	  var returnValue = inputObj.offsetTop;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
	  return returnValue;
	}
	
	function getLeftPos(inputObj)
	{
	  var returnValue = inputObj.offsetLeft;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
	  return returnValue;
	}
	
	function showSub()
	{
		var subObj = false;
		if(this && this.tagName){
			var numericId = this.parentNode.id.replace(/[^0-9]/g,'');
			okToSlideInSub[numericId] = false;
			var subObj = document.getElementById('subMenuDiv' + numericId);
			if(activeMainMenuItem)activeMainMenuItem.className='';
			if(subObj){
				if(!subPositioned[numericId]){
					if(slideDirection=='right'){
						subObj.style.left = getLeftPos(submenuObjArray[numericId]['parentDiv']) + submenuObjArray[numericId]['parentDiv'].offsetWidth + xOffsetSubMenu + 'px';
					}else{
						subObj.style.left = getLeftPos(submenuObjArray[numericId]['parentDiv']) + xOffsetSubMenu + 'px';
						
					}
					submenuObjArray[numericId]['left'] = subObj.style.left.replace(/[^0-9]/g,'');
					subObj.style.top = getTopPos(submenuObjArray[numericId]['parentDiv']) + 'px';
					subPositioned[numericId] = true;
				}				
				subObj.style.visibility = 'visible';
				subObj.style.zIndex = currentZIndex;
				currentZIndex++;	
				this.className='activeMainMenuItem';
				activeMainMenuItem = this;
			}
		}else{
			var numericId = activeSubMenuId;
		}
		if(activeSubMenuId && (numericId!=activeSubMenuId || !subObj))slideMenu(activeSubMenuId,(slideSpeed_in*-1));
		if(numericId!=activeSubMenuId && this && subObj){
			subObj.style.width = '0px';	
			slideMenu(numericId,slideSpeed_out);
			activeSubMenuId = numericId;
		}else{
			if(numericId!=activeSubMenuId)activeSubMenuId = false;
		}
		if(showSubOnMouseOver)stopAutoHide();
	}
	
	function slideMenu(menuIndex,speed){
		var obj = submenuObjArray[menuIndex]['divObj'];
		var obj2 = submenuObjArray[menuIndex]['ulObj'];
		var width = obj.offsetWidth + speed;
		if(speed<0){
			if(width<0)width = 0;
			obj.style.width = width + 'px';
			if(slideDirection=='left'){
				obj.style.left = submenuObjArray[menuIndex]['left'] - width + 'px';
				obj2.style.left = '0px';
			}else{
				obj2.style.left = width - submenuObjArray[menuIndex]['width'] + 'px' 
			}
			if(width>0 && okToSlideInSub[menuIndex])setTimeout('slideMenu(' + menuIndex + ',' + speed + ')',slideTimeout_in); else{
				obj.style.visibility = 'hidden';
				obj.style.width = '0px';
				if(activeSubMenuId==menuIndex)activeSubMenuId=false;
			}
			
		}else{
			if(width>submenuObjArray[menuIndex]['width'])width = submenuObjArray[menuIndex]['width'];
			if(slideDirection=='left'){
				obj.style.left = submenuObjArray[menuIndex]['left'] - width + 'px';
				obj2.style.left = '0px';
			}else{
				obj2.style.left = width - submenuObjArray[menuIndex]['width'] + 'px' 
			}		
			
			obj.style.width = width + 'px';
			if(width<submenuObjArray[menuIndex]['width']){
				setTimeout('slideMenu(' + menuIndex + ',' + speed + ')',slideTimeout_out);
			}else{
				okToSlideInSub[menuIndex] = true;
			}
		}
	}
	function resetPosition()
	{
		subPositioned.length = 0;
	}
			
	function initLeftMenu()
	{
		var isMSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
		var browserVersion = parseInt(navigator.userAgent.replace(/.*?MSIE ([0-9]+?)[^0-9].*/g,'$1'));
		if(!browserVersion)browserVersion=1;
		
		var menuObj = document.getElementById('dhtmlgoodies_menu');	
		var mainMenuItemArray = new Array();
		
		var mainMenuItem = menuObj.getElementsByTagName('LI')[0];
		while(mainMenuItem){
			if(mainMenuItem.tagName && mainMenuItem.tagName.toLowerCase()=='li'){
				mainMenuItemArray[mainMenuItemArray.length] = mainMenuItem;
				var aTag = mainMenuItem.getElementsByTagName('A')[0];
				if(showSubOnMouseOver)
					aTag.onmouseover = showSub;	
				else
					aTag.onclick = showSub;	
			}
			mainMenuItem = mainMenuItem.nextSibling;
		}		
		
		var lis = menuObj.getElementsByTagName('A');
		for(var no=0;no<lis.length;no++){
			if(!showSubOnMouseOver)lis[no].onmouseover = stopAutoHide;
			lis[no].onmouseout = initAutoHide;
			lis[no].onmousemove = stopAutoHide;
		}
				
		for(var no=0;no<mainMenuItemArray.length;no++){
			var sub = mainMenuItemArray[no].getElementsByTagName('UL')[0];
			if(sub){
				mainMenuItemArray[no].id = 'mainMenuItem' + (no+1);
				var div = document.createElement('DIV');
				div.className='dhtmlgoodies_subMenu';
				document.body.appendChild(div);
				div.appendChild(sub);
				if(slideDirection=='right'){
					div.style.left = getLeftPos(mainMenuItemArray[no]) + mainMenuItemArray[no].offsetWidth + xOffsetSubMenu + 'px';
				}else{
					div.style.left = getLeftPos(mainMenuItemArray[no]) + xOffsetSubMenu + 'px';
				}
				div.style.top = getTopPos(mainMenuItemArray[no]) + 'px';
				div.id = 'subMenuDiv' + (no+1);
				sub.id = 'submenuUl' + (no+1);
				sub.style.position = 'relative';	

				if(navigator.userAgent.indexOf('Opera')>=0){
					submenuObjArray[no+1] = new Array();
					submenuObjArray[no+1]['parentDiv'] = mainMenuItemArray[no];
					submenuObjArray[no+1]['divObj'] = div;
					submenuObjArray[no+1]['ulObj'] = sub;
					submenuObjArray[no+1]['width'] = sub.offsetWidth;
					submenuObjArray[no+1]['left'] = div.style.left.replace(/[^0-9]/g,'');
				}
				sub.style.left = 1 - sub.offsetWidth + 'px';	
				
				
				
				if(browserVersion<7 && isMSIE)div.style.width = '1px';	
					
				if(navigator.userAgent.indexOf('Opera')<0){
					submenuObjArray[no+1] = new Array();
					submenuObjArray[no+1]['parentDiv'] = mainMenuItemArray[no];
					submenuObjArray[no+1]['divObj'] = div;
					submenuObjArray[no+1]['ulObj'] = sub;
					submenuObjArray[no+1]['width'] = sub.offsetWidth;
					
					
					
					submenuObjArray[no+1]['left'] = div.style.left.replace(/[^0-9]/g,'');
					if(fixedSubMenuWidth)submenuObjArray[no+1]['width'] = fixedSubMenuWidth;
				}	

				if(!document.all)div.style.width = '1px';			
					
			}			
		}
			

		
		
		menuObj.style.visibility = 'visible';
		
		window.onresize = resetPosition;
	}
	
	
	window.onload = initLeftMenu;