// function library
// (c) Naz Rajan 2006-2008
// naz@nazrajan.com
// Version 2008.0925.Naz


// Changes since 2008.0103:
// Modified MoveToCenter to work with window rather than screen size
//
// Changes since 2007.0523:
// MoveToCenter corrected to center only horizontally, not vertically
// Menu corrected to fix raised final menu link
// Added functions: GetWindowSize, FadeIn, FadeOut
//
// Changes since 2007.0613:
// Removed images path from Gallery functions to allow separation of content from site
// Added extra [14], [15], [16] parameters and functionality to Gallery gConfig array
//

// -----------------------------
// MENU
function NR_menu(iMenu,iActive) {
var i;
var menuheight=(BrowserDetect("browser")=="Safari"?"20":mHeight[iMenu]);

	document.write("<table><tr><td bgcolor='"+mBGColor[iMenu][0]+"'><table border='0' class='menuon'><tr>");
	for (i=1;i<=mItem[iMenu][0];i++) {
		document.write("<td height='"+menuheight+"' align='"+mAlign[iMenu]+"'"+(null==mClass[iMenu][i]?"":(null==mBGColor[iMenu][i]?"":" bgcolor='"+mBGColor[iMenu][i]+"' ")));
		if (iActive==i) {
			document.write("class='"+(null==mClass[iMenu][i]?"menuon":mClass[iMenu][i]+"on")+"'>"+mItem[iMenu][i]+" ");
		}
		else {
			if (mHref[iMenu][i]=="#") {
				document.write("><span class='"+(null==mClass[iMenu][i]?"menu":mClass[iMenu][i])+"'>"+mItem[iMenu][i]+"</span>");
			}
			else {
				document.write("><a href=\""+(null==mHref[iMenu][i]?"":mHref[iMenu][i])+"\" class=\""+(null==mClass[iMenu][i]?"menu":mClass[iMenu][i])+"\" ");
				document.write((null==mMouseclick[iMenu][i]?"":(mMouseclick[iMenu][i]==""?"":" onClick=\""+mMouseclick[iMenu][i]+"\"")+" "));
				document.write((null==mMouseover[iMenu][i]?"":(mMouseover[iMenu][i]==""?"":" onMouseOver=\""+mMouseover[iMenu][i]+"\"")+" "));
				document.write((null==mMouseout[iMenu][i]?"":(mMouseout[iMenu][i]==""?"":" onMouseOut=\""+mMouseout[iMenu][i]+"\"")));
				document.write(">"+mItem[iMenu][i]+"</a>");
			}
		}
		document.write((null==mBelowText[iMenu][i]?"":(mBelowText[iMenu][i]==""?"":"<br><span class=\"menutext\">"+mBelowText[iMenu][i]+"</span>")));
		if (mDirection[iMenu]==0) {
			document.write((i==mItem[iMenu][0]?"":mSeparator[iMenu])+"</td>");
		}
		else {
			document.write("</td>"+(i==mItem[iMenu][0]?"":"</tr><tr>"));
		}
	}
	document.write("</tr></table></td></tr></table>");

}

//DROP DOWN MENU --------------------------------------------
//(c) Vincent Radix - Version 2008.0218
// vince@vinceair.com
//-----------------------------------------------------------

/*
 Your rollover pictures have to be organised in a folder structure as described below:
 [menu] folder (will old all menuheaders and submenu pics files for your menu)
   => ["menuheader1"] folder (which holds the on/over/and off pic files for the menuheader1)
			=>[submenu] folder (litterally "submenu" not any other name)
					=> "submenubutton1_on.jpg"
					=> "submenubutton1_over.jpg"
					=> "submenubutton1_off.jpg"
					=> "submenubutton2_on.jpg"
					=> "submenubutton1_over.jpg"
					=>	....
   => ["menuheader2"] folder (which holds the on/over/and off pic files for the menuheader2)
			=>[submenu] folder (litterally "submenu" not any other name)
					=> "submenubutton1_on.jpg"
					=> "submenubutton1_over.jpg"
					=> "submenubutton1_off.jpg"
					=> "submenubutton2_on.jpg"
					=> "submenubutton1_over.jpg"
					=>	....
	.....
*/

