/**
 * rs.js 2.0 (01-11-2009) (c) by Bernd Kiessling 
 * All Rights Reserved.
 * Es ist nicht erlaubt, diese Scripts ohne schriftliche Zustimmung des Autorīs zu verwenden, zu kopieren oder weiterzugeben !!
**/
var rs_allobjs=new Array();
var rs_scale=1;
var rs_mwidth=600;
var rs_mheight=400;
function RS(p_mwidth,p_mheight,p_mscale){	
	var thisobj=this;
	rs_mwidth=p_mwidth;
	rs_mheight=p_mheight;
	thisobj.gminw=parseInt((p_mscale*rs_mwidth)/100);
	thisobj.lastw=rs_mwidth;
	thisobj.lasth=rs_mheight;
	if(document.getElementsByTagName("body")[0].style.backgroundImage!="none"){
		if((isIEM())||(isOM())){
			document.getElementsByTagName("body")[0].style.backgroundImage="none";
		}else{
			try{
				img=new Image();
				img.id="bg";
				var tmpsrc=document.getElementsByTagName("body")[0].style.backgroundImage.substring(4,document.getElementsByTagName("body")[0].style.backgroundImage.length-1);
				if((tmpsrc.substr(0,1)=="\"")&&(tmpsrc.substr(tmpsrc.length-1,1)=="\"")){
					tmpsrc=tmpsrc.substring(1,tmpsrc.length-1);
				}
				img.src=tmpsrc;
				img.style.position="absolute";
				img.style.top="0px";
				img.style.left="0px";
				img.style.width=String(rs_mwidth)+"px";
				img.style.height=String(rs_mheight)+"px";
				document.getElementsByTagName("body")[0].insertBefore(img,document.getElementsByTagName("body")[0].firstChild);
				document.getElementsByTagName("body")[0].style.backgroundImage="none";
			}catch(e){//nothing
			}
		}
	}
	document.getElementsByTagName("body")[0].style.overflow="hidden";
	bc_addObj(document.getElementsByTagName("body")[0]);
	thisobj.resize=function(){
		var width = window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth);
		var height = window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight);
		var minw=screen.availWidth;
		if(width==null){
			if(minw==null){
				width=rs_mwidth;	
			}else{
				width=minw;
			}
		}
		if((width!=thisobj.lastw)||(height!=thisobj.lasth)){			
			if((isNF())||(isIEM())){
				rs_scale=0.8;				
			}else if((isSFM())||(isOM())){
				//nothing
			}else{
				if(width<thisobj.gminw){
					width=thisobj.gminw;	
				}
				rs_scale=((width*100)/rs_mwidth)/100;
			}
			for(var i=0;i<bc_allobjs.length;i++){
				if(bc_allobjs[i][0]!=null){
					rs_rsObj(bc_allobjs[i][0]);
				}
			}
			thisobj.lastw=width;
			thisobj.lasth=height;
			//min size			
			if(width<thisobj.gminw){
				try{
					document.getElementsByTagName("body")[0].style.overflow="auto";
				}catch(e){//nothing
				}	
			}else{	
				try{
					document.getElementsByTagName("body")[0].style.overflow="hidden";
				}catch(e){//nothing
				}
				var tmph=-1;
				var tmpt=0;
				for(var i=0;i<document.getElementsByTagName("body")[0].childNodes.length;i++){
					if(document.getElementsByTagName("body")[0].childNodes[i].tagName){
						if(document.getElementsByTagName("body")[0].childNodes[i].height>height){
							try{
								document.getElementsByTagName("body")[0].style.overflow="auto";
							}catch(e){//nothing
							}
							tmph=-1;
							break;
						}else{
							if(tmph<document.getElementsByTagName("body")[0].childNodes[i].height){
								tmph=document.getElementsByTagName("body")[0].childNodes[i].height;	
								tmpt=Number(document.getElementsByTagName("body")[0].childNodes[i].style.top.substring(0,document.getElementsByTagName("body")[0].childNodes[i].style.top-2));
							}
						}
					}
				}
				if((tmph!=-1)&&(!isNaN(tmph))){
					var tmpset=height/2-tmph/2;
					for(var i=0;i<document.getElementsByTagName("body")[0].childNodes.length;i++){
						if(document.getElementsByTagName("body")[0].childNodes[i].style){
							document.getElementsByTagName("body")[0].childNodes[i].style.top=String(Number(document.getElementsByTagName("body")[0].childNodes[i].style.top.substring(0,document.getElementsByTagName("body")[0].childNodes[i].style.top.length-2))+tmpset)+"px";
						}
					}
				}
			}
		}
	};
	thisobj.resize();
	if(window.onresize==null){
		window.onresize=function(){
			thisobj.resize();
		};
	}
}
function rs_rsObjs(p_indxs){
	for(var i=0;i<p_indxs.length;i++){
		rs_rsObj(bc_allobjs[p_indxs[i]][0]);
	}
}
function rs_rsObj(p_obj){
	var indx=bc_isAllObj(p_obj);
	if(indx==-1){
		bc_addObj(p_obj);
		rs_rsObj(p_obj);
	}else{
		for(var i=0;i<bc_allobjs[indx][1].length;i++){
			if((bc_allobjs[indx][1][i][2]!=null)&&(bc_allobjs[indx][1][i][2]!="%")){
				bc_setStyle(p_obj,String(bc_allobjs[indx][1][i][0]),String(Math.round(Number(bc_allobjs[indx][1][i][1])*rs_scale))+String(bc_allobjs[indx][1][i][2]));
			}
		}
	}
}
