﻿    function popupWindow (txt) {
	var emailID=txt;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
        alert("Please Enter valid Email ID")
		emailID.value="";
		emailID.focus();
		return false
	}
    window.open('SubscribeNewsletter.aspx?email=' + escape(emailID.value), 'popUpWindow', 'height=100,width=200,left=20,top=50,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no');
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    
		    return false
		 }

 		 return true					
	}

	/**
	*
	*  Javascript trim, ltrim, rtrim
	*  http://www.webtoolkit.info/
	*
	**/

	function trim(str, chars) {
	    return ltrim(rtrim(str, chars), chars);
	}

	function ltrim(str, chars) {
	    chars = chars || "\\s";
	    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
	}

	function rtrim(str, chars) {
	    chars = chars || "\\s";
	    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
	}

	function cseBoxEmpty(t) {
	    if (trim(t) == "") {
	        alert("Bitte Suchbegriff eingeben");
            return false;
        }
        else {
            return true;
        }
    }