//Functions called within the main function
function MM_preloadImages() { //Macromedia 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_swapImage() { //Macromedia 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_swapImgRestore() { //Macromedia 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 DropDownLayer(show,dropdivnum) {
	if (show==1) {
		document.getElementById('ldrop'+ dropdivnum).style.visibility = "visible";
	}
	else {
		document.getElementById('ldrop'+ dropdivnum).style.visibility = "hidden";
	}
}
function ShiftDiv(menunumber) {//Shift the drop down layer aside by the Menu Header Button Width in the loop
	w = 75; //Define Menu Header Button Width
	left = w * menunumber;
	return left;
}
function SetMenuOn(menunum,submenunum) {

	submenuimgnum = menunum+(parseFloat(submenunum)+1);
	document.getElementById('image'+ menunum).src = "menu/" + Menu[menunum][0] + "/on.png";
	document.getElementById('submenu'+submenuimgnum).src = "menu/" + Menu[menunum][0] + "/submenu/"+ SubMenu[menunum][submenunum] + "_on.jpg";
}				

/*
//DEFINE SUBMENUS
i=1;
Menu[i] =  new Array("menuheader1","1"); // Menu[i][1]= 1 if there is a submenu for this menu header, =0 if there is no submenu
SubMenu[i] = new Array("submenu1","submenu2","submenu3");
i++; 	
Menu[i] =  new Array("menuheader2","1");	
SubMenu[i] = new Array("submenu1","submenu2","submenu3");
i++; 	
Menu[i] =  new Array("menuheader3","1");	
SubMenu[i] = new Array("submenu1","submenu2","submenu3");
*/

function ShowDDMenu(){
                        
	for(m=1; m<Menu.length; m++){//write the menu header
	
		document.write("<td id='menu" + m +"' onMouseOver='DropDownLayer(1,"+ m +")' onMouseOut='DropDownLayer(0,"+ m +")'>");//
		document.write("<a href='#' onMouseOver=\"MM_swapImage('image"+ m +"','','menu/" + Menu[m][0] + "/over.png',1)\" onMouseOut=\"MM_swapImgRestore()\">");
		document.write("<img id='image"+ m +"' name='Image"+ m +"' width='75' height='21' border='0' src='menu/" + Menu[m][0] + "/off.png'></a>");
		leftposition = ShiftDiv(m-1);
		document.write("<div id='ldrop" + m +"' style='position:absolute; top:21px; left:"+leftposition+"px; width:67px; border:none; visibility:hidden; background-color:#000000; z-index:10'>");
		document.write("<table border='0' cellpadding='0' cellspacing='0'><tr><td bgcolor='#000000'><img border'0' width='63' height='5' src='images/spacer.gif'></td></tr></table>");//links banner and button
		document.write("<table border='0' cellpadding='0' cellspacing='2' bgcolor='#000000'>");
	
		for(sm=1; sm<=SubMenu[m].length; sm++) {//Write the submenu 
		
			smhover = "menu/" + Menu[m][0] + "/submenu/"+ SubMenu[m][sm-1] + "_over.jpg";
			smoff = "menu/" + Menu[m][0] + "/submenu/"+ SubMenu[m][sm-1] + "_off.jpg";
			
			strline = "<tr><td>";
			strline += "<a href='index.php?menu="+m+"&submenu="+[sm-1]+"'"; //reload the page and pass the menu and submenu parametres to set the active menu buttons "on"
			//strline += "<a href='" + Menu[m][0] + "_"+ SubMenu[m][sm-1] +".php?menu="+m+"&submenu="+[sm-1]+"'"; //pass the menu and submenu parametres in the page to set the active menu buttons "on"
			strline += "onMouseOver=\"MM_swapImage('submenu" + [m]+[sm] +"','','"+ smhover +"',1)\" onMouseOut=\"MM_swapImgRestore()\"";
			strline += "><img id='submenu" + [m]+[sm] +"' width='120' height='21' border='0' src='"+ smoff +"'>";
			strline += "</a></td></tr>";
			document.write(strline);
		}
		document.write("</table></div></td>");
	}
}


