jQuery(document).ready(function(){

});


function trim(sString){

  while (sString.substring(0,1) == ' '){
    sString = sString.substring(1, sString.length);
  }
  while (sString.substring(sString.length-1, sString.length) == ' ') {
    sString = sString.substring(0,sString.length-1);  
  }
  return sString;
} 



function makeCenter(layerName){
   offset_left = $(layerName).width() /2;
   offset_top  = $(layerName).height() /2;
   $(layerName).css("margin-left", "-" + offset_left + "px");
   $(layerName).css("margin-top", "-" + offset_top + "px");
}


function clearJSString(str){
  
  str = String(str);
  ret = str.replace(/&amp;/g,"&");
  
  return ret;
}




function isValidEmail( fieldValue ) {
	if ( /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+$/.test(fieldValue) )
		return true;

	return false;
}



function openWindow(url, width, height)
{
	
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;

	openpopup=window.open(url ,'','width='+width+',height='+height+',left='+left+',top='+top+',resizable=yes,scrollbars=yes,status=no');
	openpopup.opener.name='popup';
}


function openMetroPopup(url){
  width  = 670;
  height = 600; 
  openWindow(url, width, height);
  
  return false;
} 





// The next two functions comprise the text counting for a text box.  
// 
 function countCheck(countLimit) {
   if(document.frmCmt.comment.value.length > countLimit) {
     alert('Too many characters in the comment box!');
     document.frmCmt.comment.focus();
     return false;
   }
   else
     return true; 
}

function countText(countLimit) {
   var old = document.frmCmt.counter.value;
   document.frmCmt.counter.value=document.frmCmt.comment.value.length;
   if(document.frmCmt.counter.value > countLimit && old <= countLimit) {
     alert('Too many characters in the comment box!');
     if(document.styleSheets) {
       document.frmCmt.counter.style.fontWeight = 'bold';
       document.frmCmt.counter.style.color = '#ff0000'; } 
   }
   else if(document.frmCmt.counter.value <= countLimit && old > countLimit
     && document.styleSheets ) {
       document.frmCmt.counter.style.fontWeight = 'normal';
       document.frmCmt.counter.style.color = '#000000'; 
   } 
}
 





/* TEST CODE */

function popUpScrollWindow2 (URLStr, align, width, heightParam)
{
	if ( use_profilepopups == false ) {
		window.location.href = URLStr;
		return;
	}

	height = screen.height - 150;
	height = Math.min( height, heightParam );

/*	if(popUpWin){

		if(!popUpWin.closed) { popUpWin.close(); }
	}
*/
	if( align == 'center' ){

		var left = (screen.width/2) - width/2;
		var top = (screen.height/2) - height/2;
	}else if( align == 'top' ){

		var left = (screen.width/2) - width/2;
		var top = 0;
	}else{

		var left = 0;
		var top = 0;
	}

	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	popUpWin.opener.name="abc1";
}

	
  // reload anti spam image
  $(".reload_antispam").click(function () {
      var dte = new Date();
      atnsrc = $("#antispam_image").attr("src");
      $("#antispam_image").attr("src", atnsrc + dte.getTime());
      return false;
  }); 
  
 
  $(function() {
	
		if($("#suche").val()) {
			$("#suche").focus(function() {
				$(this).attr("value", "");
			});
		}
	  
		
		/*
		$("#to-promopartner").hover(
			function(){
				$(".to-promopartner-info").show();				
			},
			function() {
				$(".to-promopartner-info").hide();
			}
		);
		*/

  });

