var content ;
var contentcontainer ;
var position = 1;
var rot_position = 1;
var rot_timer;
var maxY,wd, maxX, ready, slideDur=600, destX=0, destY=0, distY, distX, per, sliding, slideStart, aniTimer, startX, startY, xcoordinate, ycoordinate,url_path_rotation;

function load(cntId,rot_value,url_path)
{
	position = 0;
	url_path_rotation = url_path;
	if(!document.getElementById)
		return;

	content = document.getElementById("content");
	contentcontainer = document.getElementById("content-container"); 

	content.visibility="hidden";
	content.style.top=0;
	content.style.left=0;
	xcoordinate=0;
	ycoordinate=0;
	maxY=(content.offsetHeight-contentcontainer.offsetHeight>0)?content.offsetHeight-contentcontainer.offsetHeight:0;
	wd=cntId?document.getElementById(cntId).offsetWidth:content.offsetWidth;
	maxX=(wd-contentcontainer.offsetWidth>0)?wd-contentcontainer.offsetWidth:0;
	content.style.visibility="visible";
	ready=true;
	document.getElementById("slide-links").style.visibility="visible";
	rot_timer = setInterval("do_rotation()",rot_value);
 }

function glideTo(MstartX, MstartY)
{
	content = document.getElementById("content"); 
	contentcontainer = document.getElementById("content-container");
	startX = parseInt(content.style.left);
	if(startX == "")
	{
		startX = 0;
	}
	startY = parseInt(content.style.top);
	destX = -Math.max(Math.min(MstartX, maxX), 0);
	destY = -Math.max(Math.min(MstartY, maxY), 0);
	distY = destY - startY;
	distX =  destX - startX;
	per = Math.PI/(2 * slideDur);
	sliding = false;
	slideStart = (new Date()).getTime();
	aniTimer = setInterval("doSlide()",10);
	on_slide_start(startX, startY);
  }



function doSlide() 
{
	var elapsed = (new Date()).getTime() - slideStart;
	if (elapsed < slideDur) 
	{
		var x = startX + distX * Math.sin(per*elapsed);
		var y = startY + distY * Math.sin(per*elapsed);
		shiftTo(x, y);
		on_slide(x, y);
	} 
	else
	{	// if time's up
		clearInterval(aniTimer);
		sliding = false;
		shiftTo(destX, destY);
		//content = null;
		on_slide_end(destX, destY);
	}
}
function shiftTo(x,y)
{
	 if(typeof(x) == "number")
	 {
		content.style.left=x+"px";
		content.style.top=y+"px";
	 }
}

on_slide_start = function() {}
on_slide = function() {}
on_slide_end = function() {}


function slide(id,img_url)
{
	clearInterval(rot_timer);
	position = id;
	glideTo(eval(id-1) * 390,0);
	for(var z=1;z<=6;z++)
	{
		if(id == z)
		{
			document.getElementById("slide" + id).src = img_url + "slide-on.gif";
		}
		else
		{
			document.getElementById("slide" + z).src = img_url + "slide-off.gif";
		}
	}
	if(id == 6)
	{
		disableAnchor(document.getElementById("slidenext"),true);
		document.getElementById("image_next").src = url_path_rotation + "next-disable.gif";
		disableAnchor(document.getElementById("slideprevious"),false);
		document.getElementById("image_previous").src = url_path_rotation + "prev.gif";
	}
	if(id == 1)
	{
		disableAnchor(document.getElementById("slideprevious"),true);
		document.getElementById("image_previous").src = url_path_rotation + "prev-disable.gif";
		disableAnchor(document.getElementById("slidenext"),false);
		document.getElementById("image_next").src = url_path_rotation + "next.gif";
	}
	if(position > 1  && position < 6)
	{
		disableAnchor(document.getElementById("slidenext"),false);
		document.getElementById("image_next").src = url_path_rotation + "next.gif";
		disableAnchor(document.getElementById("slideprevious"),false);
		document.getElementById("image_previous").src = url_path_rotation + "prev.gif";
	}
}

