


/*
CSS Browser Selector v0.2.9
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
var css_browser_selector = function() {var ua=navigator.userAgent.toLowerCase(),is=function(t){return ua.indexOf(t) != -1;},h=document.getElementsByTagName('html')[0],b=(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?'gecko ff2':is('firefox/3')?'gecko ff3':is('gecko/')?'gecko':is('opera/9')?'opera opera9':/opera\s(\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('chrome')?'chrome webkit safari':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';var c=b+os+' js'; h.className += h.className?' '+c:c;}();


userAgent = window.navigator.userAgent;
browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
var selected = '';
var main_mode = '';
var hovering ='';
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
	return '';
}

function findElement(n,ly) {
	if (browserVers < 4)		return document[n];
	var curDoc = ly ? ly.document : document;
	var elem = curDoc[n];
	if (!elem) {
		for (var i=0;i<curDoc.layers.length;i++) {
			elem = findElement(n,curDoc.layers[i]);
			if (elem) return elem;
		}
	}
	return elem;
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		var img;
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			img = null;
			if (document.layers) {
				img = findElement(changeImages.arguments[i],0);
			}
			else {
				img = document.images[changeImages.arguments[i]];
			}
			if (img) {
				img.src = changeImages.arguments[i+1];
			}
		}
	}
}

var preloadFlag = false;
function preloadImagesMain() {
	if (document.images) {
		header_etusivu_over = newImage("images/header_etusivu-over.png");
		header_etusivu_sel = newImage("images/header_etusivu-sel.png");
		header_etusivu_sel_over = newImage("images/header_etusivu-sel-over.png");
		header_palvelut_over = newImage("images/header_palvelut-over.png");
		header_palvelut_sel = newImage("images/header_palvelut-sel.png");
		header_palvelut_sel_over = newImage("images/header_palvelut-sel-over.png");
		header_yritysinfo_over = newImage("images/header_yritysinfo-over.png");
		header_yritysinfo_sel = newImage("images/header_yritysinfo-sel.png");
		header_yritysinfo_sel_over = newImage("images/header_yritysinfo-sel-over.png");
		header_yhteystiedot_over = newImage("images/header_yhteystiedot-over.png");
		header_yhteystiedot_sel = newImage("images/header_yhteystiedot-sel.png");
		header_yhteystiedot_sel_over = newImage("images/header_yhteystiedot-sel-over.png");
		preloadFlag = true;
	}
}

function preloadImagesSub() {
	if (document.images) {
		menu1_over = newImage("images/"+main_mode+"/menu1-over.png");
		menu2_over = newImage("images/"+main_mode+"/menu2-over.png");
		menu3_over = newImage("images/"+main_mode+"/menu3-over.png");
		menu4_over = newImage("images/"+main_mode+"/menu4-over.png");
		menu5_over = newImage("images/"+main_mode+"/menu5-over.png");
		menu6_over = newImage("images/"+main_mode+"/menu6-over.png");
		menu7_over = newImage("images/"+main_mode+"/menu7-over.png");
		submenu1_over = newImage("images/"+main_mode+"/submenu1-over.png");
		submenu2_over = newImage("images/"+main_mode+"/submenu2-over.png");
		submenu3_over = newImage("images/"+main_mode+"/submenu3-over.png");
		submenu4_over = newImage("images/"+main_mode+"/submenu4-over.png");
		preloadFlag = true;
	}
}

function hinauslogo (show) {
	if (show) {
		parent.parent.document.getElementById('hinaus_box').style.visibility='visible';
		parent.parent.document.getElementById('news_box_container').style.left='-1000px';
	} else {
		parent.parent.document.getElementById('hinaus_box').style.visibility='hidden';
		parent.parent.document.getElementById('news_box_container').style.left='30px';
	}
}


function newsbox (show) {
	if (show) {
		parent.document.getElementById('news_box_container').style.left='30px';
/*		parent.document.getElementById('news_box').style.visibility='visible';
		parent.document.getElementById('news_content').style.visibility='visible';
		parent.document.getElementById('news_content1').style.visibility='visible';
		parent.document.getElementById('news_content2').style.visibility='visible';
*/	} else {
		parent.document.getElementById('news_box_container').style.left='-1000px';
/*		parent.document.getElementById('news_box').style.visibility='hidden';
		parent.document.getElementById('news_content').style.visibility='hidden';
		parent.document.getElementById('news_content1').style.visibility='hidden';
		parent.document.getElementById('news_content2').style.visibility='hidden';*/
	}
}

