﻿// JScript-Datei
	ieupdate = function(){
		var strBrowser = navigator.userAgent.toLowerCase();
		if (strBrowser.indexOf("msie") > -1 && strBrowser.indexOf("mac") < 0) {
			var theObjects = document.getElementsByTagName('object');
			var theObjectsLen = theObjects.length;
			for (var i = 0; i < theObjectsLen; i++) {
				if (theObjects[i].outerHTML) {
					if (theObjects[i].data) {
						theObjects[i].removeAttribute('data');
					}
					var theParams = theObjects[i].getElementsByTagName("param");
					var theParamsLength = theParams.length;
					for (var j = 0; j < theParamsLength; j++) {
						if (theParams[j].name.toLowerCase() == 'flashvars') {
							var theFlashVars = theParams[j].value;
						}
					}
					var theOuterHTML = theObjects[i].outerHTML;
					var re = /<param name="FlashVars" value="">/ig;
					theOuterHTML = theOuterHTML.replace(re, "<param name='FlashVars' value='" + theFlashVars + "'>");
					//theObjects[i].outerHTML = 'Hallo';//theOuterHTML;
				}
			}
		}
		if (dojo.byId("hddLoggedIn").value=="0")
			$("#divPassword").hide();
	}
	resetError = function() {
		for(i = 0;i<6;++i) {
			$("#err"+i).hide();
		}
	}
	fromFlash = function(md5) {
        $("#errorCaptcha").hide();
		var txtName = dojo.byId("txtName").value;
		var txtPassword = dojo.byId("txtPasswort").value;
		var txtChatname = dojo.byId("divChatname").value;
		var txtEmail = dojo.byId("txtEmail").value;
		var ddlProblem = dojo.byId("ddlProblem").value;
		var txtMessage = dojo.byId("txtMessage").value;
		var valid = true;
		
		if (txtName=="") {
			valid = false;
			$("#err0").show();
		} 
		if (txtPassword=="" && dojo.byId("hddLoggedIn").value!="0") {
			valid = false;
			$("#err2").show();
		} 
		if (txtEmail=="") {
			valid = false;
			$("#err1").show();
		}
 		if (!isEmail(txtEmail)) {
			valid = false;
			$("#err5").show();
		}
		if (ddlProblem=="") {
			valid = false;
			$("#err3").show();
		} 	
		if (txtMessage=="") {
			valid = false;
			$("#err4").show();
		} 					
		
		if (valid)
			$("#divKontakt").load("/gc/Static/Services/Kontakt.aspx",{
				action:"sendMail",
				checksum:md5,
				name:txtName,
				password:txtPassword,
				chatname:txtChatname,
				email:txtEmail,
				problem:ddlProblem,
				message:txtMessage,
				closeButton: false,
                height:118
			});
	}
flashError = function() {
    $("#errorCaptcha").show();
}
isEmail = function(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
	}