function next_previous(str,img_url)
{
	clearInterval(rot_timer);
	if(str == "next")
	{
		if(document.getElementById("slideprevious").href == "")
		{
			if(position != 6)
			{
				disableAnchor(document.getElementById("slideprevious"),false);
				document.getElementById("image_previous").src = url_path_rotation + "prev.gif";
			}
		}
		if(position < 3)
		{
			position++;
			glideTo(eval(position-1) * 390,0);
			disableAnchor(document.getElementById("slidenext"),false);
			document.getElementById("image_next").src = url_path_rotation + "next.gif";
		}
		if(position == 3)
		{
			disableAnchor(document.getElementById("slidenext"),true);
			document.getElementById("image_next").src = url_path_rotation + "next-disable.gif";
		}
		
	}
	if(str == "previous")
	{
		if(document.getElementById("slidenext").href == "")
		{
			disableAnchor(document.getElementById("slidenext"),false);
			document.getElementById("image_next").src = url_path_rotation + "next.gif";
		}
		if(position > 1)
		{
			position--;
			glideTo(eval(position-1) * 390,0);
			disableAnchor(document.getElementById("slideprevious"),false);
			document.getElementById("image_previous").src = url_path_rotation + "prev.gif";
		}
		if(position == 1)
		{
			disableAnchor(document.getElementById("slideprevious"),true);
			document.getElementById("image_previous").src = url_path_rotation + "prev-disable.gif";
		}

	}
	for(var z=1;z<=6;z++)
	{
		if(position == z)
		{
			document.getElementById("slide" + position).src = img_url + "slide-on.gif";
		}
		else
		{
			document.getElementById("slide" + z).src = img_url + "slide-off.gif";
		}
	}

}

function do_rotation()
{
	if(position < 6)
	{
		position++;
		glideTo(eval(position-1) * 390,0);
	}
	else
	{
		position = 1;
		content.style.left="0px";
		content.style.top="0px";
	}
	for(var z=1;z<=6;z++)
	{
		if(position == z)
		{
			document.getElementById("slide" + position).src = url_path_rotation + "slide-on.gif";
		}
		else
		{
			document.getElementById("slide" + z).src = url_path_rotation + "slide-off.gif";
		}
	}
}

function disableAnchor(obj, disable)
{
	if(disable)
	{
		var href = obj.getAttribute("href");
		obj.removeAttribute('href');
	}
	else
	{
		if(obj.id == "slidenext")
		{
			obj.setAttribute('href',"Javascript:next_previous('next','" + url_path_rotation + "')");
		}
		if(obj.id == "slideprevious")
		{
			obj.setAttribute('href',"Javascript:next_previous('previous','" + url_path_rotation + "')");
		}
	}
}

//window.onLoad = function()
//{


//}







document.write("<style type='text/css'> #loader {font-family:Tahoma, Helvetica, sans;	font-size:11px;	color:#000000; background-color:#FFFFFF; padding:10px 0 10px 0; margin:0 auto; display:block; width:75px; border:1px solid #6A6A6A; text-align:middle; z-index:255;} #photoholder {font-family:Tahoma, Helvetica, sans;	font-size:11px;	color:#000000; background-color:#FFFFFF; padding:10px 10px 10px 10px; border:1px solid #6A6A6A; text-align:middle;} </style>");

function setImg(imagename) {

  var w = 0;
	var h = 0;

var b = new Array();

count = 0;
while ( (w == 0 || h == 0) && count < 100 ) {
	
var image = new Image();
image.src = imagename;

if (image.width > 0 && image.height > 0) {
w = image.width; h = image.height; 
}
count = count + 1;
}

image.onLoad = setImg2(b);

function setImg2(b) {
w = image.width; h = image.height;

if (w>h) {
proportion = h/w;
if (w>600) {
w = 600;
h = proportion*w;
h = Math.round(h);
b[0] = w;
b[1] = h;
return b;
}
else {
b[0] = w;
b[1] = h;
return b; } }

else if (h>w) {
proportion = w/h;
if (h>550) {
h = 550;
w = proportion*h;
w = Math.round(w);
b[0] = w;
b[1] = h;
return b;
}
else {
b[0] = w;
b[1] = h;
return b; } }

else {
if (w>600) {
w = 600;
h = 550;
b[0] = w;
b[1] = h;
return b; } 
else {
b[0] = w;
b[1] = h;
return b; }
} 

}

return b; 
}