// -----------------------------
// GALLERY
function NR_gallery(iGallery) {
/*
gConfig[iGallery][1]	SourceFolder
gConfig[iGallery][2]	FirstPicture
gConfig[iGallery][3]	GalleryRows
gConfig[iGallery][4]	GalleryCols
gConfig[iGallery][5]	PicWidth
gConfig[iGallery][6]	PicHeight
gConfig[iGallery][7]	ThumbWidth
gConfig[iGallery][8]	ThumbHeight
gConfig[iGallery][9]	ScrollbarPos (L/B/N)
gConfig[iGallery][10]	Mainpic
gConfig[iGallery][11]	GalleryText
gConfig[iGallery][12]	0=onMouseOver, 1=OnClick
gConfig[iGallery][13]	GalleryClickEvent function name
gConfig[iGallery][14]	ThumbMultiplier (1=default, <1=multiplier)

gConfig[iGallery][30] to [99]	Spare for custom use
*/
var tnum=1;

	if (gConfig[iGallery][9]=="T") {
		document.write("<table><tr><td>");
		document.write("<a onClick=\"NR_scrollImages("+iGallery+",-1);\"><img name='scrollleft' src='images/scrollleft.gif' width='17' height='20' border='0'></a>");
		document.write("</td><td><img src='images/spacer.gif' width='"+((gConfig[iGallery][4]*(gConfig[iGallery][7]+7))-45)+"' height='20'></td><td align='right'>");
		document.write("<a onClick=\"NR_scrollImages("+iGallery+",1);\"><img name='scrollright' src='images/scrollright.gif' width='17' height='20' border='0'></a>");
		document.write("</td></tr></table>");
	}
	else if (gConfig[iGallery][9]=="L") {
		document.write("<table><tr><td><table><tr><td valign=\"top\"><a onClick=\"NR_scrollImages("+iGallery+",-1);\"><img name=\"scrollup\" src=\"images/scrollup.gif\" width=\"19\" height=\"14\" ");
		document.write("border=\"0\"></a></td></tr><tr><td height=\""+((gConfig[iGallery][3]*gConfig[iGallery][8])-20)+"\">&nbsp;</td></tr><tr><td valign=\"bottom\"><a onClick=\"NR_scrollImages("+iGallery+",1);\"><img name=\"scrolldown\" src=\"images/scrolldown.gif\" width=\"19\" height=\"14\" border=\"0\"></a></td></tr></table></td><td><table>");
	}
	else {
		document.write("<table>");
	}
	for (r=1; r<=gConfig[iGallery][3]; r++) {
		document.write("<tr><td valign='top' width='"+(gConfig[iGallery][4]*(gConfig[iGallery][7]+10))+"' height='"+(gConfig[iGallery][8]+10)+"'>");
		for (c=1; c<=gConfig[iGallery][4]; c++) {
			document.write("<img id='thumb"+tnum+"' src='");
			if (tnum>gPicture[iGallery][0]) {
				document.write("images/spacer.gif");
				document.write("' width='"+gConfig[iGallery][7]+"' height='"+gConfig[iGallery][8]+"'>");
			}
			else {
				document.write(gConfig[iGallery][1]+"/"+gThumbHeader+gPicture[iGallery][tnum]+gSourceTail);
				document.write("' width='"+(gConfig[iGallery][14]<1?gPictureWidth[iGallery][tnum]:gConfig[iGallery][7])+"' height='"+(gConfig[iGallery][14]<1?gPictureHeight[iGallery][tnum]:gConfig[iGallery][8])+"' ");
				if (gConfig[iGallery][12]==0) {
					document.write("onMouseOver=\"");
					if (gConfig[iGallery][13]>"") {document.write(gConfig[iGallery][13]+"();")}
					document.write("NR_rolloverImage(\'"+gConfig[iGallery][10]+"\', "+iGallery+", "+tnum+")\" ");
				}
				else if (gConfig[iGallery][12]==1) {
					if (gConfig[iGallery][13]>"") {document.write(" onClick=\""+gConfig[iGallery][13]+"(\'"+gClick[iGallery][((r-1)*gConfig[iGallery][4])+c]+"\');\" ")}
					else {document.write(" onClick=\"NR_rolloverImage(\'"+gConfig[iGallery][10]+"\', "+iGallery+", "+tnum+")\" ")}
				}
				document.write(">");
				document.write("<img src='images/spacer.gif' width='10' border='0'>");
			}
			tnum++;
		}
		document.write("</td></tr>");
	}
	if (gConfig[iGallery][9]=="L") {
		document.write("</table></td></tr></table>");
	}
	else {
		if (gConfig[iGallery][9]=="B") {
			document.write("<tr><td><table><tr><td>");
			document.write("<a onClick=\"NR_scrollImages("+iGallery+",-1);\"><img name='scrollleft' src='images/scrollleft.gif' width='17' height='20' border='0'></a>");
			document.write("</td><td><img src='images/spacer.gif' width='"+((gConfig[iGallery][4]*(gConfig[iGallery][7]+7))-45)+"' height='20'></td><td align='right'>");
			document.write("<a onClick=\"NR_scrollImages("+iGallery+",1);\"><img name='scrollright' src='images/scrollright.gif' width='17' height='20' border='0'></a>");
			document.write("</td></tr></table></td></tr>");
		}
		else {
			document.write("</table>");
		}
	}
}


