d=document;
w=window;
nav4=window.Event?true:false;
function $(id){
	if(d.all){
		return d.all[id];
	}else{
		return d.getElementById(id)
	}
}
function $f(){return window.frames['ifasd'].document}
function $w(){return window.frames['ifasd'].window}
function $$(id){return $f().getElementById(id)}

popupuseouterwin=false;
de={
	actmen:null,
	contentscroll:function(){
		alert(1);
		st.overmen_kill();
	},
	addcontentscroll:function(val){
		return [val[0],(val[1]-parseInt($('content_left').scrollTop))];
	},
	addrightmenuscroll:function(val){
		return [val[0],(val[1]-parseInt($('content_right').scrollTop))];
	},
	adddetailimagescroll:function(val){
		return [val[0],(val[1]-parseInt($('detail_top_images').scrollTop))];
	},
	getpos:function(objId) {
		var curleft=curtop=0;
		if(objId.offsetParent){
			do{
				curleft+=objId.offsetLeft;
				curtop+=objId.offsetTop;
			}while(objId=objId.offsetParent);
		}
		return[curleft,curtop];
	},
	setposition:function(posId,objId){
		pos=de.getpos(posId);
		posLeft=pos[0]+1;
		posTop=pos[1]+43;
		objWidth=parseInt(objId.offsetWidth);
		rightPos=(posLeft+objWidth);
		winWidth=de.scrWH('in')[0];
		if(_BNM=='SF'){ //Safari, Chrome
			posTop=parseInt(posTop)-13;
		}
		objId.style.top=posTop;
		if(rightPos>winWidth){
			objId.style.left=(winWidth-objWidth)+'px';
		} else {
			objId.style.left=posLeft+'px';
		}
	},
	overpopmen:function(objId,id){
		if(de.actmen!=null&&de.actmen!=id){
			de.setactmen(id);
			de.popmen(objId,id);
		}else if(de.actmen==id){
			de.setactmen(id);
		}
	},
	fader:function(id,how,grayout,kill){
		if(!grayout)grayout=0;
		if(how=='block'){
			de.changeopac('0.1',id);
			$(id).style.display='block';
			setTimeout('de.changeopac(0.2,\''+id+'\','+grayout+')',25);
			setTimeout('de.changeopac(0.4,\''+id+'\','+grayout+')',50);
			setTimeout('de.changeopac(0.6,\''+id+'\','+grayout+')',75);
			setTimeout('de.changeopac(0.8,\''+id+'\','+grayout+')',100);
			setTimeout('de.changeopac(1.0,\''+id+'\','+grayout+')',125);
		}else if(how=='fadeout'){
			setTimeout('de.changeopac(1.0,\''+id+'\','+grayout+')',25);
			setTimeout('de.changeopac(0.8,\''+id+'\','+grayout+')',50);
			setTimeout('de.changeopac(0.6,\''+id+'\','+grayout+')',75);
			setTimeout('de.changeopac(0.4,\''+id+'\','+grayout+')',100);
			setTimeout('de.changeopac(0.2,\''+id+'\','+grayout+')',125);
			if(kill){
				setTimeout('de.changeopac(-1,\''+id+'\','+grayout+')',150);
			}else{
				setTimeout('de.changeopac(0,\''+id+'\','+grayout+')',150);
			}
		}else{
			de.changeopac('1.0',id);
			objId.display='none';
		}
	},
	changeopac:function(op,id,grayout){
		if($(id)==null){
			objId=id.style;
			objId___=id;
		}else{
			objId=$(id).style;
			objId___=$(id);
		}
		if(!objId)return;
		if(op==0){
			objId.display='none';
			if(grayout==1){
				de.grayout('hide');
			}
		} else if(op==-1){
			d.body.removeChild(objId___);
			if(grayout==1){
				de.grayout('hide');
			}
		}else{
			objId.opacity=(op);
			objId.MozOpacity=(op);
			objId.KhtmlOpacity=(op);
			objId.filter='alpha(opacity='+(op*100)+')';
		}
		if(op=='1.0'&&grayout==1){
			de.grayout();
		}
	},
	scrWH:function(what){
		thisScrollT=d.body.scrollTop;
		thisWindowX=(d.documentElement&&d.documentElement.clientWidth)||w.innerWidth||self.innerWidth||d.body.clientWidth;
		thisWindowY=(d.documentElement&&d.documentElement.clientHeight)||w.innerHeight||self.innerHeight||d.body.clientHeight;
		thisScrollX=(d.documentElement&&d.documentElement.scrollLeft)||w.pageXOffset||self.pageXOffset||d.body.scrollLeft;
		thisScrollY=(d.documentElement&&d.documentElement.scrollTop)||w.pageYOffset||self.pageYOffset||d.body.scrollTop;
		thisPageX=(d.documentElement&&d.documentElement.scrollWidth)?d.documentElement.scrollWidth:(d.body.scrollWidth>d.body.offsetWidth)?d.body.scrollWidth:d.body.offsetWidth;
		thisPageY=(d.documentElement&&d.documentElement.scrollHeight)?d.documentElement.scrollHeight:(d.body.scrollHeight>d.body.offsetHeight)?d.body.scrollHeight:d.body.offsetHeight;
		if(what=='in'){
			return[thisWindowX,thisWindowY,thisScrollT];
		}else{
			return[thisPageX,thisPageY,thisScrollT];
		}
		//return 'thisWindowX:'+thisWindowX+'\nthisWindowY:'+thisWindowY+'\nthisScrollX:'+thisScrollX+'\nthisScrollY:'+thisScrollY+'\nthisPageX:'+thisPageX+'\nthisPageY:'+thisPageY;
	},
	grayout:function(hide,layer,indx,opc){
		if(layer==null)layer='grayout';
		if(indx==null)indx=898;
		if(opc==null)opc=0.4;
		inout=(popupuseouterwin==true)?'out':'in';
		if($(layer)==null)
			goe=layer;
		else
			goe=$(layer);
		if(hide){
			goe.style.display='none';
		} else {
			de.changeopac(opc,layer);
			winsize=de.scrWH(inout);
			goe.style.width=winsize[0]+'px';
			goe.style.height=winsize[1]+'px';
			goe.style.zIndex=indx;
			goe.style.display='block';
		}
	},
	popload:function(inh,closer,toped){
		poploadCloser=closer;
		poploadToped=toped;
		jx.return_call('http://'+hostver+inh+'&sid='+jx.sid(),'de.poploadset','|pg.loader','POST');
	},
	poploadset:function(ret){
		scroll(0,0);
		val=jx.dataArray(unescape(ret));
		txt=(val[1])?val[1]:val[0];
		usecloser=(poploadCloser)?1:null;
		usetoped=(poploadToped)?1:null;
		try{usewidth=poploadSetWidth}catch(e){usewidth='550'}
		try{usetopic=poploadSetTopic}catch(e){usetopic=false}
		try{usetop=poploadSetTop}catch(e){usetop=null}
		de.popup(usewidth,txt,usetop,null,usecloser,usetopic,usetoped);
		poploadSetWidth=null;
		poploadSetTopic=null;
		if(val[2]){ // Eval script from loaded page
			eval(val[2]);
		}
	},
	popup:function(w,inh,tl,ll,closer,topic,toped){
		popupuseouterwin=false; //login uses total window
		if(toped){
			elm_nam='poptop';
			hider='hidepotop';
		}else{
			elm_nam='popup';
			hider='hide';
		}
		elm=$(elm_nam);
		if(w=='hide') {
			if(inh!='nofade'){
				de.fader('popup','fadeout',1);
			}else{
				$('popup').style.display='none';
				de.grayout('hide');
			}
		}else if(w=='hidepotop'){
			de.grayout('hide','grayout2');
			$('poptop').style.display='none';
		}else{
			if(!w)w=300;
			if(!tl) {
				tl=100;
			}
			if(ll=='totalcenter') {
				popupuseouterwin=true;
				areacenter=(de.scrWH('out')[0]/2);
				ll=(areacenter-(w/2));
			}else if(!ll) {
				areacenter=400;
				ll=(areacenter-(w/2));
			}
			if(!nav4)w=parseInt(w)+20; // IE fix
			elm.style.top=tl+'px';
			elm.style.left=ll+'px';
			elm.style.width=w+'px';
			inhtxt=unescape(inh);
			if(closer){
				setmen='<div class="clear">';
				if(topic){
					setmen+='<div style="float:left"><h1>'+topic+'</h1></div>';
				}
				setmen+='<div style="float:right"><img src="/_gfx/trans.gif" class="close" onclick="de.popup(\''+hider+'\')"></div>';
				setmen+='</div>';
				inhtxt=setmen+inhtxt;
			}
			elm.innerHTML=inhtxt;
			if(toped){
				de.grayout('','grayout2',900,0.3);
				elm.style.display='block';
			}else{
				de.fader(elm_nam,'block',1);
			}
		}
	},
	poptop:function(w,evt,inh,innt,met){
		if(!met)met='GET';
		elm=$('poptop');
		if(w=='hide') {
			elm.style.display='none';
			$('poptop').innerHTML='';
			de.grayout('hide','grayout2');
		} else {
			if(evt){
				getpageXY=de.pageXY(evt);
				x=getpageXY[0];
				y=getpageXY[1];
				y=(y-50);
			}else{
				if(!w)w=300;
				y=100;
				areacenter=400;
				x=(areacenter-(w/2));
				if(!nav4)w=parseInt(w)+20; // IE fix
			}
			elm.style.top=y+'px';
			elm.style.left=x+'px';
			elm.style.width=w+'px';
			elm.style.display='block';
			if(innt) {
				$('poptop').innerHTML=innt;
			} else {
				jx.return_call('http://'+hostver+inh+'&sid='+jx.sid(),'de.poptopset','|pg.loader',met);
			}
			de.grayout('','grayout2',900,0.3);
		}
	},
	poptopset:function(ret){
		val=jx.dataArray(unescape(ret));
		inhtxt=val[1];
		try{
			if(closer){
				setmen='<div class="clear">';
				try{
					if(poptop_topic){
						setmen+='<div style="float:left"><h1>'+poptop_topic+'</h1></div>';
					}
				}catch(e){}
				setmen+='<div style="float:right"><img src="/_gfx/trans.gif" class="close" onclick="de.poptop(\'hide\')"></div>';
				setmen+='</div>';
				inhtxt=setmen+inhtxt;
			}
		}catch(e){}
		closer=false;
		poptop_topic=false;
		$('poptop').innerHTML=inhtxt;
	},
	replace:function(string,text,by) {
		stringLength=string.length
		textLength=text.length;
		if((stringLength==0)||(textLength==0))return string;
		try{
			i=string.indexOf(text);
		}catch(e){
			i=null;
			return string;
		}
		if((!i)&&(text!=string.substring(0,textLength)))return string;
		if(i==-1)return string;
		newstr=string.substring(0,i)+by;
		if((i+textLength)<stringLength)
		newstr+=this.replace(string.substring(i+textLength,stringLength),text,by);
		return newstr;
	},
	newImgSize:function(objid,img,s,getback) {
		if(!getback)getback=false;
		imgn=new Image();
		imgn.name=img;
		imgn.src=img;
		if(imgn.complete){
			de.newImgSize_set(imgn,objid,s,getback);
		}else{
			imgn.onload=function(){
				de.newImgSize_set(this,objid,s,getback);
			}
		}
		imgn.onerror=function(){
			//alert('error');
			return false;
		}
	},
	newImgSize_set:function(im,objid,s,getback){
		imgw=im.width;
		imgh=im.height;
		if(imgw!=imgh) {
			if(imgh>imgw) {
				imgnw=(s/imgh)*imgw;
				imgnh=s;
			} else {
				imgnh=(s/imgw)*imgh;
				imgnw=s;
			}
		} else {
			imgnw=s;
			imgnh=s;
		}
		//return Array(imgnw,imgnh);
		objid.className='';
		objid.src=im.src;
		objid.width=imgnw;
		objid.height=imgnh;
		if(getback){
			eval(getback);
		}
	},
	rgbConvert:function(str){
		str=str.toLowerCase();
		if(str.search(/rgb/)!=-1) {
			str=str.replace(/rgb\(|\)/g,'').split(',');
			str[0]=parseInt(str[0],10).toString(16).toLowerCase();
			str[1]=parseInt(str[1],10).toString(16).toLowerCase();
			str[2]=parseInt(str[2],10).toString(16).toLowerCase();
			str[0]=(str[0].length==1)?'0'+str[0]:str[0];
			str[1]=(str[1].length==1)?'0'+str[1]:str[1];
			str[2]=(str[2].length==1)?'0'+str[2]:str[2];
			return(str.join('').toUpperCase());
		}else{
			str=de.replace(str,'#','');
			return str.toUpperCase();
		}
	},
	rgbMake:function(str){
		str=this.rgbConvert(str);
		return [parseInt(str.substring(0,2),16), parseInt(str.substring(2,4),16), parseInt(str.substring(4,6),16)];
	},
	strip_tags:function(str,allowed_tags){
		var key='',tag='',allowed=false;
		matches=allowed_array=[];
		allowed_keys={};
		replacer=function(search,replace,str) {
			tmp_arr=[];
			tmp_arr=str.split(search);
			return tmp_arr.join(replace);
		};
		// Build allowes tags associative array
		if(allowed_tags){
			allowed_tags=allowed_tags.replace(/[^a-zA-Z,]+/g, '');
			allowed_array=allowed_tags.split(',');
		}
		// Match tags
		matches=str.match(/(<\/?[^>]+>)/gi);
		// Go through all HTML tags 
		for(key in matches){
			if(isNaN(key)){
				continue; // IE7 Hack
			}
			// Save HTML tag
			html=matches[key].toString();
			// Is tag not in allowed list? Remove from str!
			allowed=false;
			// Go through all allowed tags
			for(k in allowed_array){
				// Init
				allowed_tag=allowed_array[k];
				i=-1;
				if(i!=0){i=html.toLowerCase().indexOf('<'+allowed_tag+'>');}
				if(i!=0){i=html.toLowerCase().indexOf('<'+allowed_tag+' ');}
				if(i!=0){i=html.toLowerCase().indexOf('</'+allowed_tag);}
				// Determine
				if(i==0){
					allowed=true;
					break;
				}
			}
			if(!allowed){
				str=replacer(html,"",str); // Custom replace. No regexing
			}
		}
		return str;
	},
	number_format:function(a,b,c,d) {
		// number_format(number,decimals,comma,formatSeparator)
		a=Math.round(a*Math.pow(10,b))/Math.pow(10,b);
		e=a+'';
		f=e.split('.');
		if(!f[0])f[0]='0';
		if(!f[1])f[1]='';
		if(f[1].length<b){
			g=f[1];
			for(i=f[1].length+1;i<=b;i++){
				g+='0';
			}
			f[1]=g;
		}
		if(d!=''&&f[0].length>3){
			h=f[0];
			f[0]='';
			for(j=3;j<h.length;j+=3){
				i=h.slice(h.length-j,h.length-j+3);
				f[0]=d+i+f[0]+'';
			}
			j=h.substr(0,(h.length%3==0)?3:(h.length%3));
			f[0]=j+f[0];
		}
		c=(b<=0)?'':c;
		return f[0]+c+f[1];
	},
	setAttribute:function(objId,stl){
		if(_BID==1){
			objId.setAttribute('style',stl);
		}else{
			objId.style.setAttribute('cssText',stl);
		}
	},
	preventDefault:function(e){
		if(nav4){
			e.preventDefault();
			e.stopPropagation();
		}else{
			window.event.returnValue=false;
		}
	},
	pageXY:function(e){
		if(nav4){
			return[e.pageX,e.pageY]
		}else{
			return[(window.event.clientX+d.body.scrollLeft),(window.event.clientY+d.body.scrollTop)]
		}
	},
	colorfade:function(objId,startColor,endColor,speed,delay){
		target=objId;
		this.colorfade_set(target,'rgb('+startColor[0]+','+startColor[1]+','+startColor[2]+')');
		steps=speed*20;//10 steps/second
		speed=speed*1000/steps;//make seconds
		s_r=startColor[0]; s_g=startColor[1]; s_b=startColor[2];
		e_r=endColor[0]; e_g=endColor[1]; e_b=endColor[2];
		rint=Math.round(Math.abs(s_r-e_r)/steps);
		gint=Math.round(Math.abs(s_g-e_g)/steps);
		bint=Math.round(Math.abs(s_b-e_b)/steps);
		for(a=0;a<=steps;a++){
			delay+=speed;
			s_r=(s_r>=e_r)?s_r-rint:s_r+rint;
			s_g=(s_g>=e_g)?s_g-gint:s_g+gint;
			s_b=(s_b>=e_b)?s_b-bint:s_b+bint;
			color='rgb('+s_r+','+s_g+','+s_b+')';
			setTimeout('de.colorfade_set(target,\''+color+'\')',delay);
		}
		delay+=speed;
		color='rgb('+e_r+','+e_g+','+e_b+')';
		setTimeout('de.colorfade_set(target,\''+color+'\')',delay);
	},
	colorfade_set:function(target,color){
		target.style.background=color;
	},
	overflowheight:function(){
		height=de.overflowheight_get()-100;
		fld_ary=Array('content_left','content_right');
		for(a_ in fld_ary){
			try{
				$(fld_ary[a_]).style.height=height+'px';
			}catch(e){}
		}
	},
	overflowheight_get:function(){
		de_=d.documentElement;
		return self.innerHeight||(de_&&de_.clientHeight)||d.body.clientHeight;  
	},
	set_theme:function(thm__){
		ac.cookie_set('site_theme_save',thm__);
		$('css_theme').href='_css/theme_'+thm__+'.css'; 
	},
	prew_theme:function(thm__){
		de.popup('hide');
		setTimeout('pg.mysettings(\'themes\')',2000);
	},
	detail_mined:[],
	detail_min:function(minId){
		this.detail_mined[minId]=minId;
		$('details_'+minId).style.display='none';
		de_ndiv=d.createElement('div');
		de_ndiv.className='mined_item color_main_bg';
		if(_BID==1){
			de_ndiv.setAttribute('onclick','de.detail_min_open('+minId+')');
		}else{
			de_ndiv.onclick=function(){de.detail_min_open(minId)}
		}
		de_ndiv.innerHTML=$('spec_artnr').value+' - '+$('spec_desc').value;
		$('mined').appendChild(de_ndiv);
	},
	detail_min_open:function(minId){
		this.detail_close_all();
		$('details_'+minId).style.display='block';
	},
	detail_close_all:function(){
		$('details').style.display='none';
		$('details').innerHTML='';
		/*
		for(a in this.detail_mined){
			$('details_'+a).style.display='none';
		}
		*/
	},
	cssGetAttribute:function(id,styleFF,styleIE){
		if($(id)==null){
			objId=id;
		}else{
			objId=$(id);
		}
		if(_BID==1){ // FF
			cs____=d.defaultView.getComputedStyle(objId,null);
			ret__=cs____.getPropertyValue(styleFF);
		}else{
			ret__=objId.currentStyle[styleIE];
		}
		return ret__;
	},
	dragfocus:function(objId,usecontleft){
	// TURNED OFF
		return;


		if(_BID!=1)return; // problems in ie
		if(usecontleft){
			$('content_left').style.position='absolute';
			$('content_left').style.zIndex=900;
		}
		objId.style.zIndex=900;
		de.grayout(null,null,null,0.4);
	},
	dragunfocus:function(objId){
	// TURNED OFF
		return;



		if(_BID!=1)return; // problems in ie
		de.grayout('hide');
		$('content_left').style.position='';
		$('content_left').style.zIndex='';
		objId.style.zIndex='';
	},


	set_onclick:function(objid__,func__){
		if(_BID==1){
			objid__.setAttribute('onclick',func__);
		}else{
			objid__.onclick=new Function('evt',func__);
		}
	},
	get_offettop:function(objid__){
		if(_BID==1){
			return parseInt(objid__.offsetTop);
		}else if(_BID==10){ // IE 8<
			return parseInt(objid__.offsetTop);
		}else{
			return parseInt(objid__.offsetTop)+parseInt(objid__.parentNode.offsetTop);
		}
	},
	get_selectvalue:function(objid__){
		try{
			return objid__.options[objid__.selectedIndex].value;
		}catch(e){return false}
	},
	get_selecttext:function(objid__){
		try{
			return objid__.options[objid__.selectedIndex].text;
		}catch(e){return false}
	},
	set_selectvalue:function(objid__,val__){
		for(p=0;p<objid__.options.length;p++){
			if(objid__.options[p].value==val__){
				objid__.selectedIndex=p;
			}
		}
	},
	get_mousebutton:function(e){
		if(e.which){
			return e.which;
		}else{
			if(e.button==2){
				return 3;
			}else{
				return e.button;
			}
		}
	},
	pagetitle:function(t__){
		if(!t__)t__=pgtitle;
		d.title=t__;
	},
	charcut:function(obj,len){
		useext=(obj.length>len)?'..':'';
		return obj.substr(0,len)+useext;
		//return obj.slice(0,len)+useext;
	}
};