function initImage() {
  imageId = 'thephoto';
	if (document.getElementById(imageId))
     image = document.getElementById(imageId);
	//if (document.all)
	   //image = document.all['thephoto'];
  //setOpacity(image, 0);
  image.style.visibility = 'visible';
  //fadeIn(imageId,0);
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  obj.style.filter = "alpha(opacity:"+opacity+")";
  obj.style.KHTMLOpacity = opacity/100;
  obj.style.MozOpacity = opacity/100;
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById)
    obj = document.getElementById(objId);
	//if (document.all)
	  //obj = document.all['thephoto'];
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  
}
	
var offsetfrommouse=[15,15]; 
var displayduration=0; 
var currentimageheight = 135;	
var currentimagewidth = 135;	
var timer;
var timer2 = 0;
var firsttime = 0;

function gettrailobj(){
if (document.getElementById)
return document.getElementById("preview_div").style
//else if (document.all)
//return document.all.['preview_div'].style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("preview_div")
//else if (document.all)
//return document.all.['preview_div']
}

function gettrailobjpre(){
if (document.getElementById)
return document.getElementById("pre_loader").style
//else if (document.all)
//return document.all.['preview_div'].style
}

function gettrailobjnostylepre(){
if (document.getElementById)
return document.getElementById("pre_loader")
//else if (document.all)
//return document.all.['preview_div']
}

function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function hidetrail(){
  if (document.getElementById) {	
	gettrailobj().display= "none";
	gettrailobjpre().display="none";
	document.onmousemove=""
	gettrailobj().left="-500px"
	gettrailobjpre().left="-500px"
	clearTimeout(timer);
	if (timer2 != 0) { clearInterval(timer2); timer2 = 0; }
	firsttime = 0; }
}

function showtrail(imagename,title,showthumb){
	i = imagename
	t = title
	s = showthumb
  if (document.getElementById) {
	   timer = setTimeout("show('"+i.replace("'", "\\'")+"',t,s);",200); }
}

function show(imagename,title,showthumb){

  var w = 0;
	var h = 0;
    var a = setImg(imagename,w,h);
		
		currentimagewidth = a[0];
		currentimageheight = a[1];
		currentimagewidth = currentimagewidth + 20;
		
        var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
	      var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

if((navigator.userAgent.indexOf("Firefox")!=-1 || (navigator.userAgent.indexOf("Opera")==-1 && navigator.appVersion.indexOf("MSIE")!=-1)) && (docwidth>650 && docheight>500)){
	
	document.onmousemove=followmouse;
	 
	newHTML = '<h2>' + title + '</h2>';
	if (showthumb > 0){
    if (a[0] > 0 && a[1] > 0) { 
    newHTML = newHTML + '<div id="photoholder" name="photoholder" align="center"><img src="' + imagename + '" id="thephoto" name="thephoto" width="' + a[0] + '"  height="' + a[1] + '" alt="" border="0"></div>';
    if (timer2 != 0) {
    clearInterval(timer2); timer2 = 0; } document.onmousemove=followmouse;
		}
		else {
		newHTML = '<div id="photoholder" name="photoholder" align="center" style="padding: 0px 0px 0px 0px;"><img src="../images/spacer.gif" id="thephoto" name="thephoto" width="1"  height="1" alt="" border="0"></div>';
    if (timer2 == 0) { timer2 = setInterval("show('"+imagename+"','"+title+"',1);",300); }
		document.onmousemove=followmouse;
		}

  }

}

function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < currentimagewidth + 35){

		if(navigator.userAgent.indexOf("Firefox")!=-1)	{xcoord = e.pageX - xcoord - currentimagewidth - 35 + 2*offsetfrommouse[0]} else{ xcoord = e.pageX - xcoord - currentimagewidth - 35 + 6*offsetfrommouse[0] ;}
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 110)){
			ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < currentimagewidth + 35){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - currentimagewidth - 35 + 2*offsetfrommouse[0];
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 110)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-offsetfrommouse[0]
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
	
	middlewidth = (currentimagewidth/2) - 40;
	middleheight = currentimageheight/2;
	
	gettrailobjpre().left=(middlewidth+xcoord)+"px"
	gettrailobjpre().top=(middleheight+ycoord)+"px"
	
	if (firsttime == 0) {
	
	if (timer2 == 0) { timer2 = setInterval("show('"+imagename+"','"+title+"',1);",300); }
	if (document.getElementById) {
		newHTML2 = '';
    gettrailobjnostylepre().innerHTML = newHTML2;
    gettrailobjpre().display="block"; }
			
	if ( typeof( window[ 'newHTML' ] ) != "undefined" ) {
	if (a[0] > 0 && a[1] > 0) { 
	gettrailobjnostyle().innerHTML = newHTML;

	gettrailobj().display="block";
	
	initImage();
		
	firsttime = 1; }}
	}
	
	
}
}