function NR_scrollImages(iGallery,sdirection) {
var t, n, imgname, imgsrc;
var imghdr=gConfig[iGallery][1]+"/", irows=gConfig[iGallery][3], icols=gConfig[iGallery][4];
	if (sdirection==0) {
		dFirstPictureOnPage=1;	// NR_jumpToSection("",100,1);
		n=dFirstPictureOnPage;
	}
	else {
		n = dFirstPictureOnPage+(icols*sdirection);
  		n = (n<gConfig[iGallery][2]?gConfig[iGallery][2]:n);   // no scroll after reaching start
	}
	if (n<=gPicture[iGallery][0]) {  // no scroll if reached end
		dFirstPictureOnPage = n;
   		for (t=1; t<=(irows*icols); t++) {
			imgname = "thumb" + t;
			if (n>gPicture[iGallery][0]) {
			  	imgsrc = "images/spacer.gif";
				document.getElementById(imgname).alt = "";  //dSiteName;
			}
			else {
				//imgsrc = imghdr + gThumbHeader + gPicture[iGallery][n] + gSourceTail;
				imgsrc = imghdr + gPicture[iGallery][n] + gSourceTail;
				document.getElementById(imgname).alt = "Click here to see a larger version of this image \r\n(picture "+n+", file "+gPicture[iGallery][n]+")";
			}
			document.getElementById(imgname).src = imgsrc;
			document.getElementById(imgname).width = gConfig[iGallery][7];
			document.getElementById(imgname).height = gConfig[iGallery][8];
			if (gConfig[iGallery][14]<1) {
				document.getElementById(imgname).width = gPictureWidth[iGallery][n];
				document.getElementById(imgname).height = gPictureHeight[iGallery][n];
			}
			n++;
		}
	}
}

