var dom = (document.getElementById) ? true : false;
var nn4 = (document.layers) ? true : false;
var ie = (document.all) ? true : false;
var ie4 = (!dom && ie) ? true : false;
var moz = (dom && (navigator.appName=="Netscape")) ? true : false;
var opr = (dom && window.opera) ? true : false;
var op7 = (opr && (navigator.userAgent.indexOf("Opera 7") > 0 || navigator.userAgent.indexOf("Opera/7") >= 0)) ? true : false;

var LoadingIMG = new Image();
LoadingIMG.src = "http://images.vstrecha.de/templates/subSilver/images/loading.gif"; 

function FlashRequest(){}

function mainButtonOver(obj){
	obj.className='MainButtonOver';
}

function mainButtonOut(obj){
	obj.className='MainButton';
}
function init(){}



function Fensterweite()
{
 if (window.innerWidth) return window.innerWidth;
 else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
 else return 0;
}

function Fensterhoehe()
{
 if (window.innerHeight) return window.innerHeight;
 else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
 else return 0;
}



var lastVisitenCard;
var inCard=false;
var SelectOpen=false;
var AutoClose=true;
function viewSelect(href,Ereignis,Element){
	var iframe = document.getElementById("dynamicFrameContainer");
	breite=197;
	hoehe=316;
	position=RicoUtil.toDocumentPosition(Element);
	
	
	if(iframe){
		viewLoadingIMG();
		iframe.style.visibility='visible';
		if(SelectOpen){
			iframe.style.visibility='hidden';
			SelectOpen=false;
			//AutoClose=true;
			return false;
		}

		
		
		if(!Ereignis){
			Ereignis =window.event;
		}	
		
		iframe.style.position="absolute";		
		iframe.style.width=breite+2;
		iframe.style.height=hoehe+2;
		document.getElementById("dynamicFrame").width=breite;
		document.getElementById("dynamicFrame").height=hoehe;
		iframe.style.top=position.y+Element.height-1;
		iframe.style.left=position.x+Element.width-breite+1;
		if(opr){
			iframe.style.top=position.y+Element.height-10;
			iframe.style.left=position.x+Element.width-breite-10;
		}
		SelectOpen=true;
		
		document.getElementById("dynamicFrame").src=href;
		//AutoClose=false;
		
	}	
	return false;
}

function viewLoadingIMG(){

		
		document.getElementById("dynamicFrame").src='http://images.vstrecha.de/templates/subSilver/images/load.html';
	//	window.frames['dynamicFrame'].document.open();
	//	window.frames['dynamicFrame'].document.write('<html><body  style="text-align:center;background-color:#EEEEEE"><br /><br /><img src="http://images.vstrecha.de/templates/subSilver/images/loading.gif" border="0" /></body></html>');
	//	window.frames['dynamicFrame'].document.close();
	
}
function viewVisitenCard(href,Ereignis){
	//alert(id);
	var iframe = document.getElementById("dynamicFrameContainer");
	breite=187;
	hoehe=303;
	
	if(iframe){
		if(lastVisitenCard!=href)viewLoadingIMG();
		iframe.style.visibility='visible';
		inCard=false;
		SelectOpen=false;
		
		if(lastVisitenCard!=href)document.getElementById("dynamicFrame").src=href;
		lastVisitenCard=href;
		if(!Ereignis){
			Ereignis =window.event;
		}
		//alert(Ereignis.clientX+'x'+Ereignis.clientY);
		
		iframe.style.position="absolute";		
		iframe.style.width=breite+2;
		iframe.style.height=hoehe+2;
		document.getElementById("dynamicFrame").width=breite;
		document.getElementById("dynamicFrame").height=hoehe;
		
		if((Fensterhoehe()-Ereignis.clientY)<hoehe+20 && Ereignis.clientY>hoehe){
			iframe.style.top=Ereignis.clientY+document.body.scrollTop-5-hoehe;
		}else{
			iframe.style.top=Ereignis.clientY+document.body.scrollTop+2;
		}
		if((Fensterweite()-Ereignis.clientX)<breite+30){
			iframe.style.left=Ereignis.clientX+document.body.scrollLeft-2-breite;
		}else{
			iframe.style.left=Ereignis.clientX+document.body.scrollLeft+2;
		}
	}
	
	
}

