function do_change(){
//	windows.location = this.href;	
	return true;
	
}

function watch_width(){
	dims = doSize();
	var width = dims.x;
	var classn = 'var1';
	if(width>1300){
		classn = 'var2';
	}
	if(width>1500){	
		classn = 'var3';	
	}
	
	var dbcl = document.body.className;
	if(dbcl !== classn){	
		document.body.className = classn;
		var URL = STI+'/registerclass/'+classn;
		xmlhttp=new XMLHttpRequest();
		xmlhttp.open("GET",URL,true);
		xmlhttp.send();			
		
	}
	
}	

function doSize() {
  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;
  }
 return {x:myWidth,y:myHeight};
}

sli_interv = false;
sli_blocat = false;
function do_slide(nr,isback,cuinterv){
	var imgbig = $O('imgbig');
	if(sli_blocat) return;
	sli_blocat = true;
	if(!window['slides_num']){
		for(i=1;i<10;i++){
			if(!$O('poza_'+i)){
				slides_num = i-1;
				break;
			}
		}
	}
	//curent
	if(!imgbig  ||  (slides_num <1) || (nr &&  ( (nr < 1) ||  (nr > slides_num) ) )){
		sli_blocat = false;
		return;
	}
	
	if(!cuinterv && sli_interv){
		 window.clearInterval(sli_interv);	
		 sli_interv = false;
	}
	

	nr_dorit = nr ? nr : (isback ? (slide_on-1) : (slide_on+1));
	if(nr_dorit > slides_num){
		nr_dorit =1;
	}
	if(nr_dorit < 1){
		nr_dorit = slides_num;
	}	

	if(!slides[nr_dorit] || (nr_dorit == slide_on)){
		sli_blocat = false;		
		return;
	}

	for(i=1;i<=slides_num;i++){
		if($O('poza_'+i)){
			if(i == nr_dorit){
				$O('poza_'+i).className += ' sel';
			}
			else{
				$O('poza_'+i).className = $O('poza_'+i).className.replace(' sel','');		
			}
		}
	}
	slide_on = nr_dorit;
	if($O('slide_counter')){
		$O('slide_counter').innerHTML = nr_dorit;
	}
	
	
	//alert('e'+nr_dorit);
	var sli = slides[nr_dorit];
	var iam = new Image();
	iam.onload = function(){
		opacity('imgbig', 100, 0, 500);
		setTimeout("$O('imgbig').src = '"+this.src+"'; $O('imgbig').alt = '"+this.alt+"';opacity('imgbig', 0, 100, 1000);",500);				
		setTimeout("sli_blocat = false;",1600);						
	}
	iam.src = sli[0];
	iam.alt = sli[1];	
	
	

	if($O('slidetit')){
		$O('slidetit').innerHTML = '';
		var sli_a_txt = document.createTextNode(sli[1]); 
		if(sli[2].length > 3){
			var sli_a = document.createElement('a');		
			sli_a.setAttribute("target",sli[3]);	
			sli_a.setAttribute("href",sli[2]);	
			sli_a.appendChild(sli_a_txt);		
			$O('slidetit').appendChild(sli_a);	
		}
		else{
			$O('slidetit').appendChild(sli_a_txt);	
		}
	}

}
function $$(id){
	if(m = document.getElementById(id))
		return m.style;
	return false;
}
function $O(id){
	if(m = document.getElementById(id))
		return m;
	return false;
}
function $$O(id){
	if(m = document.getElementById(id))
		return m.style;
	return false;
}

function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);object.KhtmlOpacity = (opacity / 100);
//    object.filter = "alpha(opacity=" + opacity + ")";
} 
function opacity(id, opacStart, opacEnd, millisec) {
	if(is_ie && 0){
		changeOpac(opacEnd, id);
		return;
	}	
    var speed = Math.round(millisec / 100);
    var timer = 0;
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}