function NR_showImage(imgname, iGallery, pnum) {
var imgsrc, imgnum, imghdr=gConfig[iGallery][1]+"/", i;

	imgsrc = document.getElementById("thumb"+pnum).src;
	imgnum = dFirstPictureOnPage+pnum-1;
	document.getElementById(imgname).src = "images/spacer.gif";   // clear current picture
	document.getElementById(imgname).width = gConfig[iGallery][5];  // PicWidth
	document.getElementById(imgname).height = gConfig[iGallery][6]; // PicHeight
	if (imgnum>gPicture[iGallery][0]) {  // spacer used, not a thumbnail
		if (gConfig[iGallery][11]>"") {
			document.getElementById(gConfig[iGallery][11]).innerHTML = "&nbsp;";
		}
	}
	else {	
		if (gConfig[iGallery][11]>"") {
			document.getElementById(gConfig[iGallery][11]).innerHTML = gText[iGallery][imgnum];
		}
		document.getElementById(imgname).src = imghdr + gPicture[iGallery][imgnum] + gSourceTail;
		if (gConfig[iGallery][14]<1) {
			document.getElementById(imgname).width = gPictureWidth[iGallery][n];
			document.getElementById(imgname).height = gPictureHeight[iGallery][n];
		}
		else {
			document.getElementById(imgname).width = gConfig[iGallery][7];
			document.getElementById(imgname).height = gConfig[iGallery][8];
		}
	}

}

function NR_rolloverImage(imgname, iGallery, pnum) {
	var imgsrc, imgnum, imghdr=gConfig[iGallery][1]+"/", imgtail=gSourceTail;
// diagnosegallery();

	imgnum = dFirstPictureOnPage+pnum-1;
	if (imgnum>gPicture[iGallery][0]) {  // means spacer used, not a thumbnail
		document.getElementById(imgname).src = "images/spacer.gif";   // clear current picture
		if (gConfig[iGallery][11]>"") {
			document.getElementById(gConfig[iGallery][11]).innerHTML = "&nbsp;";
		}
	}
	else {	
		document.getElementById(imgname).src = imghdr + gPicture[iGallery][imgnum] + imgtail;
		if (gConfig[iGallery][11]>"") {
			document.getElementById(gConfig[iGallery][11]).innerHTML = gText[iGallery][imgnum];
		}
	}
}

function diagnosegallery() {
//	alert(gConfig[1][1]);
//	alert(dFirstPictureOnPage);
//	alert(gPicture[1][0]);
//	alert(document.getElementById(gConfig[1][11]).src);
//	alert(document.getElementById('mainpic').src);
alert("DIAGNOSIS");
}


// -----------------------------
// IMAGE MANAGEMENT
function NR_swapImage(flder,imgid,ovr) {
	document.getElementById(imgid).src = (ovr ? flder+"/"+imgid+"_over.jpg" : flder+"/"+imgid+".jpg");
}


// -----------------------------
// USER INTERACTION
function disableRightClick(e)
{
  var message = "Right click has been disabled";
  
  if(!document.rightClickDisabled) // initialize
  {
    if(document.layers) 
    {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = disableRightClick;
    }
    else document.oncontextmenu = disableRightClick;
    return document.rightClickDisabled = true;
  }
  if(document.layers || (document.getElementById && !document.all))
  {
    if (e.which==2||e.which==3)
    {
      alert(message);
      return false;
    }
  }
  else
  {
    alert(message);
    return false;
  }
}
disableRightClick();

// -----------------------------
// SITE PRESENTATION

function NR_movetocenter(bglayer,sdirection) {
	sw=screen.width; sh=screen.height;
	winsize = new Array(); winsize=GetWindowSize(); dw=winsize[0]; dh=winsize[1];
	lw = parseInt(document.getElementById(bglayer).style.width);
	lh = parseInt(document.getElementById(bglayer).style.height);
	document.getElementById(bglayer).style.left=0;
	document.getElementById(bglayer).style.top=0;
	n=((dw-lw)/2);
	document.getElementById(bglayer).style.left = (n<0 ? (BrowserDetect("browser")=="Firefox" ? "0px" : 0) : (BrowserDetect("browser")=="Firefox" ? n+"px" : n));
	if (dh>lh) {
		n=((dh-lh)/2);
		//document.getElementById(bglayer).style.top = (n<0 ? 0 : n);
		document.getElementById(bglayer).style.top = (n<0 ? (BrowserDetect("browser")=="Firefox" ? "0px" : 0) : (BrowserDetect("browser")=="Firefox" ? n+"px" : n));
	}
	//alert(document.getElementById(bglayer).style.left);
}

