/*=======================================================================*/
// [[[ Baner rotating 

	function banerObj($id, $imgArray, $varName, $timeOut){
		this.id 		= $id;
		this.counter 	= 0;
		this.imgs 		= $imgArray;
		this.name 		= $varName;
		this.timeout	= $timeOut;
	}
	
	function cycleBan($obj) {
	  $obj.counter++;
	  if ($obj.counter == $obj.imgs.length) {
	    $obj.counter = 0;
	  }
	
	  document.getElementById($obj.id).src = $obj.imgs[$obj.counter];
	  setTimeout("cycleBan("+$obj.name+")", $obj.timeout*1000);
	}

// ]]] Baner rotating 
/*=======================================================================*/
// [[[ Links opening in other window

	function externallinks(){
	    var c=document;
	    if(c){
	        var ls=c.getElementsByTagName('a');
	        for(var i=0; i<ls.length; i++){
	        	
	        	//status on mouseover      	
	        	//ls[i].onmouseover = function(){statwords('link');return true;};
	        	//ls[i].onmouseout  = function(){statwords('');return true;};
				if(ls[i].getAttribute('target')) {
					if (ls[i].getAttribute('target') == '_blank') {
						ls[i].setAttribute('rel','external');
					}
					ls[i].removeAttribute('target');
				}
	            if(ls[i].getAttribute('rel')=='external'){
	                ls[i].className+=ls[i].className?' extlink':'extlink';
	                ls[i].title+='(opens in new window)';
	                ls[i].onclick=function(){window.open(this.href);return false}
	            }
	        }
	    }
	}

	function statwords(message){
		window.status = message;
		return true;
	}

// ]]] Links opening in other window
/*=======================================================================*/
// [[[ remove attributes from tags for XHTML

	function removeAttribs(){
		
	}
	
// ]]] remove attributes from tags for XHTML
/*=======================================================================*/
// [[[ Background image manipulation

//	function initBg(){
//		
//		if (document.getElementById("ieslegtText")){
//			$cookie = readCookie('bgImage');
//			if ($cookie == 'none') {
//				changeBg('white');
//			} else {
//				document.getElementById("ieslegtText").innerHTML = "Izslēgt fonu";
//			}
//		}
//	}
//	
//	function changeBg($bg){
//		
//		if (!$bg) $bg = document.body.style.backgroundImage;
//		if ($bg == '' || $bg != 'none') {
//			createCookie('bgImage','none', 5);
//			document.body.style.background = "white none repeat scroll 0% 0%";
//			document.getElementById("ieslegtText").innerHTML = "<?php echo WBG::message("izslegt_fonu",null,1);?>Ieslēgt fonu";
//		} else {
//			createCookie('bgImage','image', 5);
//			document.body.style.background = "url(images/building/mainBg.jpg) repeat scroll 0% 0%";
//			document.getElementById("ieslegtText").innerHTML = "Izslēgt fonu";
//		}
//	}

// ]]] Background image manipulation
/*=======================================================================*/
// [[[ Cookies manipulation

	function createCookie(name, value, $hours) {
		if ($hours) {
			var date = new Date();
			date.setTime(date.getTime()+($hours*60*1000));//*60 u nas was minuti vmesto hours
			var expires = "; expires="+date.toGMTString();
		}else {
			var expires = "";
		}
		document.cookie = name+"="+value+expires+"; path=/";
	}
	
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
	function eraseCookie(name) {
		createCookie(name,"",-1);
	}

// ]]] Cookies manipulation
/*=======================================================================*/
// [[[ Image overmouse changing

	var $prevImg;
	var $totalImgs;
	var $current;
	$current = 0;
	
	function changeImage($obj, $newSrc){
		$obj.src = 'images/'+$newSrc;
	}
	
	function showImg($index){
		
		document.getElementById("image_"+$prevImg).style.display = "none";
		document.getElementById("gal_img_link_"+$prevImg).className = "";
		$imgToshow = document.getElementById("image_"+$index);
		document.getElementById("gal_img_link_"+$index).className="act";
		$imgToshow.style.display = "";
		$prevImg = $index;
		$current = $index;
	}
	
	function nextImg(){
		if ($current < $totalImgs) {
			$current++;
			showImg($current);
		} else {
			$current = 0;
			showImg($current)
		}
	}
	
	function prevImg(){
		if ($current > 0) {
			$current--;
			showImg($current);
		}
	}
	
// ]]] Image overmouse changing
/*=======================================================================*/
// [[[ Content part size initialization

	function innitContentPart(){
		
		if (document.getElementById("mycustomscroll")) {
			$screenHeight = document.body.parentNode.clientHeight;
			$currentHeight= document.getElementById("mycustomscroll").clientHeight;
			$height = document.body.clientHeight;//document.body.clientHeight;
			$scrollHeight = $screenHeight-$height+$currentHeight-25;
			document.getElementById("mycustomscroll").style.height = $scrollHeight+"px";
		}
	}
	
// ]]] Content part size initialization
/*=======================================================================*/
