	var elemShow = 0;
	var selected_obj = null;
	var oldX = 0;
	var oldY = 0;

	function showNext(inc) {
		divElems = document.getElementById('content_home').getElementsByTagName('div');
		elemShow+=inc;
		if (elemShow>=divElems.length)
			elemShow = 0;
		if (elemShow<0)
			elemShow = divElems.length-1;
			
		for  (i=0;i<divElems.length;i++) {
			divElems[i].style.display='none';
			if (elemShow==i)
				divElems[i].style.display='block';
		}

	}

	function nav_mo(pObj){
		if (selected_obj==pObj)
			return true;

		if (pObj.getElementsByTagName('img').length>0 || pObj.tagName=='IMG') {

			if (pObj.tagName=='IMG')
				obj = pObj;
			else
				obj = pObj.getElementsByTagName('IMG')[0];

			if (obj.src.indexOf("_over.")>0) {

				obj.src = obj.src.replace(/_over/,"");
			}
			else {
				if (obj.src.indexOf(".php")>0)
					obj.src = obj.src.substr(0,obj.src.indexOf(".php"))+'_over'+obj.src.substr(obj.src.indexOf(".php"));
				else
					obj.src = obj.src.substr(0,obj.src.lastIndexOf("."))+'_over'+obj.src.substr(obj.src.lastIndexOf("."));
			}

		}

		return true;
	}

	function alterScroll() {
		isStatic = false;
		if (navigator.appVersion.indexOf('MSIE 6')>0)
			return;
		var scrollPos;

		tmp = document.getElementById('content_').getElementsByTagName('img');
		for (i=0;i<tmp.length;i++) {
			if (tmp[i].offsetWidth>tmp[i].parentNode.offsetWidth) {

				/*if (window.pageYOffset==oldY) {
					document.getElementById('navigation').style.position='absolute';
					isStatic = true;
				}
				else {*/


					if (typeof window.pageYOffset != 'undefined') {
					   scrollPos = window.pageXOffset;
					}
					else if (typeof document.compatMode != 'undefined' &&
						 document.compatMode != 'BackCompat') {
					   scrollPos = document.documentElement.scrollLeft;
					}
					else if (typeof document.body != 'undefined') {
					   scrollPos = document.body.scrollLeft;
					}


					document.getElementById('navigation').style.left=-parseInt(scrollPos)+'px';

				//}

			}
		}

		/*if (!isStatic) {
			document.getElementById('navigation').style.position='fixed';
		}*/
		oldY = window.pageYOffset;
	}
		
	function getClientHeight() {

		if (window.innerWidth) { 
			h = window.innerHeight; 
			w = window.innerWidth; 
		} 	
		else if(document.body) {
			h = document.body.clientHeight;
			w = document.body.clientWidth;
			if (document.body.offsetHeight == h && document.documentElement && document.documentElement.clientHeight)  {
				h = document.documentElement.clientHeight;
				w = document.documentElement.clientWidth;
			}
		}	
		else if(document.documentElement) {
				h = document.documentElement.clientHeight;
				w = document.documentElement.clientWidth;
		}			
		return Array(w,h);	
	}
	function loadXMLDoc(w,h) {
		var xmlhttp;
		if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}
		else {// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4 && xmlhttp.status==200)	{
				if (xmlhttp.responseText != h)
					resizeImages(w,h);
			}
		}
		xmlhttp.open("GET","ajax/sizes.php?w="+w+"&h="+h,true);
		xmlhttp.send();
		
		
	}	
	function getHeight() {
		hw = getClientHeight();
		//if (hw[1]<780)
			loadXMLDoc(hw[0],hw[1]);
	}
	function resizeImages(w,h) {
		imgArr = document.getElementsByTagName('img');
		hSet = false;
		for (i=0;i<imgArr.length;i++) {
			if (imgArr[i].getAttribute('onclick')!='') {

				height = imgArr[i].parentNode.getAttribute('style').match(/; ?(height:)(.*?)px/i)[2];
				width = imgArr[i].parentNode.getAttribute('style').match(/(width:)(.*?)px/i)[2];
				if (width>height) {
					height_new = Math.min(Math.max(h - 235,320),525);
					width_new = Math.round((height_new) / height * width);
					
					if (width_new>700) {
						height_new = Math.round(700/width_new*height_new)+15;
						width_new = 700;
					}	
					
					imgArr[i].parentNode.setAttribute('style',imgArr[i].parentNode.getAttribute('style').replace(/(; ?height:)(.*?)px/i,"$1"+(height_new)+'px'));
					imgArr[i].parentNode.setAttribute('style',imgArr[i].parentNode.getAttribute('style').replace(/(width:)(.*?)px/i,"$1"+width_new+'px'));
					if (!hSet) {
						newheight = Math.min(Math.max(690,height_new),h - 70);
						imgArr[i].parentNode.parentNode.parentNode.setAttribute('style',imgArr[i].parentNode.parentNode.parentNode.getAttribute('style').replace(/(;height:)(.*?)px/i,"$1"+newheight+'px'));
					}
				}
				else {
					height_new = Math.min(Math.max(h - 70,400),690);
					width_new = Math.round((height_new) / height * width);
					
					imgArr[i].parentNode.setAttribute('style',imgArr[i].parentNode.getAttribute('style').replace(/(; ?height:)(.*?)px/i,"$1"+height_new+'px'));
					imgArr[i].parentNode.setAttribute('style',imgArr[i].parentNode.getAttribute('style').replace(/(width:)(.*?)px/i,"$1"+width_new+'px'));
					if (!hSet) {
						newheight = Math.min(Math.max(690,height_new),h - 70);
						imgArr[i].parentNode.parentNode.parentNode.setAttribute('style',imgArr[i].parentNode.parentNode.parentNode.getAttribute('style').replace(/(; ?height:)(.*?)px/i,"$1"+newheight+'px'));
					}	
				}
				hSet = true;
			}
		}	
	}
	
	getHeight();
	
	
	
window.onload = function() {
	spans = document.getElementsByTagName('span');
	for (i=0;i<spans.length;i++) {
		if (spans[i].className=='mailAddress') {
			spans[i].innerHTML = spans[i].innerHTML.replace(/##/,'@').replace(/#/,'.');		
		}
	}
	if (tmpVideo = document.getElementById('prev_next_video')) {
		document.getElementById('nav_home_next').appendChild(tmpVideo);
		document.getElementById('prev_next_video').style.display='block';
	}
}		
