
function swapImage(imgName,newImg) { eval('document.' + imgName + '.src = "' + newImg + '"'); }
function showdiv(id) { if(id != "" && id != null) document.getElementById(id).style.display = "block"; }
function hidediv(id) { if(id != "" && id != null) document.getElementById(id).style.display = "none"; }

function windowOpener(url,width,height,name,scrolls) {
	browserName = navigator.appName;
	browserVer = navigator.appVersion.substring(0,1);
	if (width==null) {width=900;}
	if (height==null) {height=394;}
	if (name==null) {name="globaltPopup"}
	if (scrolls==true) {
		scrollsOption="yes";
	} else {
		scrollsOption="no";
	}
	var topPx = (browserName=="Netscape")?"screenX":"top";
	var leftPx = (browserName=="Netscape")?"screenY":"left";
	if (browserName != "Netscape" || browserVer != 2) {
		controlWindow=window.open(url,name,"toolbar=no,height="+height+",width="+width+",location=no,directories=no,status=no,menubar=no,scrollbars="+scrollsOption+",resizable=no,"+leftPx+"=100,"+topPx+"=100");
        controlWindow.focus();
    }
}

// de/incement by
var pixs = 30;	
var element_height = 241;
var d_height = 241;
var eh2 = element_height + 1;
var element_targetheight = 392;


function changeheight2(flip){
	if(element_height > element_targetheight && flip==0) { flip = 1; return;}
	if(element_height < eh2 && flip==1) { flip = 0; return;}
	if(flip) x = -pixs;
	if(!flip) x = pixs;
	element_height = element_height + x;
	el = document.getElementById("home-main-teaser");
	//flash = document.getElementById("home-main-teaser");
	el.style.height = element_height + 'px';
	//flash.style.height = element_height + 'px';
	var to = setTimeout("changeheight("+flip+");",0);
	if (!flip) {
		if(element_height > element_targetheight) { 
			el.style.height = element_targetheight + 'px';
			//flash.style.height = element_targetheight;
		}
	}
	if (flip) {
		if(element_height < d_height) { 
			el.style.height = d_height + 'px';
			//flash.style.height = d_height;
		}
	}
}

function changeheight(flip){
if(flip==0) w = 392;
if(flip==1) w = 241;
document.getElementById('home-main-teaser').style.height = w + 'px'; 
document.getElementById('main').style.height = w + 'px';
}


/**/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function insertAfter(newElement,targetElement) {
  var parent = targetElement.parentNode;
  if (parent.lastChild == targetElement) {
    parent.appendChild(newElement);
  } else {
    parent.insertBefore(newElement,targetElement.nextSibling);
  }
}

/**/



function showPic(whichpic,whichcontainer) {
  var source = whichpic.getAttribute("rel");
  for ( var x=0; x < ids.length; x++) {
	if (ids[x] == whichpic) {
		kuva_id = x + 1;
	}
  }
  final_pic_id = "pic"+kuva_id;
  document.getElementById(final_pic_id).style.display = "block";
  var container = document.getElementById(final_pic_id);
  container.setAttribute("src",source);
  return false;
}

function hidePic(whichpic,whichcontainer) {
  document.getElementById(whichcontainer).style.display = "none";
   
   for ( var x=0; x < ids.length; x++) {
	if (ids[x] == whichpic) {
		pic_id = x + 1;
	}
  }
   
  final_pic_id = "pic"+pic_id;
  
  document.getElementById(final_pic_id).style.display = "none";
  return false;
}


function prepareSmallPics() {
  if (!document.createElement) return false;
  if (!document.createTextNode) return false;
  if (!document.getElementById) return false;
   
  for (x=0; x < ids.length; x++) {
	var smallpic = document.createElement("img");
	j = x +1;
	smallpic.setAttribute("id","pic"+j);
	smallpic.setAttribute("class","dont-show");
    smallpic.setAttribute("src","images/100x100trans.gif");
	smallpic.setAttribute("alt","Device 1234");
	curlink = ids[x];
	insertAfter(smallpic,curlink);
	//document.getElementById("pic"+j).style.display = "none";
  }
   
}

var ids = new Array() ;

function prepareComplist() {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("complist")) return false;
  var gallery = document.getElementById("complist");
  var links = gallery.getElementsByTagName("a");
  for ( var i=0; i < links.length; i++) {
	links[i].onmouseover = function() {
      var ids = i + 1;
	  var container = "pic"+ids;
	  var container = "pic"+i;
	 return showPic(this,container);
	}
	
	links[i].onmouseout = function() {
	var container = "pic"+i;
    return hidePic(this,container);
   }
	
   ids[i] = links[i];  
  }
}

addLoadEvent(prepareComplist);
addLoadEvent(prepareSmallPics);




