function ignoreSpaces(string){
	var temp = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++) temp += splitstring[i];
	return temp;
}

function emptyStringControl(str){
	if(ignoreSpaces(str).length==0) return true;
	else return false;
}

function checkatsign(input){
	var found = false;
	var str = "@";
	for (var i = 0;i<input.length;i++)
			for (var j = 0;j<str.length;j++)
				if (input.charAt(i) == str.charAt(j)) found = true;
	return found;
}

function checkfirst(input){
	var found = false;
	var str = " \u00F6\u00F6\u00E7\u00C7\u0131\u0130\u015F\u015F\u011F\u011E\u00FC\u00DCé<!>'£^#+$%½&/{([)]=}?\"*\\|@?¨~´`,;:";
	for (var i = 0;i<input.length;i++)
			for (var j = 0;j<str.length;j++)
				if (input.charAt(i) == str.charAt(j)) found = true;
	return found;
}

function validate(){
	var user = document.lform.u.value;
	var pwd = document.lform.p.value;
	SetRememberanceBoxes();
	if (emptyStringControl(user)) {
		alertMessage.tur=1;
		alertMessage.init("\u00DCye ad\u0131n\u0131z\u0131 giriniz");
		return false;
	}else if (checkatsign(user)) {
		alertMessage.tur=1;
		alertMessage.init("\u00DCye Ad\u0131 Mynet Email adresinizin @ i\u015Faretinden \u00F6nceki k\u0131sm\u0131d\u0131r");
		return false;
	}else if (checkfirst(user)) {
		alertMessage.tur=1;
		alertMessage.init("\u00DCye ad\u0131 hatal\u0131");
		return false;
	}else if (emptyStringControl(pwd)){
		alertMessage.tur=2;
		alertMessage.init("Lütfen \u015Fifrenizi giriniz");
		return false;
	}else {
		return true;
	}
}

function SetRememberanceBoxes(){
	if(document.lform.rp.checked){
		document.lform.rememberstate.value='2';
	}
}

function LogIn(){
	 lsuserName = document.lform.u.value;
	 if(validate()){
       	var url = "https://uyeler.mynet.com/index/loginjso.jsp?nameofservice=bar&ax="+document.lform.u.value+"&rememberstate="+document.lform.rememberstate.value+"&cf=ProcessLogin";
     	my_l.setCookie("mpltoemailp", hex_mymd(document.lform.p.value), 0 , "/", ".mynet.com", false);
		my_l.jsimport(url);
		alertMessage.open("L\u00FCtfen Bekleyin");
   }
	return false;
}

function ProcessLogin(lstatus,murl){
	my_l.setCookie("mpltoemailp","",0,"/", ".mynet.com");
	if(lstatus == "1"){
		alertMessage.close();
		j("#loginhtm").fadeOut("slow", 
			function(){
				if(window.location.host === 'www.mynet.com'){
					j("#loginhtm").css({opacity:1});
					j("#loginhtm").fadeIn('slow');
					htmlLogin.my_l_html();
					html.countwrite();
				}else{
					j("#loginhtm").fadeIn('slow');
					alertMessage.open("L\u00FCtfen Bekleyin");
					window.location.reload();
				}
		});
			
	}else if(lstatus == "-1"){
		alertMessage.close();
		window.setTimeout( function(){ alertMessage.init("Hatal\u0131 Kullan\u0131c\u0131 Ad\u0131/\u015Fifre") },300);
	}else if(lstatus == "-2"){
		document.location.href = "http://uyeler.mynet.com/login/login.asp?loginRequestingURL=http%3A%2F%2Feposta.mynet.com%2Findex%2Fmymail.html&formname=eposta&shim=1";
	}else{
		document.location.href = "http://uyeler.mynet.com/login/?loginRequestingURL=http%3A%2F%2Feposta.mynet.com%2Findex%2Fmymail.html&formname=eposta";
	}
}

var alertMessage = {
	tur:0,
	msopacity:0.5,
	init:function(message){
		j("#loginhtm").css({ opacity:this.msopacity});
		j("#loginhtm").prepend("<div id='mylyukleniyor'></div>");
		j("#mylyukleniyor").prepend(message);
		
		j("#mylyukleniyor").fadeOut(4000, function(){ 
			j("#mylyukleniyor").remove();
			j("#loginhtm").css({opacity:1});
			if(alertMessage.tur === 1){
				j("#loginuser").focus();
			}else if(alertMessage.tur === 2){
				j("#loginpassword").focus();
			}			
		});
	},
	open:function(message){
		j("#loginhtm").css({ opacity:this.msopacity});
		j("#loginhtm").prepend("<div id='mylyukleniyor'></div>");
		j("#mylyukleniyor").prepend(message);
	},
	close:function(message){
		j("#mylyukleniyor").fadeOut("fast", function(){ 
			j("#mylyukleniyor").remove();
			j("#loginhtm").css({opacity:1});
			
			if(alertMessage.tur === 1){
				j("#loginuser").focus();
			}else if(alertMessage.tur === 2){
				j("#loginpassword").focus();
			}			
		});
	}
}
