function checkfirst(input){
  var found = false;
  var str="0123456789";
  for (var i = 0;i<str.length;i++){
    if (input.charAt(0) == str.charAt(i)) found = true;
  }
  return found;
}
function checksecond(input){
  var found = false;
  var str="öÖçÇıİşŞğĞüÜ/*+!%&()=?<>£#$½~¨@,;:.€é ";  
  str = str + "'";
  str = 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 validateForm(isim,channame) {
	if (isim=="") alert("Odaya girmek için rumuz girmelisiniz");
	else if (checkfirst(isim)) alert("Hatalı rumuz girdiniz.\nRumuz rakamla başlayamaz");
	else if (isim.charCodeAt(0) == 45) alert("Hatalı rumuz girdiniz.\nRumuz \" - \" işareti ile başlayamaz");
	else if (checksecond(isim)) alert("Hatalı rumuz girdiniz.\nLütfen boşluk ve Türkçe karakter kullanmayınız");
	else{
	document.SohbetForm.channame.value = channame;
	document.SohbetForm.submit();
	}
}
function check(input){
  var found = false;
  var str1="0123456789-";
  for (var i = 0;i<str1.length;i++){
    if (input.charAt(0) == str1.charAt(i)) found = true;
  }
  if (!found){
  	var str2="öÖçÇıİşŞğĞüÜ/*+!%&()=?<>£#$½~¨@,;:.€é ";  
  	str2 = str2 + "'";
  	str2 = str2 + '"';
	for (var i = 0;i<input.length;i++)
		for (var j = 0;j<str2.length;j++)
			if (input.charAt(i) == str2.charAt(j)) found = true;
  }
  return found;
}
function checkforOda(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 ignore(){
   if (self.document.cr.getSelectedUser()=="")
       alert("Özel sohbet etmek istemediğiniz kullanıcıyı fareyle\nişaretledikten sonra Engelle butonuna basmalısınız");
   else
       self.document.cr.output("/silence "+self.document.cr.getSelectedUser());
}       
function changeNick(){
	nick=prompt("Yeni rumuz giriniz: ( Türkçe karakter kulanmayınız )\n* Genel odalar içindeyken rumuz değiştiremezsiniz","");
	if(nick && nick!=null && nick!="null" && nick!=""){
		if (check(nick)) {
			alert("Hatalı rumuz girdiniz.\nLütfen boşluk ve Türkçe karakter kullanmayınız");
		}
		else{
			self.document.cr.nick(nick);
		}
	}
}	      
function openRoom(name,topic){
   if (name=="") {
                alert("Oda ismini girmelisiniz");
   }			
   else if (checkforOda(name)) {
			alert("Oda ismini hatalı girdiniz.\nLütfen boşluk ve Türkçe karakter kullanmayınız");
   }	
   else{
         self.document.cr.room("#"+name);
         self.document.cr.output("/topic #"+name+" "+topic);
   }    
}
function oda(){
		var popupWindow = null;
        popupWindow=window.open("/openroom/","popupWindow","width=225,height=120,status=no,toolbar=no,menubar=no,directories=no,location=no,scrollbars=no,resizable=no,titlebar=yes,left=350,top=250,screenX=300,screenY=250,alwaysRaised=yes,z-lock=yes");
		if (popupWindow != null) {
            if (popupWindow.opener == null) {
                popupWindow.opener = self;                
            }
		popupWindow.focus();		      
        }
}
function odamynet(){
        var popupWindowsohbetler = null;
        popupWindowsohbetler=window.open("/popuproom/","popupWindowsohbetler","width=420,height=300,status=no,toolbar=no,menubar=no,directories=no,location=no,scrollbars=yes,resizable=no,titlebar=yes,left=350,top=250,screenX=300,screenY=250,alwaysRaised=yes,z-lock=yes");
        if (popupWindowsohbetler != null) {
            if (popupWindowsohbetler.opener == null) {
                popupWindowsohbetler.opener = self;           
            }
		popupWindowsohbetler.focus();				
        }
}
function odaozel(){
        var popupWindowsohbetler=null;
        popupWindowsohbetler=window.open("/popuproom/rooms.asp?isPrivate=true","popupWindowsohbetler","width=420,height=300,status=no,toolbar=no,menubar=no,directories=no,location=no,scrollbars=yes,resizable=no,titlebar=yes,left=350,top=250,screenX=300,screenY=250,alwaysRaised=yes,z-lock=yes");
        if (popupWindowsohbetler != null) {
            if (popupWindowsohbetler.opener == null) {
                popupWindowsohbetler.opener = self;           
            }
		popupWindowsohbetler.focus();				
        }
}
function joinMynetOda(roomName){
        document.cr.output("/join #"+roomName);
}
function popup(url){
	var yenipencere = null;	
	yenipencere=window.open(url,'yenipencere','width=550,height=300,status=no,toolbar=no,menubar=no,directories=no,location=no,scrollbars=yes,resizable=yes,alwaysRaised=yes,screenX=20,screenY=5,titlebar=yes,z-lock=yes,left=20,top=130');
	yenipencere.location.href=url;
	if (yenipencere != null) {
	    if (yenipencere.opener == null){
	    	yenipencere.opener = self;		
		}
	yenipencere.focus();	
	}
}
function changeAvatar(avatar){
	document.cr.output('/set ' + document.cr.nick() + ' avatar ' + avatar);
}
function selectActions(s){
	if(s != ""){
		if(s.substring(0,2) == "%u"){
			if(document.cr.getSelectedUser() != "") document.cr.output('/ACTION ' + document.cr.getSelectedUser() + s.substring(2));
			else alert("Lütfen önce birini seçiniz");
		}
		else document.cr.output('/ACTION ' + s );
	}
	document.cr.insert('');
}
function selectSounds(s){
	if(s != "") document.cr.output('/SOUND ' + s );
	document.cr.insert('');
}
function selectPics(s){
	if(s != "") document.cr.insert(String.fromCharCode(5) + s + String.fromCharCode(5));
}