	window.onload=setup
windowNameDefault="gomediadotch"

function setup(){
	setWindow()
	outLinks()
	if(document.body&&(document.body.className.toLowerCase().indexOf("popup")>-1)){resizeContent()}
}

function resizeContent(){
	if(document.getElementById&&document.getElementById("container")&&bw.ie&&bw.win){
		contWidth=document.getElementById("container").style.width
		for(iLoop=0;iLoop<document.images.length;iLoop++){
			iWidth=parseInt(document.getElementById("inhalt").document.images[iLoop].style.width)
			if(iWidth>contWidth){contWidth=iWidth+"px"}
		}
		document.getElementById("container").style.width=contWidth
		document.getElementById("container").style.margin="13px 2em 0 0"
	}
}

//--- link targeting, so that popup links work in safari ---
function cm(h){
	if(h.target!=""){ // use the specified target
		return true
	}else if((self.window.opener)&&(self.window.opener.name)){ // open in the parent window (if popup)
		self.window.opener.document.location=h.href
		return false
	}
}

// datenblatt staff
function db(o){
	return p(o.href,'datenblatt',520,480,'scrollbars=1')
}

// kontakt formular
function kontakt(o){
	return p(o.href,'kontakt',400,600,'toolbar=0,scrollbars=1,resizable=1')
}

function disclaimer(o){
	return p(o.href,'disclaimer',480,320,'toolbar=0,scrollbars=1,resizable=1')
}

function impressum(o){
	return p(o.href,'impressum',400,454,'toolbar=0,scrollbars=1,resizable=1')
}

function hilfe(o){
	return p(o.href,'hilfe',400,454,'toolbar=0,scrollbars=1,resizable=1')
}

function sitemap(o){
	return p(o.href,'sitemap',1000,500,'toolbar=0,scrollbars=1,resizable=1')
}

function suche(o){
	return p(o.href,'suche',360,480,'toolbar=0,scrollbars=1,resizable=1')
}

function gallery(o){
	return p(o.href,'gallery',525,625,'toolbar=0,scrollbars=1,resizable=0')
}

function zoom(o){
	return popPic(o);
}

function popPic(o){
	saw=screen.availWidth
	sah=screen.availHeight
	popwide=saw<1025?saw*0.95:880
	pophigh=sah<769?sah*0.95:650
	p(o.href,'grafik',popwide,pophigh,'resizable=1,scrollbars=1')
	return false
}

function popmedia(path,mediatype){
	w=(mediatype=="audio")?500:650
	h=(mediatype=="audio")?100:455
	options="menubar=0,location=0,toolbar=0,directories=0,status=1,resizable=1,scrollbars=0"
	return p(path,'gosmedia',w,h,options)
}


/*--- dhtml ---*/
function flickmore(){
	if(document.getElementById&&document.getElementById("more")){
	fulllist=document.getElementById("more").style
	fulllist.display=(fulllist.display=="none")?"block":"none"
	setCookie("morestate",fulllist.display,30)
	}
	return false
}

function pdJumper(pdform,pdField){
	if(document.forms[pdform]&&document.forms[pdform].elements[pdField]){
		if(document.forms[pdform].elements[pdField].options[document.forms[pdform].elements[pdField].selectedIndex].value!=""){
			top.location=document.forms[pdform].elements[pdField].options[document.forms[pdform].elements[pdField].selectedIndex].value
		}
	}
	return false
}

// table zoom into new window
function tz(ob){
	if(document.getElementById){
		stable=window.open(ob.href,"stable","toolbar=1,scrollbars=1,resizable=1,width=800,height=600")
		return false
	}
}

// call onload to set state of article list
function clap(){
	if(document.getElementById&&document.getElementById("more")){
		morestate=getCookie('morestate')
		if(morestate!=""&&morestate!=null){
		document.getElementById("more").style.display=morestate
	}}
}
	
/*--- Window Opener ---*/
cWindows={
	options:new Array(
	"",
	"toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=480,height=390",
	"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=360,height=200",
	"toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=680,height=480",
	"toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=810,height=490",
	"toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=600,height=425",
	"toolbar=1,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=450,height=425",
	"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=360,height=325"
	)
}

function openIt(a,b,n){
	newWin=window.open(a,b,cWindows["options"][n])
}

function setChannelImages(){
	for (var i=0; i<=(document.images.length-1);i++){
		if(document.images[i].src.toLowerCase().indexOf("mediaimgmod") > -1){
			document.images[i].src=replaceAll(document.images[i].src,self.window.location.hostname,"www.mountain.ch")
		}
	}
}