function GetWindowSize() {
  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;
  }
  
  winsize[0] = myWidth;
  winsize[1] = myHeight;
  return winsize;
}

// -----------------------------
// SITE NAVIGATION
function NR_geturl() {
	var urlquery, urlterms;
	urlquery = location.href.split("?");
	return urlquery[1];
}

//------------------------------

function GetUrlParameter( param ){  
	param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
	var regexS = "[\\?&]"+param+"=([^&#]*)";  
	var regex = new RegExp( regexS );  
	var results = regex.exec( window.location.href );  
	if( results == null )    
		return "";  
	else    
		return results[1];
}

// -----------------------------
function NR_jumpToSection(param,jumpto,jumpdefault) {
	var urlquery, urlterms;
	urlquery = location.href.split("?");
	return (urlquery[1]==param ? jumpto : jumpdefault);
}

// -----------------------------
// STRING
function NR_FormatTitle(strText) {
	var strHTML, i=0;
	i = strText.indexOf('/');
	strHTML = strText.substr(0,i) + '<br><div class=\'body\'>';
	strText = strText.substr(i+1, strText.length-i);
	i = strText.indexOf('/');
	strHTML = strHTML + strText.substr(0,i) + '<br>' + strText.substr(i+1, strText.length-i) + '</div>';
	return strHTML;
}

function NR_replaceString(str,strfind,strrepl) {
	while(1 == 1) {
		if(str.indexOf(strfind)==-1) return str;
			str = str.replace(strfind,strrepl);
	}
}

function StringLeft(str, n) {
    if (n <= 0)
        return "";
    else if (n > String(str).length)
        return str;
    else
        return String(str).substring(0,n);
}

function StringRight(str, n) {
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

// -----------------------------
// SLIDESHOW

function RunLayerSlideShow(folder,numpic,w,h,delay) {

	for (n=1; n<=numpic; n++) {
		document.write("<div id='lslide"+n+"' style='position:absolute; width:"+w+"px; height:"+h+"px; left:0px; top:0px; z-index:"+(10+n)+"; visibility: hidden;'>");
		document.write("<img id='slide"+n+"' src="+folder+n+".jpg' alt='picture' width='"+w+"' height='"+h+"' style='border:0; visibility: inherit;'>");
		document.write("</div>");
	}
	for(n=1; n<=numpic; n++) {
		strfn = "FadeIn(\"slide"+n+"\",20,5)";
		setTimeout(strfn, n*delay);
		setTimeout("document.getElementById('lslide"+n+"').style.visibility=\'visible\'", n*delay);
	}
}

function NR_RunSlideShow(divid,imageid,imageFiles,displaySecs) { 
	var imagesfolder;
	if (imageFiles.indexOf('/')>0) {
		imagesfolder = "";    // folder is part of filename so leave blank
	}
	else {
		imagesfolder = "images/";
	}
	var imageSeparator = imageFiles.indexOf(";"); 
	var nextImage = imageFiles.substring(0,imageSeparator); 
	
	if (BrowserDetect("browser")=="Firefox") {
		document.getElementById(imageid).style.visibility="hidden";
	}
	changeOpac(imageid, 0);
	blendimage(divid,imageid,imagesfolder+nextImage,100); 
	
	var futureImages = imageFiles.substring(imageSeparator+1,imageFiles.length)+ ';' + nextImage; 
	setTimeout("NR_RunSlideShow('"+divid+"','"+imageid+"','"+futureImages+"',"+displaySecs+")",displaySecs*1000); 
	
	// Cache the next image to improve performance. 
	imageSeparator = futureImages.indexOf(";"); 
	nextImage = futureImages.substring(0,imageSeparator);
 	if (dSlideCache[nextImage] == null) { 
		dSlideCache[nextImage] = new Image;
		dSlideCache[nextImage].style.visibility = "hidden";
		dSlideCache[nextImage].src = imagesfolder+nextImage;
		//dSlideCache[nextImage].style.visibility="visible";
	} 
//	document.getElementById(imageid).style.visibility="visible";
}

function changeOpac(id, opacity) { 
	var object = document.getElementById(id).style;
	
	object.opacity = (opacity==0?0:opacity/101); 
	object.MozOpacity = (opacity==0?0:opacity/101); 
	object.KhtmlOpacity = (opacity==0?0:opacity/101); 
	object.filter = "alpha(opacity=" + opacity + ")";
} 

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec/10); 
	var timer = 0; 
	//set the current image as background 
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
	changeOpac(imageid, 0); //make image transparent 
	document.getElementById(imageid).src = imagefile; //make new image
	//fade in image 
	for(i=0; i<100; i++) { 
		setTimeout("changeOpac('" + imageid + "'," + i + ")",(timer * speed)); 
		timer++; 
	} 
}


