var requiredMajorVersion = 9;
var requiredMinorVersion = 0;
var requiredRevision = 0;




window.onresize = function () {
window_extention();object_center('grboxmain');
}
window.onload = function () {
window_extention();object_center('grboxmain');
set_focus();
}

function set_focus(){
  var bFound = false;
  // for each form

  for (f=0; f < document.forms.length; f++)
  {
    // for each element in each form

    for(i=0; i < document.forms[f].length; i++)
    {
      // if it's not a hidden element

      if (document.forms[f][i].type != "hidden")
      {
        // and it's not disabled

        if (document.forms[f][i].disabled != true)
        {
            // set the focus to it

            document.forms[f][i].focus();
            var bFound = true;
        }
      }
      // if found in this element, stop looking

      if (bFound == true)
        break;
    }
    // if found in this form, stop looking

    if (bFound == true)
      break;
  }
 } 
  
  

function checkEmail (strng) {
var ret=true;
if (strng == "") {
   ret = false;
}
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       ret = false;
    }
    else {
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          ret = false;
       }
    }
return ret;    
}

var strKlassenName = "novalidate";
var u1sercolor="#0f9e00";
var strPattern = eval("/"+strKlassenName+"/");
function formValidating(objForm){
	  var blnSend = true;
		  for(var i=0; i<objForm.elements.length; i++){

			var objElement = objForm.elements[i];
				if (objElement.type=="text" || objElement.type=="password" || objElement.type=="textarea" ){
				var gr_match1=objElement.value;
				var illegalChars1= /[\(\)\<\>\\\"\[\]]/
				if (gr_match1.match(illegalChars1))  {objElement.style.backgroundColor = u1sercolor; blnSend = false;} else objElement.style.backgroundColor = "";
				}

				if (objElement.type=="text" || objElement.type=="password" )
						if(objElement.className.search(strPattern) == -1){
								if(objElement.value.length <= 3) {
								objElement.style.backgroundColor = u1sercolor; blnSend = false;
								} else if(objElement.value.length >= 3) {
								objElement.style.backgroundColor = "";
								}
								if (objElement.name.search("email") >=0){
								var valid=objElement.value;
								if (checkEmail(objElement.value)==true) objElement.style.backgroundColor = ""; else {objElement.style.backgroundColor = u1sercolor; blnSend = false;}
								}
		
							var gr_match=objElement.value;
							var illegalChars= /[\(\)\<\>\\\"\[\]]/
							if (gr_match.match(illegalChars))  {objElement.style.backgroundColor = u1sercolor; blnSend = false;} else if (blnSend == true) objElement.style.backgroundColor = "";
		
				}
				if (objElement.type=="checkbox" )
				if(objElement.className.search(strPattern) == -1){
				  if(objElement.checked == false) {
					objElement.parentNode.style.backgroundColor = u1sercolor; blnSend = false;
				  } else if(objElement.checked == true) {
					objElement.parentNode.style.backgroundColor = "";
				  }
				}

				if (objElement.type=="radio" )
				if(objElement.className.search(strPattern) == -1){
					var boolRadio = false; 
					for(var z=0; z<objForm.elements[objElement.name].length; z++){
						if (objForm.elements[objElement.name][z].checked) {boolRadio = true; }
					}
				  if(boolRadio == false) {
					objElement.parentNode.style.backgroundColor = u1sercolor; blnSend = false;
				  } else if(boolRadio == true) {
					objElement.parentNode.style.backgroundColor = "";
				  }
				}
		  }
	  return blnSend;
}






function setTableDaemm(val3){
	$("#dm032").removeClass();
	$("#dm040").removeClass();
	if (val3==40){ 
		$("#dm040").addClass("gr_gray");
	}
	if (val3==32){ 
		$("#dm032").addClass("gr_gray");
	}
return;
}



function popup(b,gr_title)
{

for (var i=0; i<document.images.length; i++)
    if (document.images[i]==b) {break;}
a=document.images[i].src;
pic=new Image();
pic.src=a;
h=pic.height;
w=pic.width;

    t=(screen.height-h)/2;
    l=(screen.width-w)/2;

if (pic.width <= 0 || pic.height <= 0){
  setTimeout("popup_for_image('" + a + "');", 500);
//setTimeout("popup("+b+","+gr_title+");", 500);
}
else
{
var fenster2 = window.open('','','width='+w+',height='+h+',top='+t+',left='  +l+',location=no, statusbar=no, directories=no, resizable=no, menubar=no, toolbar=no, scrollbars=no');fenster2.focus();
if (gr_title="") gr_title="Bild";
fenster2.document.open();
fenster2.document.write("<html><head><title>"+gr_title+"</title></head><body leftmargin=0 topmargin=0 margindwidth=0 marginheight=0>");
fenster2.document.write("<img src="+a+">");
fenster2.document.write("</body></html>");
fenster2.document.close();
fenster2.focus();
}
}


function popup_for_image(a,gr_title)
{
pic=new Image();
pic.src=a;
h=pic.height;
w=pic.width;

    t=(screen.height-h)/2;
    l=(screen.width-w)/2;

if (pic.width <= 0 || pic.height <= 0){
  setTimeout("popup_for_image('" + a + "');", 500);
}
else
{
var fenster2 = window.open('','','width='+w+',height='+h+',top='+t+',left='  +l+',location=no, statusbar=no, directories=no, resizable=no, menubar=no, toolbar=no, scrollbars=no');fenster2.focus();
if (gr_title="") gr_title="Bild";
fenster2.document.open();
fenster2.document.write("<html><head><title>"+gr_title+"</title></head><body leftmargin=0 topmargin=0 margindwidth=0 marginheight=0>");
fenster2.document.write("<img src="+a+">");
fenster2.document.write("</body></html>");
fenster2.document.close();
fenster2.focus();
}
}


function schowhktbl(){
	if ($(window).width() > 1000 && $(window).height() > 770)
	tb_show("Heizkostentabelle", "UserFiles/File/hd/heizkosten_diagramm.php?height=690&width=610");
	else 
	tb_show("Heizkostentabelle", "UserFiles/File/hd/heizkosten_diagrammk.php?height=470&width=410");
	
//	$("#grboxmain").focus();

//	$("#TB_ajaxContent").focus();

//	alert("4");
	
}



$(document).ready(function(){




/*
$(body).keydown(
   function(e){
     var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
     alert(key);
   }
 );
}); 
*/

//$(".TB_window").keyup( function() { } );

		var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		
		// Check to see if the version meets the requirements for playback
		if (hasReqestedVersion) {
		}
		else {
		$("#grboxmain").before('<div style="position:absolute;right:10px;top:10px;background-color:#1cff51;font:12px Arial;padding:5px;">Bitte installieren Sie die aktuelle Version des Adobe-Flash-Players,</br>um alle Inhalte dieser Seite betrachten zu können.</br>Loggen Sie sich hierzu als Administrator ein!</br><a href="http://www.adobe.com/go/getflash/">Adobe-Flash-Player installieren...</a></div>');
		
		//document.write('<div style="position:absolute;right:10px;top:10px;background-color:#f00;">Bitte installieren Sie </div>');
		}


$(".transp").click(function() {
prjTbName= 	$(this).attr("name");
window.parent.gr_showtiny(	$(this).attr("id"),	$(this).attr("name"), prjTbName, $(this.previousSibling).attr("name"));
});


$(".transp").mouseover( function() { 
	$(this).fadeTo("fast", 0.6);
});
$(".transp").mouseout( function() { 
	$(this).fadeTo("fast", 0.0);

});



$(".prjmore").click( function() { 
window.location = "index.php?action=showprj"+"&pageid="+$("#pageid").val()+"&prjtbl="+$(this).attr("name")+"&id="+$(this).attr("id");
});


$('.gr_ruon').wrap('<div style="background:#95d139;"></div>');;
$('.gr_ruon').corner("round 5px").parent().css('padding', '1px').corner("round 5px");
$(".gr_ruon td").css({ padding: 5, width: "100%", height: "100%" });

o = document.getElementsByTagName("object");
for(i=0; i<o.length; i++) {
o[i].outerHTML = o[i].outerHTML;
}

$(".rollover").hover(function(){
  $(this).attr( 'src', 'UserFiles/neowall/info-material.gif');
},function(){
  $(this).attr( 'src', 'UserFiles/neowall/get_info_0.jpg');
});


$('.content_gray').wrap('<div class="content_gray_padder">&nbsp;</div>');;
$('.content_gray1').wrap('<div class="content_gray_padder">&nbsp;</div>');;



				$('#scroll_pane').jScrollPane();

$(".content_search").click( function() { 
document.suchen.submit();
});

$(".suchtext").click( function() { 
return false;
});


	$("form").submit( function() {
	  return formValidating(document.formID);
	 } );




});





var window_width;
var window_height;

//Fenstergröße und -breite feststellen
function window_extention()
{

var x,y;
var test1 = document.body.scrollHeight;
var test2 = document.body.offsetHeight;
if (test1 > test2) // all but Explorer Mac
{
	x = document.body.scrollWidth;
	y = document.body.scrollHeight;
}
else // Explorer Mac;
     //would also work in Explorer 6 Strict, Mozilla and Safari
{
	x = document.body.offsetWidth;
	y = document.body.offsetHeight;
}


window_width=x;
window_height=y;

}

function object_center (object){

l=window_width/2-450; if(l<0) l=50;
l=Math.round(l,0);

a=window_height/2-300; if(a<0) a=50; 
a=Math.round(a,0);
 document.getElementById(object).style.left = l+"px";
 document.getElementById(object).style.top =a+'px';
 document.getElementById(object).style.visibility ='visible';
}



function makeVisible(){
//$(".notvisible").fadeTo("slow", 1);

//$(".notvisible").slideDown("fast");

}