document.write("<div id=\"pre_loader\" name=\"pre_loader\" style=\"display: none; position: absolute; z-index:499;\"></div>"); 
document.write("<div id=\"preview_div\" name=\"preview_div\" style=\"display: none; position: absolute; z-index:500;\"></div>");


//Chrome Drop Down Menu v2.01- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated: November 14th 06- added iframe shim technique

var cssdropdown={
disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseout
disablemenuclick: true, //when user clicks on a menu item with a drop down menu, disable menu item's link?
enableswipe: 1, //enable swipe effect? 1 for yes, 0 for no
enableiframeshim: 1, //enable "iframe shim" technique to get drop down menus to correctly appear on top of controls such as form objects in IE5.5/IE6? 1 for yes, 0 for no

//No need to edit beyond here////////////////////////
dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, swipetimer: undefined, bottomclip:0,

getposOffset:function(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
},

swipeeffect:function(){
if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight)){
this.bottomclip+=10+(this.bottomclip/10) //unclip drop down menu visibility gradually
this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"
}
else
return
this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 10)
},

showhide:function(obj, e){
if (this.ie || this.firefox)
this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
if (this.enableswipe==1){
if (typeof this.swipetimer!="undefined")
clearTimeout(this.swipetimer)
obj.clip="rect(0 auto 0 0)" //hide menu via clipping
this.bottomclip=0
this.swipeeffect()
}
obj.visibility="visible"
}
else if (e.type=="click")
obj.visibility="hidden"
},

iecompattest:function(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
},

clearbrowseredge:function(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset
var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ //move up?
edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
},

dropit:function(obj, e, dropmenuID){
if (this.dropmenuobj!=null) //hide previous menu
this.dropmenuobj.style.visibility="hidden" //hide menu
this.clearhidemenu()
if (this.ie||this.firefox){
obj.onmouseout=function(){cssdropdown.delayhidemenu()}
obj.onclick=function(){return !cssdropdown.disablemenuclick} //disable main menu item link onclick?
this.dropmenuobj=document.getElementById(dropmenuID)
this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}
this.dropmenuobj.onmouseout=function(e){cssdropdown.dynamichide(e)}
this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}
this.showhide(this.dropmenuobj.style, e)
this.dropmenuobj.x=this.getposOffset(obj, "left")
this.dropmenuobj.y=this.getposOffset(obj, "top")
this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
this.positionshim() //call iframe shim function
}
},

positionshim:function(){ //display iframe shim function
if (this.enableiframeshim && typeof this.shimobject!="undefined"){
if (this.dropmenuobj.style.visibility=="visible"){
this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px"
this.shimobject.style.left=this.dropmenuobj.style.left
this.shimobject.style.top=this.dropmenuobj.style.top
}
this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")? "block" : "none"
}
},

hideshim:function(){
if (this.enableiframeshim && typeof this.shimobject!="undefined")
this.shimobject.style.display='none'
},

contains_firefox:function(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
},

dynamichide:function(e){
var evtobj=window.event? window.event : e
if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
this.delayhidemenu()
else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
this.delayhidemenu()
},

delayhidemenu:function(){
this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden'; cssdropdown.hideshim()",this.disappeardelay) //hide menu
},

clearhidemenu:function(){
if (this.delayhide!="undefined")
clearTimeout(this.delayhide)
},

startchrome:function(){
for (var ids=0; ids<arguments.length; ids++){
var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
for (var i=0; i<menuitems.length; i++){
if (menuitems[i].getAttribute("rel")){
var relvalue=menuitems[i].getAttribute("rel")
menuitems[i].onmouseover=function(e){
var event=typeof e!="undefined"? e : window.event
cssdropdown.dropit(this,event,this.getAttribute("rel"))
}
}
}
}
if (window.createPopup && !window.XmlHttpRequest){ //if IE5.5 to IE6, create iframe for iframe shim technique
document.write('<IFRAME id="iframeshim"  src="" style="display: none; left: 0; top: 0; z-index: 90; position: absolute; filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')
this.shimobject=document.getElementById("iframeshim") //reference iframe object
}
}

}
