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: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			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.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function changeClass(id,className){
	if(document.getElementById(id))document.getElementById(id).className=className;
}
function getScrollerWidth() {

          var scr = null;

          var inn = null;

          var wNoScroll = 0;

          var wScroll = 0;

          // Outer scrolling div

          scr = document.createElement('div');

          scr.style.position = 'absolute';

          scr.style.top = '-1000px';

          scr.style.left = '-1000px';
 
          scr.style.width = '100px';

          scr.style.height = '50px';

          // Start with no scrollbar

          scr.style.overflow = 'hidden';

          // Inner content div

          inn = document.createElement('div');

          inn.style.width = '100%';

          inn.style.height = '200px';

          // Put the inner div in the scrolling div

          scr.appendChild(inn);

          // Append the scrolling div to the doc

          document.body.appendChild(scr);

          // Width of the inner div sans scrollbar

          wNoScroll = inn.offsetWidth;

          // Add the scrollbar

          scr.style.overflow = 'auto';

          // Width of the inner div width scrollbar

          wScroll = inn.offsetWidth;

          // Remove the scrolling div from the doc

          document.body.removeChild(

     document.body.lastChild);

          // Pixel width of the scroller
     return (wNoScroll - wScroll);
}
function changeImgSrc(id,src){
	if(document.getElementById(id))document.getElementById(id).src=src;
}


var scroll=0;
function fscroll(ta_id,idscroller,sc){
	var hg=0;
	if(document.getElementById(idscroller).scrollHeight){
		hg=document.getElementById(idscroller).scrollHeight-document.getElementById(ta_id).offsetHeight;
	}else{
		hg=document.getElementById(ta_id).scrollHeight;
	}
	//window.alert(document.getElementById(ta_id).scrollHeight+" - "+scroll+" - "+document.getElementById(ta_id).scrollTop);
	//document.getElementById(ta_id).scrollTop=document.getElementById(ta_id).scrollHeight;
	if((scroll<=hg) && (scroll>=0)){
		scroll+=sc;
		document.getElementById(ta_id).scrollTop=scroll;
	}
	if(scroll>hg){scroll=hg;}
	if(scroll<0){scroll=0;}
	//alert(ta_id+'----'+sc);
	
	
}

function alertSize() {
		  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;
		  }
		  //window.alert( 'Width = ' + myWidth );
		  //window.alert( 'Height = ' + myHeight );
		  //alert(document.getElementById('tdmiddle').offsetWidth+'-jjjj---'+document.getElementById('idtd').offsetWidth);
		  
		  return myWidth-getScrollerWidth();
}
function stopAnimate(brot,alle){
	if(document.getElementById(brot))$("#"+brot).animate({height: "0px",opacity: 0}, 500 , function(){displayobj(brot,'none');});
	displayobj(alle,'block');
		//document.getElementById(brot).style.border='3px solid blue';
}


function animateheight(id,idt,idb,idLine){
	if(document.getElementById(broth)){
		stopAnimate(broth,allege);
		
	}
	if(broth==id){
		broth=null;
		allege=null;
		return;
	}
	
	if(document.getElementById(id)){
		if(BrowserDetect.browser=="Explorer"&&BrowserDetect.version=="6"){
			if(document.getElementById(idb))document.getElementById(idb).style.height='0px';
			document.getElementById(id).style.filter="alpha(opacity="+(0.1*100)+")";
		}else{
			 document.getElementById(id).style.MozOpacity=0.1;
		}
		
		document.getElementById(id).style.display='block';
		var oh=document.getElementById(idt).offsetHeight;
		
		//alert(oh);
		
		oh=oh+65;
		if(oh<190){
			oh=190;
			document.getElementById(idt).style.height='125px';
		}
		//window.scrollTo(0,0);
		/*
		if(document.getElementById('kk')){
			document.getElementById('kk').scrollTop=0;
			}
		*/
		
		document.documentElement.scrollTop=0;
		displayobj(idLine,'none');
		if(document.getElementById(idb))document.getElementById(idb).style.height=(oh-90)+'px';
		$("#"+id).animate({height: oh+"px",opacity: 1}, 500);
		broth=id;
		allege=idLine;
		//document.getElementById(id).style.border='3px solid red';
		
	}
	//alert(document.getElementById(id)+'--');
}
function changeClassGlob(classname){//alert(globalBall);
	if(document.getElementById(globalBall))document.getElementById(globalBall).className=classname;

}
function onLoadpage(){
	//logo
	changeClassGlob('fl whelp8');
	displayobj('idlogo','block');
	displayobj('idallege22','block');
	displayobj('idelucidate58','block');
	displayobj('idelucidate57','block');
	displayobj('idelucidateP','block');
	displayobj('idelucidateL','block');
	displayobj('idelucidateH','block');
	displayobj('idelucidateO','block');
	
	
	setheightObj('idhope2','idlogo',0,107);
	setheightObj('idhope2','idallege22',105,90);
	setheightObj('idhope2','idinterpret1',-590,60);
	
	setheightObj('idhope2','idelucidate58',-531,230);
	setheightObj('idhope2','idelucidate57',-531,290);
	setheightObj('idhope2','idelucidateP',-80,450);
	setheightObj('idhope2','idelucidateL',-80,510);
	
	setheightObj('idhope2','idelucidateH',-80,660);
	setheightObj('idhope2','idelucidateO',-80,810);
	
}
function displayobj(id,visibility){
	if(document.getElementById(id))document.getElementById(id).style.display =visibility;
}
function setheightObj(id,idShow,left,hgt){
	var hgt1=0,left1=0,wdt=0,wd=0,ws=0;
	if(document.getElementById(id)){
	//	hgt1=document.getElementById(id).offsetTop;
		wd=alertSize();
		//left1=document.getElementById(id).offsetLeft;
		wdt=document.getElementById(id).offsetWidth;
		//alert(wd+'---+++'+wdt)
	}
	
	if(document.getElementById(idShow)){
		ws=document.getElementById(idShow).offsetWidth;
		document.getElementById(idShow).style.top=hgt+'px';
		document.getElementById(idShow).style.left=wd-((wd-wdt)/2)-ws+left+'px';
	}
	
	//alert(document.getElementById(idShow).style.left+'----'+hgt1+'--');
}


function changeClassesAll(id1,cl1,id2,cl2,id3,cl3,id4,cl4){
	changeClass(id1,cl1);
	changeClass(id2,cl2);
	changeClass(id3,cl3);
	changeClass(id4,cl4);
}


function changeClass(id,classname){
	if(document.getElementById(id))document.getElementById(id).className=classname;
}
