﻿var blnSliderMoving = false;
function runit() {
	alert("runit 2") // PH: 07-12-2008 18:18:02
	//intDivCount = 0; // PH: 07-12-2008 18:18:02
			for(i=1;i<intDivCount + 1;i++) {
				if(typeof(g('news' + i))!="undefined") {
					g('news' + i).setAttribute("orgHeight", g('news' + i).offsetHeight);
					g('news' + i).style.visibility = "visible";
					g('news' + i).style.height = "0px";
					g('news' + i).style.overflow = "hidden";
				}
			}
	}
	
	function toggleDivSlide(strId, blnIgnoreSliderMoving) {
		if(blnSliderMoving&&!blnIgnoreSliderMoving) { return; }
		tmpTo = (p(g(strId).style.height) == 0 ? g(strId).getAttribute("orgHeight") : 0);
		height_scroller(strId, (tmpTo == 0 ? g(strId).getAttribute("orgHeight") : 0), tmpTo, (parseInt(g(strId).getAttribute("orgHeight")) / 12), 6);
	}
	
	function expandCornerBox(strBoxId, intEndWidth) {
		if(blnSliderMoving) { 
			return; 
		}
		var table = (ns6 ? g(strBoxId).childNodes[0] : g(strBoxId).childNodes[0]);
		var intStart = 0;
		var intEnd = intEndWidth;
		if(table.rows[0].cells[1].getAttribute("orgwidth") == table.rows[0].cells[1].offsetWidth) {
			intStart = table.rows[0].cells[1].getAttribute("orgwidth");
		} else {
			intStart = table.rows[0].cells[1].offsetWidth;
			intEnd = table.rows[0].cells[1].getAttribute("orgwidth");
		}
		
		blnSliderMoving = true;
		expandCB(strBoxId, intStart, intEnd, intSlideMaxSpeed, intSlideSoftness);
	}
	
	function collapseCornerBox(strBoxId) {
		if(blnSliderMoving) { 
			return; 
		}
		var table = (ns6 ? g(strBoxId).childNodes[0] : g(strBoxId).childNodes[0]);
		var intStart = g(strBoxId).offsetWidth;
		var intEnd = 0;
		if(table.rows[0].cells[1].getAttribute("orgwidth") == table.rows[0].cells[1].offsetWidth) {
			intEnd = table.rows[0].cells[1].getAttribute("orgwidth");
		} else {
			intEnd = table.rows[0].cells[1].getAttribute("orgwidth");
			intStart = table.rows[0].cells[1].offsetWidth;
		}
		
		intEnd = parseInt(intEnd) + 15;
		blnSliderMoving = true;
		expandCB(strBoxId, intStart, intEnd, intSlideMaxSpeed, intSlideSoftness);
	}