function moveVisitenCard(Ereignis){
	var iframe = document.getElementById("dynamicFrameContainer");
	if(iframe){
		iframe.style.visibility='visible';
	}
}
function hideVisitenCard(){
	if(SelectOpen)return;
	//viewLoadingIMG();
	window.setTimeout("hideVisitenCard3()", 300);
	
}
$anzahlOuts=0;
function hideVisitenCard2(){
	if(SelectOpen)return;
	if(opr && $anzahlOuts==0){
		$anzahlOuts=1;
		return;
	}
	window.setTimeout("hideVisitenCard3()", 300);
	inCard=false;	
}
function hideVisitenCard3(){
	if(inCard)return;
	if(SelectOpen)return;
	var iframe = document.getElementById("dynamicFrameContainer");
	if(iframe){
		iframe.style.visibility='hidden';
		
	}
	$anzahlOuts=0;
}
function closeDynamicFrame(){
	var iframe = document.getElementById("dynamicFrameContainer");
	if(iframe){
		iframe.style.visibility='hidden';
		SelectOpen=false;
	}
}
function setInCard(){
	var iframe = document.getElementById("dynamicFrameContainer");
	if(iframe){
		iframe.style.visibility='visible';
	}
	inCard=true;
}


var RicoUtil = {

   getElementsComputedStyle: function ( htmlElement, cssProperty, mozillaEquivalentCSS) {
      if ( arguments.length == 2 )
         mozillaEquivalentCSS = cssProperty;

      var el = htmlElement;
      if ( el.currentStyle )
         return el.currentStyle[cssProperty];
      else
        return document.defaultView.getComputedStyle(el, null).getPropertyValue(mozillaEquivalentCSS);
   },

   createXmlDocument : function() {
      if (document.implementation && document.implementation.createDocument) {
         var doc = document.implementation.createDocument("", "", null);

         if (doc.readyState == null) {
            doc.readyState = 1;
            doc.addEventListener("load", function () {
               doc.readyState = 4;
               if (typeof doc.onreadystatechange == "function")
                  doc.onreadystatechange();
            }, false);
         }

         return doc;
      }

      if (window.ActiveXObject)
          return Try.these(
            function() { return new ActiveXObject('MSXML2.DomDocument')   },
            function() { return new ActiveXObject('Microsoft.DomDocument')},
            function() { return new ActiveXObject('MSXML.DomDocument')    },
            function() { return new ActiveXObject('MSXML3.DomDocument')   }
          ) || false;

      return null;
   },

   getContentAsString: function( parentNode ) {
      return parentNode.xml != undefined ? 
         this._getContentAsStringIE(parentNode) :
         this._getContentAsStringMozilla(parentNode);
   },

  _getContentAsStringIE: function(parentNode) {
     var contentStr = "";
     for ( var i = 0 ; i < parentNode.childNodes.length ; i++ ) {
         var n = parentNode.childNodes[i];
         if (n.nodeType == 4) {
             contentStr += n.nodeValue;
         }
         else {
           contentStr += n.xml;
       }
     }
     return contentStr;
  },

  _getContentAsStringMozilla: function(parentNode) {
     var xmlSerializer = new XMLSerializer();
     var contentStr = "";
     for ( var i = 0 ; i < parentNode.childNodes.length ; i++ ) {
          var n = parentNode.childNodes[i];
          if (n.nodeType == 4) { // CDATA node
              contentStr += n.nodeValue;
          }
          else {
            contentStr += xmlSerializer.serializeToString(n);
        }
     }
     return contentStr;
  },

   toViewportPosition: function(element) {
      return this._toAbsolute(element,true);
   },

   toDocumentPosition: function(element) {
      return this._toAbsolute(element,false);
   },

   /**
    *  Compute the elements position in terms of the window viewport
    *  so that it can be compared to the position of the mouse (dnd)
    *  This is additions of all the offsetTop,offsetLeft values up the
    *  offsetParent hierarchy, ...taking into account any scrollTop,
    *  scrollLeft values along the way...
    *
    * IE has a bug reporting a correct offsetLeft of elements within a
    * a relatively positioned parent!!!
    **/
   _toAbsolute: function(element,accountForDocScroll) {

     // if ( navigator.userAgent.toLowerCase().indexOf("msie") == -1 )
      //   return this._toAbsoluteMozilla(element,accountForDocScroll);

      var x = 0;
      var y = 0;
      var parent = element;
	 
      str="";
      
      while ( parent ) {
		
         var borderXOffset = 0;
         var borderYOffset = 0;
         if ( parent != element ) {
            var borderXOffset = parseInt(this.getElementsComputedStyle(parent, "borderLeftWidth" ));
            var borderYOffset = parseInt(this.getElementsComputedStyle(parent, "borderTopWidth" ));
            borderXOffset = isNaN(borderXOffset) ? 0 : borderXOffset;
            borderYOffset = isNaN(borderYOffset) ? 0 : borderYOffset;
         }

         x += parent.offsetLeft  + borderXOffset;
         y += parent.offsetTop  + borderYOffset;
         
        // str+=parent.id+": "+parent.offsetTop+"  + "+borderYOffset+" \r\n";
         
		 parent = parent.offsetParent;
		
		 
      }
		//alert(str+' --- '+y);
      if ( accountForDocScroll ) {
         x += this.docScrollLeft();
         y += this.docScrollTop();
      }

      return { x:x, y:y };
   },

   /**
    *  Mozilla did not report all of the parents up the hierarchy via the
    *  offsetParent property that IE did.  So for the calculation of the
    *  offsets we use the offsetParent property, but for the calculation of
    *  the scrollTop/scrollLeft adjustments we navigate up via the parentNode
    *  property instead so as to get the scroll offsets...
    *
    **/
   _toAbsoluteMozilla: function(element,accountForDocScroll) {
      var x = 0;
      var y = 0;
      var parent = element;
      while ( parent ) {
         x += parent.offsetLeft;
         y += parent.offsetTop;
         parent = parent.offsetParent;
      }

      parent = element;
      while ( parent &&
              parent != document.body &&
              parent != document.documentElement ) {
         if ( parent.scrollLeft  )
            x -= parent.scrollLeft;
         if ( parent.scrollTop )
            y -= parent.scrollTop;
         parent = parent.parentNode;
      }

      if ( accountForDocScroll ) {
         x -= this.docScrollLeft();
         y -= this.docScrollTop();
      }

      return { x:x, y:y };
   },

   docScrollLeft: function() {
      if ( window.pageXOffset )
         return window.pageXOffset;
      else if ( document.documentElement && document.documentElement.scrollLeft )
         return document.documentElement.scrollLeft;
      else if ( document.body )
         return document.body.scrollLeft;
      else
         return 0;
   },

   docScrollTop: function() {
      if ( window.pageYOffset )
         return window.pageYOffset;
      else if ( document.documentElement && document.documentElement.scrollTop )
         return document.documentElement.scrollTop;
      else if ( document.body )
         return document.body.scrollTop;
      else
         return 0;
   }

};
function viewAttach(a,img,ausrichtung){
	document.write('<a href="'+a+'" target="_blank" onClick=\'window.open("'+a+'","users_popup","width=1024,height=800,resizable=yes,scrollbars=yes");return false;\'><img src="'+img+'" border="0" align="'+ausrichtung+'" vspace="3" hspace="3" name="attach_img" /></a>')	
}
function remoteImg(img){
	document.write('<img src="'+img+'" border="0"  name="remote_img" />');	
}
