//Manual Scroller- © Dynamic Drive 2001
//For full source code, visit http://www.dynamicdrive.com

//specify speed of scroll (greater=faster)
var speed=5
var speedcounter=0
var access=0

//auto scroll variable
var autoScrollCounter = 0;
var maxCounter = 10;

var crossobj
var layerobj
var contentwidth
var layerobjwidth

iens6=document.all||document.getElementById
ns4=document.layers

function swapimage(id, image){
	document.getElementById(id).src = image
}

function getcontentobject(){
	if (iens6){
		crossobj=document.getElementById? document.getElementById("scrollContent") : document.all.content
		layerobj=document.getElementById? document.getElementById("nsContent") : document.all.content
	}
	else if (ns4){
		crossobj=document.nscontainer.document.nsContent
		layerobj=document.nscontainer.document.scrollContent
	}
}

function getcontentwidth(){
	if (iens6){
		contentwidth=crossobj.offsetWidth;
		layerobjwidth=layerobj.width;		
	}
	else if (ns4){
		contentwidth=crossobj.clip.width;
		layerobjwidth=layerobj.clip.width;
	}
}

function moveright(){
	getcontentobject();
	getcontentwidth();
	
	stopAutoScroll();
	if (window.moveleftvar) clearTimeout(moveleftvar)
	
	if (iens6&&parseInt(crossobj.style.left) >= (contentwidth*(-1)+ 158))
	{					
		crossobj.style.left = parseInt(crossobj.style.left)-speed + "px"
		speedcounter += speed;
		access=1;
	}
	else if (ns4&&crossobj.left >= (contentwidth*(-1)+158))
		crossobj.left -= speed;
	else
		access=0;		
	if ((speedcounter < layerobjwidth)&&(access==1)) {
		moverightvar=setTimeout("moveright()",25)
	}
	else {
		stopscroll();
	}
}

function moveleft(){
	getcontentobject();
	getcontentwidth();
	
	stopAutoScroll();
	if (window.moverightvar) clearTimeout(moverightvar)
	
	if (iens6&&parseInt(crossobj.style.left) < 0)
	{
		crossobj.style.left=parseInt(crossobj.style.left)+speed+"px"
		speedcounter += speed;
		access=1;
	}
	else if (ns4&&crossobj.left < 0)
		crossobj.left+=speed
	else
		access=0;
		
	if((speedcounter < layerobjwidth)&&(access==1)) {
		moveleftvar=setTimeout("moveleft()",25)
	}
	else {
		stopscroll();
	}
}

function stopscroll(){
	speedcounter=0;
	if (window.moveleftvar) clearTimeout(moveleftvar)
	if (window.moverightvar) clearTimeout(moverightvar)
}

function movemostleft(){
	stopscroll()
if (iens6)
	crossobj.style.left=0+"px"
else if (ns4)
	crossobj.left=0
}

function movemostright(){
	stopscroll()
if (iens6)
	crossobj.style.right=0+"px"
else if (ns4)
	crossobj.right=0
}

function autoScroll() {
	if (autoScrollCounter == 0)
	{		
		autoMainScroll = setTimeout("autoScroll()",16000);
		autoRightScroll = setTimeout("moveleft();",8000);
	}
	else
	{
		autoMainScroll = setTimeout("autoScroll()",8000);
		moveright();		
	}
	autoScrollCounter++;
	
	if (autoScrollCounter > maxCounter)
	{
		crossobj.style.left = '0px';
	}	
}

function stopAutoScroll()
{
	if (window.autoMainScroll) clearTimeout(autoMainScroll);
	autoMainScroll = setTimeout("autoScroll()",8000);
}


//function getcontent_height(){
//if (iens6)
//	contentheight=crossobj.offsetHeight
//Else if (ns4)
//	document.nscontainer.document.nscontent.visibility="show"
//}

//function initialize(){
//	getcontentobject();
//	getcontentheight();
//}


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 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_displayStatusMsg(msgStr) { //v1.0
	status=msgStr;
	document.MM_returnValue = true;
}

//Chrome Drop Down Menu- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated: June 14th, 06'

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

//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(){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.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+2+"px"
}
},

contains_firefox:function(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
},

rollover:function(relvalue){
var altvalue=document.getElementById("image"+relvalue).getAttribute("alt");
var srcvalue=document.getElementById("image"+relvalue).getAttribute("src");
var srcLastIndex = srcvalue.lastIndexOf('.');
var srcValueLeft = srcvalue.substring(0,srcLastIndex);
var srcValueRight = srcvalue.substr(srcLastIndex,srcvalue.length-srcLastIndex);
MM_swapImage('image'+relvalue,'',srcValueLeft+'_over'+srcValueRight,1);
MM_displayStatusMsg(altvalue);
//window.status=altvalue;
return document.MM_returnValue;
},

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'",this.disappeardelay) //hide menu
MM_swapImgRestore()
MM_displayStatusMsg('')
},

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"))
cssdropdown.rollover(this.getAttribute("rel"))
}
}
}
}
}

}

/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
	var dyniframe=new Array()
	for (i=0; i<iframeids.length; i++){
		if (document.getElementById)
			resizeIframe(iframeids[i])
		//reveal iframe for lower end browsers? (see var above):
		if ((document.all || document.getElementById) && iframehide=="no"){
			var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
			tempobj.style.display="block"
		}
	}
}

function resizeIframe(frameid){
	var currentfr=document.getElementById(frameid)
		if (currentfr && !window.opera){
			currentfr.style.display="block"
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
			currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
			currentfr.height = currentfr.Document.body.scrollHeight;
		if (currentfr.addEventListener)
			currentfr.addEventListener("load", readjustIframe, false)
		else if (currentfr.attachEvent){
			currentfr.detachEvent("onload", readjustIframe) // Bug fix line
			currentfr.attachEvent("onload", readjustIframe)
		}
	}
}

function readjustIframe(loadevt) {
	var crossevt=(window.event)? event : loadevt
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
	if (iframeroot)
	resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
	if (document.getElementById)
	document.getElementById(iframeid).src=url
}

if (window.addEventListener)
	window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
	window.attachEvent("onload", resizeCaller)
else
	window.onload=resizeCaller

function Print(divId)
{
	var win = window.open();
	//var win = window.open("",null,"height=100,width=100,status=yes,toolbar=no,menubar=yes,location=no");
	win.document.write("<html><head><LINK href='/Include/somf.css' type='text/css' rel='stylesheet'></head>")
	win.document.write("<body onload='self.print();'>");
	win.document.write(document.getElementById(divId).innerHTML);
	win.document.write("<hr size='1'>");
	win.document.write("</body></html>");				
	win.document.close();
}

function OpenWindow(url)
{
	window.open(url, null, 'width=550,height=550,menubar=yes,status=yes,location=no,toolbar=yes,scrollbars=yes');
}

function ResizeObject(object,newWidth,newHeight)
{	
	object.style.width=newWidth;
	object.style.height=newHeight;
}