function height_scroller(theelement, startheight, endheight, maxspeed, softness) {
  	var el=document.getElementById(theelement);
  	if (el.offsetHeight != endheight) {
    	var distanceend=Math.abs((endheight - el.offsetHeight) / softness);
    	var distancestart=Math.abs((startheight - el.offsetHeight) / softness);                    
    	var distance=Math.min(distancestart, distanceend);
    	var multiplier;
    	if (distance<1) {
    		multiplier=Math.abs(distance-1)+1;
    	}
    	else { 
    		multiplier=1; 
    	}
    	
    	distance = Math.ceil(distance);
    	
    	if (distance==0) {
    		distance=1; 
    	}
    	if (distance>maxspeed) {
    			distance=maxspeed;
    		}
    	if (startheight > endheight) {
    		distance=-distance;
    	}
    	var tempscrolltop = el.offsetHeight;
    	
    	if (startheight > endheight) {
    		el.style.height = p(el.style.height) + distance + "px";
    	}
    	else {
    		el.style.height = tempscrolltop + distance + "px";
    	}
	    
	    if ((startheight>endheight ? p(el.style.height) > 0 : p(el.style.height) + distance < endheight)) {
	      t=setTimeout('height_scroller(\''+theelement+'\','+startheight+','+endheight+','+maxspeed+','+softness+')',Math.round(20 * multiplier));
	      blnSliderMoving = true;
	    }
	    else {
	    	el.style.height = endheight + "px";
	    	t=null;
	    	resizeMain();
	    }
  	} 
  	else {
  		t=null;
  	}
	}
	
	function expandCB(theelement, startheight, endheight, maxspeed, softness) {
		var parentObj = document.getElementById(theelement);
  	var el = parentObj;
  	
  	if(el.offsetWidth!= endheight) {
    	var distancestart=Math.abs((endheight - el.offsetWidth) / softness);
    	var distanceend=Math.abs((startheight - el.offsetWidth) / softness);  
    	var distance=Math.min(distancestart, distanceend);
    	var multiplier;
    	if (distance<1) {
    		multiplier=Math.abs(distance-1)+1;
    	}
    	else { 
    		multiplier=1; 
    	}
    	
    	distance = Math.ceil(distance);
    	
    	if (distance==0) {
    		distance=1; 
    	}
    	if (distance>maxspeed) {
    		distance=maxspeed;
    	}
    	if (startheight > endheight) {
				distance=-distance;
    	}
    	var tempscrolltop = p(el.style.width);
    	var xpos;
    	if (startheight > endheight) {
    		xpos = rxposObj(el) - distance;
    	} else {
    		xpos = rxposObj(el) - distance;
    	}
    	
    	el.style.left = xpos + "px";
    	
    	if (startheight > endheight) {
    		el.style.width = p(el.style.width) + distance + "px";
    		//g("qwer").value += el.style.width + "_" + startheight + "x" + endheight + "\n";
    		el.childNodes[0].rows[1].cells[1].style.paddingLeft = parseInt(el.childNodes[0].rows[1].cells[1].style.paddingLeft) + distance + "px";
    	}
    	else {
    		el.style.width = tempscrolltop + distance + "px";
    		el.childNodes[0].rows[1].cells[1].style.paddingLeft = parseInt(el.childNodes[0].rows[1].cells[1].style.paddingLeft) + distance + "px";
    	}
    	
	    if ((startheight>endheight ? p(el.offsetWidth) > 0 : p(el.offsetWidth) + distance < endheight)) {
	      t=setTimeout('expandCB(\''+theelement+'\','+startheight+','+endheight+','+maxspeed+','+softness+')',Math.round(20 * multiplier));
	    }
	    else {
	    	el.style.width = endheight + "px";
	    	t=null;
	    	blnSliderMoving = false;
	    	exeFuncAndEvalArray();
	    }
  	} 
  	else {
  		t=null;
  		blnSliderMoving = false;
  		exeFuncAndEvalArray();
  	}
	}
	
	function expandCBVertical(theelement, startheight, endheight, maxspeed, softness) {
		var parentObj = document.getElementById(theelement);
  	var el = parentObj;
  	
  	if(el.offsetHeight!= endheight) {
    	var distancestart=Math.abs((endheight - el.offsetHeight) / softness);
    	var distanceend=Math.abs((startheight - el.offsetHeight) / softness);  
    	var distance=Math.min(distancestart, distanceend);
    	var multiplier;
    	if (distance<1) {
    		multiplier=Math.abs(distance-1)+1;
    	}
    	else { 
    		multiplier=1; 
    	}
    	
    	distance = Math.ceil(distance);
    	
    	if (distance==0) {
    		distance=1; 
    	}
    	if (distance>maxspeed) {
    		distance=maxspeed;
    	}
    	if (startheight > endheight) {
				distance=-distance;
    	}
    	var tempscrolltop = p(el.style.height);
    	
    	if (startheight > endheight) {
				var intMove = tempscrolltop + distance;
				if(intMove < 0) {
					intMove = 0;
				}
    		el.style.height = intMove + "px";
    		el.childNodes[0].rows[1].style.height = (tempscrolltop - 14 < 0 ? 0 : tempscrolltop - 14) + "px"; //parseInt(el.childNodes[0].rows[1].style.height) + distance + "px";
    	}
    	else {
    		el.style.height = tempscrolltop + distance + "px";
    		el.childNodes[0].rows[1].style.height = (el.offsetHeight - 14 < 0 ? 0 : el.offsetHeight - 14) + "px"; //parseInt(el.childNodes[0].rows[1].style.height) + distance + "px";
    	}
    	
	    if ((startheight>endheight ? p(el.style.height) > 0 : p(el.style.height) + distance < endheight)) {
	      t=setTimeout('expandCBVertical(\''+theelement+'\','+startheight+','+endheight+','+maxspeed+','+softness+')',Math.round(20 * multiplier));
	    }
	    else {
	    	el.style.height = endheight + "px";
	    	t=null;
	    	blnSliderMoving = false;
	    	exeFuncAndEvalArray();
	    }
  	} 
  	else {
  		t=null;
  		blnSliderMoving = false;
  		exeFuncAndEvalArray();
  	}
	}
	
	function exeFuncAndEvalArray_shit(arr) {
		var arrF = eval(arr.replace(/!/g, "\'"));
		alert("initial array: " + arrF);
		if(arrF.length==0) {
			return;
		}
		
	  var funcToRun;
	  if(arrF.length > 0) {
	  	funcToRun = arrF[arrF.length - 1]
	  } else {
	  	funcToRun = arrF[0];
	  }
	  
	  arrF.pop();
	  var arrT = new Array();
	  var outputArray = "\"Array(" + arrF.toString() + ")";
	  var arrFrep = "Array(";
	  //alert(arrFrep);
	  //arrFrep = arrFrep.replace(/()/g, "(" + arrFrep
	  for(var i = 0, len = arrF.length; i < len; i++) {
	  	arrT[i] = arrF[i].toString().replace(/'/g, "!");
	  }
	  
	  for(var i = 0, len = arrT.length; i < len; i++) {
	  	if(arrT[i].indexOf("()") < 0) {
	  		arrT[i] = arrT[i].replace(")", ",#repWithArrayRightHere#)");
	  	} else {
	  		arrT[i] = arrT[i].replace("()", "(#repWithArrayRightHere#)");
	  	}
	  }
	  
	  for(var i = 0, len = arrF.length; i < len; i++) {
	  	arrFrep += "\"" + arrT[i].toString() + "\"";
	  	if(i < (len - 1)) {
	  		 arrFrep += ","
	  	}
	  }
	  
	  outputArray = outputArray.replace(/'/g, "!") + "\"";
	  arrFrep += ")";
	  arrFrep = arrFrep.replace(/#repWithArrayRightHere#/g, outputArray);
		
		outputArray = "\"Array("
		for(var i = 0, len = arrT.length; i < len; i++) {
	  	outputArray += "\\\"" + arrT[i] + "\\\"";
	  }
		outputArray += ")\"";
		
	  if(funcToRun.indexOf("()") < 0) {
	  		funcToRun = funcToRun.replace(")", ("," + outputArray));
	  	} else {
	  		funcToRun = funcToRun.replace("()", ("(" + outputArray + ")"));
	  	}
	  
	  alert("funcToRun: " + funcToRun);
	  eval(funcToRun);
	}
	
	function xy_scroller(theelement, startheight, endheight, maxspeed, softness) {
		blnSliderMoving = false;
  	var el=document.getElementById(theelement);
  	if (p(el.style.left) != endheight) {
    	var distanceend=Math.abs((endheight - p(el.style.left)) / softness);
    	var distancestart=Math.abs((startheight - p(el.style.left)) / softness);                    
    	var distance=Math.min(distancestart, distanceend);
    	var multiplier;
    	
    	if(distance<1) {
    		multiplier=Math.abs(distance-1)+1;
    	} else { 
    		multiplier=1; 
    	}
    	
    	distance = Math.ceil(distance);
    	
    	if(distance==0) {
    		distance=1; 
    	}
    	if(distance>maxspeed) {
    			distance=maxspeed;
    		}
    	if(startheight > endheight) {
    		distance=-distance;
    	}
    	
    	var tempscrolltop = p(el.style.left);
    	
    	if(startheight > endheight) {
    		el.style.left = p(el.style.left) + distance + "px";
    	} else {
    		el.style.left = tempscrolltop + distance + "px";
    	}
	    
	    if((startheight < endheight ? p(el.style.left) < 0 : (p(el.style.left) + distance) > endheight)) {
	      t = setTimeout('xy_scroller(\''+theelement+'\','+startheight+','+endheight+','+maxspeed+','+softness+')',Math.round(20 * multiplier));
	      blnSliderMoving = true;
	    }
	    else {
	    	el.style.left = endheight + "px";
	    	t=null;
	    }
  	} 
  	else {
  		t=null;
  	}
	}
