/*******************************************************************************
 FOS (Flash Oyun Scripti - Flash Games Script)
 Copyright (C) 2008 Taylan Aktepe (taylanaktepe@yahoo.com)

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 More Info About The Licence At http://www.gnu.org/copyleft/gpl.html 
 ---
 Görüş ve düşünceleriniz ile destek/yardım için ziyaret edebileceğiniz 
 siteler,
    - Taylan Aktepe Blog (http://www.taylanaktepe.com)
    - Taylan Aktepe Forum (http://www.taylanaktepe.com/forum/)
 ---
 Dosya Açıklaması fos-javascripts/main.js
    - Genel JavaScripts.
 ---
 Dosyaya Ait Güncelleme Notları fos-javascripts/main.js
    - Henüz güncelleme yapılmadı - 17 Eylül 2008
*******************************************************************************/ 

/**
 * versiyon 1.0
 * checkSearch() 
 * Arama formu için girdi kontrolü.
 */ 
  function checkSearch() { 
    var fosterms;
	  with(window.document.searchform) {
		  fosterms = s;
    }
    if(trim(fosterms.value) == '') {
		  alert('Lütfen aranacak kelimeleri yazınız!');
		  fosterms.focus();
		  return false;
	  } else {
      fosterms.value = trim(fosterms.value);
      return true;
    }	  
  }

/**
 * versiyon 1.0
 * checkLogin() 
 * Üye giriş formu için girdi kontrolü.
 */ 
  function checkLogin() { 
    var fosusername, fospassword;
	  with(window.document.loginform) {
		  fosusername = username;
		  fospassword = password;
    }
    if(trim(fosusername.value) == '') {
		  alert('Lütfen kullanıcı adınızı yazınız!');
		  fosusername.focus();
		  return false;
	  } else if(trim(fospassword.value) == '') {
		  alert('Lütfen şifrenizi yazınız!');
		  fospassword.focus();
		  return false;
	  } else {
      fosusername.value = trim(fosusername.value);
      fospassword.value = trim(fospassword.value);
      return true;
    }
  }
  
/**
 * versiyon 1.0
 * checkRegister() 
 * Yeni üye formu için girdi kontrolü.
 */ 
  function checkRegister() { 
    var fosusername, fospassword, fospassapprove, fossecuritycode;
	  with(window.document.registerform) {
		  fosusername = username;
		  fospassword = password;
		  fospassapprove = pass_approve;
      fossecuritycode = securitycode;
    }
    if(trim(fosusername.value) == '') {
		  alert('Lütfen kullanıcı adınızı yazınız!');
		  fosusername.focus();
		  return false;
	  } else if(trim(fospassword.value) == '') {
		  alert('Lütfen şifrenizi yazınız!');
		  fospassword.focus();
		  return false;
		} else if(trim(fospassapprove.value) == '') {
		  alert('Lütfen şifrenizi onaylayınız!');
		  fospassapprove.focus();
		  return false;
		} else if(trim(fossecuritycode.value) == '') {
		  alert('Lütfen güvenlik kodunu yazınız!');
		  fossecuritycode.focus();
		  return false;
	  } else {
      fosusername.value = trim(fosusername.value);
      fospassword.value = trim(fospassword.value);
      fospassapprove.value = trim(fospassapprove.value);
      fossecuritycode.value = trim(fossecuritycode.value);
      return true;
    }
  }
  
/**
 * versiyon 1.0
 * checkComment() 
 * Yorum formu için girdi kontrolü.
 */ 
  function checkComment() {
	  var fosname, fosemail, foscomment, foscodes;
	  with(window.document.commentform) {
		  fosname    = name;
		  fosemail   = email;
		  foscomment = comment;
		  foscodes = securitycode;
    }
	
	  if(trim(fosname.value) == '') {
		  alert('Lütfen adınızı yazınız!');
		  fosname.focus();
		  return false;
	  } else if(trim(fosemail.value) == '') {
		  alert('Lütfen e-posta adresinizi yazınız!');
		  fosemail.focus();
		  return false;
	  } else if(!isEmail(trim(fosemail.value))) {
		  alert('E-posta adresiniz doğrulanamadı. Lütfen kontrol ediniz!');
		  fosemail.focus();
		  return false;
	  } else if(trim(foscomment.value) == '') {
		  alert('Lütfen yorum yazınız!');
		  foscomment.focus();
		  return false;
	  } else if(trim(foscodes.value) == '') {
		  alert('Lütfen güvenlik kodunu giriniz!');
		  foscodes.focus();
		  return false;
	  } else {
		  fosname.value    = trim(fosname.value);
		  fosemail.value   = trim(fosemail.value);
		  foscomment.value = trim(foscomment.value);
		  foscodes.value = trim(foscodes.value);
		  return true;
	  }
  }
  
/**
 * versiyon 1.0
 * checkRating() 
 * Puan formu için girdi kontrolü.
 */ 
  function checkRating() { 
    var fosrate;
	  with(window.document.ratingform) {
		  fosrate = rate;
    }
    if(trim(fosrate.value) == '') {
		  alert('Lütfen vermek istediğiniz puanı seçiniz!');
		  fosrate.focus();
		  return false;
	  } else {
      fosrate.value = trim(fosrate.value);
      return true;
    }
  }

/**
 * versiyon 1.0
 * trim() 
 * Boşlukların kaldırılması.
 */ 
  function trim(str) {
	  return str.replace(/^\s+|\s+$/g,'');
  }

/**
 * versiyon 1.0
 * isEmail() 
 * E-posta adresi kontrolü.
 */ 
  function isEmail(str) {
    var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
    return regex.test(str);
  }

/**
 * Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
 * This notice must stay intact for legal use.
 * Visit http://www.dynamicdrive.com/ for full source code
 */
  function ismaxlength(obj){
    var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
    if (obj.getAttribute && obj.value.length>mlength)
      obj.value=obj.value.substring(0,mlength)
  }

/**
 * versiyon 1.0
 * clearText()
 * Girdi alanlarını temizleme.
 */ 
  function clearText(thefield){
    if (thefield.defaultValue==thefield.value)
    thefield.value = ''
  }

/**
 * versiyon 1.0
 * fullwin() 
 * Tam ekran oynama.
 */  
  function fullwin(targeturl){
    newwin = window.open(targeturl, "_blank", "Width=1280,Height=1024, titlebar=no, location=no, resizable=no, channelmode=no, directories=no, status=no, scrollbars=0, fullscreen=yes");
    newwin.moveTo(0, 0);
  }