function autofitIframe(id){
	if (!window.opera && !document.mimeType && document.all && document.getElementById){
		if (parent.document.getElementById(id)) {
			parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px";
		}
	}
	else if(document.getElementById) {		
		if (parent.document.getElementById(id)) {
			parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px"
		}
	}
}

function autofitIframe2(id, parent_id){
	if (!window.opera && !document.mimeType && document.all && document.getElementById){
		if (parent.document.getElementById(id)) {
			parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px";
		}
		if (parent.parent.document.getElementById(parent_id)) { 
			parent.parent.document.getElementById(parent_id).style.height=parent.document.body.offsetHeight+"px";
		}
	}
	else if(document.getElementById) {		
		if (parent.document.getElementById(id)) {
			parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px"
		}
		if (parent.parent.document.getElementById(parent_id)) { 
			parent.parent.document.getElementById(parent_id).style.height=parent.document.body.scrollHeight+"px"
		}
	}
} 

function update_header_buttons() {
	var targetbutton;
	if (selected=='header_btn1')
		if (hovering=='header_btn1')
			targetbutton='images/header_etusivu-sel-over.png';
		else
			targetbutton='images/header_etusivu-sel.png';
	else
		if (hovering=='header_btn1')
			targetbutton='images/header_etusivu-over.png';
		else
			targetbutton='images/header_etusivu.png';
			
	changeImages('header_btn1', targetbutton);

	if (selected=='header_btn2')
		if (hovering=='header_btn2')
			targetbutton='images/header_palvelut-sel-over.png';
		else
			targetbutton='images/header_palvelut-sel.png';
	else
		if (hovering=='header_btn2')
			targetbutton='images/header_palvelut-over.png';
		else
			targetbutton='images/header_palvelut.png';
			
	changeImages('header_btn2', targetbutton);

	if (selected=='header_btn3')
		if (hovering=='header_btn3')
			targetbutton='images/header_yritysinfo-sel-over.png';
		else
			targetbutton='images/header_yritysinfo-sel.png';
	else
		if (hovering=='header_btn3')
			targetbutton='images/header_yritysinfo-over.png';
		else
			targetbutton='images/header_yritysinfo.png';
			
	changeImages('header_btn3', targetbutton);

	if (selected=='header_btn4')
		if (hovering=='header_btn4')
			targetbutton='images/header_yhteystiedot-sel-over.png';
		else
			targetbutton='images/header_yhteystiedot-sel.png';
	else
		if (hovering=='header_btn4')
			targetbutton='images/header_yhteystiedot-over.png';
		else
			targetbutton='images/header_yhteystiedot.png';
			
	changeImages('header_btn4', targetbutton);
	
	
}

function update_main_content(mode) {
	main_mode=mode;
	switch (mode) {
		case 'etusivu':
			parent.selected = 'header_btn1';
			break;
		case 'palvelut':
			parent.selected = 'header_btn2';
			break;
		case 'yritysinfo':
			parent.selected = 'header_btn3';
			break;
		case 'yhteystiedot':
			parent.selected = 'header_btn4';
			break;
	}
	preloadImagesSub();
	autofitIframe('main_content');
	parent.update_header_buttons();
}


/* Ladataan nykyään ajankohtaista_tekstit.js -tiedostosta
var pausecontent=new Array()
pausecontent[0]='Korjaamomme odotusaika: 0-10 päivää työkohteesta riippuen Kysy lisää!'
pausecontent[1]='Ilmainen noutopalvelumme tekee sinulle autosi korjauksen todella vaivattomaksi.'
pausecontent[2]='Noudamme veloituksetta autonne korjaukseen Lahden talousalueelta ja toimitamme korjattuna takaisin - vaikka kotipihastanne.'
pausecontent[3]='Kaikki tuulilasit -10% ja useita jopa -40% hinnalla marraskuun loppuun asti.'

*/
/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}


function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,width=600,height=600,left = 400,top = 225');");
}


