
//<!--
var dyn = (document.all || document.layers || document.getElementById) ? true : false;

var ie = (navigator.appName.indexOf('Microsoft') != -1) ? true : false;
var ie4 = (ie && document.all && !document.getElementById) ? true : false;
var ie5 = (ie && document.getElementById && navigator.appVersion.indexOf('MSIE 6.0') == -1) ? true : false;
var ie6 = (ie && document.getElementById && navigator.appVersion.indexOf('MSIE 6.0') != -1) ? true : false;
var ie4Min = (ie && (document.all || document.getElementById)) ? true : false;
var ie5Min = (ie && document.getElementById) ? true : false;
var ie6Min = (ie && document.getElementById) ? true : false;

var ns = (navigator.appName.indexOf('Netscape') != -1) ? true : false;
var ns4 = (ns && document.layers) ? true : false;
var ns6 = (ns && document.getElementById) ? true : false;
var ns4Min = (ns && (document.layers || document.getElementById)) ? true : false;
var ns6Min = (ns && document.getElementById) ? true : false;
//-->

function getById(obj) { return document.getElementById(obj); }

function loadImage(imID,imUrl,setCookie,scrollUp) {
	var imObj = MM_findObj(imID);
	imObj.src=imUrl;

	if (setCookie&&pageID) SetCookie('prevIm'+pageID,imUrl);
	if (scrollUp>0) {
		if (document.body.scrollTop>scrollUp) 
			document.body.scrollTop = scrollUp;
	}
}



function popupWin(name, URL, width, height, resizable, scrollbars, status, top, left)
{
	if (!top) top=200;
	if (!left) left=200;
	newWin =  open(URL,name,"scrollbars="+scrollbars+", status="+status+", width="+width+", height="+height+", menubar=0, toolbar=0, resizable="+resizable+", top="+top+", left="+left);
}


function MM_findObj(n, d) {
  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 && document.getElementById) x=document.getElementById(n); return x;
}


function getStyleObject(objectId) {
    if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
		return getObjNN4(document,objectId);
    } else {
	return false;
    }
} 


function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}


// preload functions


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImagesArray(array) {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<array.length; i+=2) {
			document[array[i]].src = array[i+1];
		}
	}
}

function changeImages() {
	changeImagesArray(changeImages.arguments);
}

function toggleImages() {
	for (var i=0; i<toggleImages.arguments.length; i+=2) {
		if (selected == toggleImages.arguments[i])      changeImagesArray(toggleImages.arguments[i+1]);
	}
}

var selected = '';
var clicked = false;
var preloadFlag = false;



function getElementLeft(Elem) {
	var elem;
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all){
		var elem = document.all[Elem];
	}
	xPos = elem.offsetLeft;
	tempEl = elem.offsetParent;
  	while (tempEl != null) {
  		xPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
  	}
	return xPos;
}

function getElementTop(Elem) {
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all) {
		var elem = document.all[Elem];
	}

	yPos = elem.offsetTop;
	tempEl = elem.offsetParent;
	while (tempEl != null) {
  		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
  	}
	return yPos;
}



function getWinHeight() {
   if (ie4Min) return document.body.clientHeight;
   else if (ns4Min) return window.innerHeight;
}

function getWinWidth() {
   if (ie4Min) return document.body.clientWidth;
   else if (ns4Min) return window.innerWidth;
}


function getDocScrollLeft() {
   if (ie4Min) return document.body.scrollLeft;
   else if (ns4Min) return window.pageXOffset;
   }

function getDocScrollTop() {
   if (ie4Min) return document.body.scrollTop;
   else if (ns4Min) return window.pageYOffset;
   }


// paarkonvertee unicode entities (&#456;) uz HEX entities, ko maak paraadiit Javacscript

function convertDec(text) {

	return text.replace(/&#(\d+);/g,function($1, $2) {return String.fromCharCode($2);});

}

function resize_content()
{
	if(self.innerHeight)
		y=self.innerHeight;
	else if(document.documentElement && document.documentElement.clientHeight)
		y=document.documentElement.clientHeight;
	else if(document.body)
		y=document.body.clientHeight;
	var height=parseInt(y)-182;
	document.getElementById("contenttable").style.height=height+"px";
}

function countDownTime(){
	var thisdate=new Date();

	if(window.countdowntimer) 
		clearTimeout(countdowntimer);
	if(countDownTimeSec != thisdate.getSeconds()){
		countDownTimeSec=thisdate.getSeconds();
		if(seconds==0){
			seconds=59;
			if(minutes==0){
				minutes=59;
				if(hours==0){
					hours=23;
					if(days==0){
						days=0;
					}else{
						days--;
					}
				}else{
					hours--;
				}
			}else{
				minutes--;
			}
		}else{
			seconds--;
		}
		//document.getElementById("daysCounter").innerHTML=days;
		document.getElementById("hourCounter").innerHTML=hours;
		document.getElementById("minutesCounter").innerHTML=minutes;
		document.getElementById("secondsCounter").innerHTML=seconds;
		if(hours<10)
			document.getElementById("hourCounter").innerHTML="0"+hours;
		if(minutes<10)
			document.getElementById("minutesCounter").innerHTML="0"+minutes;
		if(seconds<10)
			document.getElementById("secondsCounter").innerHTML="0"+seconds;
	}
	
	countdowntimer=setTimeout("countDownTime()",1000);
}



function countUpTime(){
	var thisdate=new Date();

	if(window.countuptimer) 
		clearTimeout(countuptimer);
	if(countUpTimeSec != thisdate.getSeconds()){
		countUpTimeSec=thisdate.getSeconds();
		if(seconds==59){
			seconds=0;
			if(minutes==59){
				minutes=0;
				if(hours==23){
					hours=0;
					if(days==0){
						days=0;
					}else{
						days++;
					}
				}else{
					hours++;
				}
			}else{
				minutes++;
			}
		}else{
			seconds++;
		}
		//document.getElementById("daysCounter").innerHTML=days;
		document.getElementById("hourCounter").innerHTML=hours;
		document.getElementById("minutesCounter").innerHTML=minutes;
		document.getElementById("secondsCounter").innerHTML=seconds;
		if(hours<10)
			document.getElementById("hourCounter").innerHTML="0"+hours;
		if(minutes<10)
			document.getElementById("minutesCounter").innerHTML="0"+minutes;
		if(seconds<10)
			document.getElementById("secondsCounter").innerHTML="0"+seconds;
	}
	
	countuptimer=setTimeout("countUpTime()",1000);
}