function FadeIn(layer,inter,step) {
	var fade=0;
	canvas=document.getElementById(layer).style;
	ms = (canvas.opacity==0?0:1);
	pace = setInterval(FadeIt,inter);
	
	function FadeIt() {
		if (fade<100) {
			fade+=step;
			if (ms) canvas.filter="alpha(opacity="+fade+")";
			else canvas.opacity=(fade/100);
		}
		else {
			clearInterval(pace);
		}
	}
	
}

function FadeOut(layer,inter,step) {
	var fade=100;
	canvas=document.getElementById(layer).style;
	ms = (canvas.opacity==1?1:0);
	pace = setInterval(FadeIt,inter);
	
	function FadeIt(){
		if(fade>0){
			fade-=step;
			if (ms) canvas.filter="alpha(opacity="+fade+")";
			else canvas.opacity=(fade);
		}
		else {
			clearInterval(pace);
		}
	}
	
}

function GrowImage(onoff,divid,imgid,imgwstart,imgwend,steps,delay){
	
	if ((onoff==1 && document.getElementById(imgid).width < imgwend) || (onoff==0 && document.getElementById(imgid).width > imgwstart)) {
		document.getElementById(imgid).width = document.getElementById(imgid).width + (onoff==1 ? steps : -steps);
		document.getElementById(divid).style.left = parseInt(document.getElementById(divid).style.left) + (onoff==1 ? -steps : steps) +"px";
		//document.getElementById(divid).style.left = parseInt(document.getElementById(divid).style.width) + (onoff==1 ? steps : -steps) +"px";
	
		strfn="GrowImage("+onoff+",'"+divid+"','"+imgid+"',"+imgwstart+","+imgwend+","+steps+","+delay+")";
		setTimeout(strfn, delay);
	}
}


function SlideLayer(onoff,divid,divleftstart,divleftend,steps,delay){
	
	if ((onoff==1 && parseInt(document.getElementById(divid).style.left) > divleftend) || (onoff==0 && parseInt(document.getElementById(divid).style.left) < divleftstart)) {
		document.getElementById(divid).style.left = parseInt(document.getElementById(divid).style.left) + (onoff==1 ? -steps : steps) +"px";
		strfn = "SlideLayer("+onoff+",'"+divid+"',"+divleftstart+","+divleftend+","+steps+","+delay+")";
		setTimeout(strfn, delay);
	}
	vis = (onoff==1 ? "visible" : "hidden");
	delayvis = (onoff==1 ? 600 : 50);
	setTimeout("document.getElementById('"+divid+"').style.visibility = '"+vis+"'", delayvis);
	//FadeIn(divid);
	//if (onoff==1) {FadeIn(divid,15,10);} else {FadeOut(divid);}
}

// -----------------------------
// BROWSER
// Detect Browser type and version
function BrowserDetect(nOption) {		// nOption = browser | version | os

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{	string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{	prop: window.opera,
			identity: "Opera"
		},
		{	string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{	string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{	string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{	string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{	// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{	string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{	string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{	// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{	string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{	string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{	string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

	};
	BrowserDetect.init();

	if (nOption=="browser") {return BrowserDetect.browser;}
	else if (nOption=="version") {return BrowserDetect.version;}
	else if (nOption=="os") {return BrowserDetect.OS;}
	else return "";
}

// -----------------------------

