 
var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n #masterdiv{ display:none;}')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var md = document.getElementById("masterdiv");
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
			md.style.display = "block";
			
		}else{
			el.style.display = "none";
			md.style.display = "none";
		}
	}
}
function Switch_D(obj, target){
	if(document.getElementById){
	var ar = document.getElementById(obj);
	var ta = document.getElementById(target);
		if(ar.checked == true){
	ta.disabled = false;				
		}
		else{
	ta.disabled = true;
		}
	}
}
function Switch_N(obj, target){
	if(document.getElementById){
	var ar = document.getElementById(obj);
	var ta = document.getElementById(target);
		if(ar.checked == true){
	ta.style.display = "block";				
		}
		else{
	ta.style.display = "none";
		}
	}
}

function IsNumeric(input){
    var RE = /^-{0,1}\d*\.{0,1}\d+$/;
    return (RE.test(input));
}

function TestValues() {
var filternick  = /^([\w-]+(?:\.[\w-]+)*)$/i;
var filtermail = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

var mail = document.getElementById("testmail");
var nick = document.getElementById("testnick");
var dtay = document.getElementById("testay");
var dtgun = document.getElementById("testgun");
var sifre = document.getElementById("testpass");
var ceps = document.getElementById("testceps");
var cep = document.getElementById("testcep");
var strmail = mail.value;
var strnick = nick.value;

var errors = document.getElementById("errors");

		if(!strnick.match(filternick) || !strmail.match(filtermail) || (dtay.value == "x" || dtgun.value == "x") || sifre.value.length < "6" || ceps.value == "x" || cep.value.length != 7 || !IsNumeric(cep.value)) {
	errors.innerHTML = "Hatalar Oluştu:";
			
	var msg = "- Kullanıcı Adınız Alfabetik Olmalıdır<br>";	
	var error1 = document.getElementById("error_nick");	
	
	var msg2 = "- Girdiğiniz Mail Geçersiz.<br>";			
	var error2 = document.getElementById("error_mail");

	var msg3 = "- Girdiğiniz Doğum Tarihi Geçersiz.";			
	var error3 = document.getElementById("error_dt");

	var msg4 = "- Şifreniz Min. 6 Karakter Olmalıdır.<br>";			
	var error4 = document.getElementById("error_pw");		

	var msg5 = "- Cep Telefonu Numaranız Geçersiz.<br>";			
	var error5 = document.getElementById("error_cep");
		
	if(!strnick.match(filternick)) {
	error1.innerHTML = msg;
	nick.select();
	}
	else {
	error1.innerHTML = "";		
	}	
	
	if(!strmail.match(filtermail)) {
	error2.innerHTML = msg2;
	}
	else {
	error2.innerHTML = "";		
	}	
	if(dtay.value == "x" || dtgun.value == "x") {
	error3.innerHTML = msg3;
	}
	else {
	error3.innerHTML = "";		
	}
	if(sifre.value.length < "6") {
	error4.innerHTML = msg4;
	}
	else {
	error4.innerHTML = "";		
	}
	if(ceps.value == "x" || cep.value.length != 7 || !IsNumeric(cep.value)) {
	error5.innerHTML = msg5;
	}
	else {
	error5.innerHTML = "";		
	}			
	
		}
		else {
		errors.innerHTML = "";
		document.new_member.submit();	
		}
		
		
}

function checkemail(){
var str = document.getElementByName("mail").value
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true
else{
alert("Lütfen Geçerli Bir Mail Adresi Giriniz !")
testresults=false
}
return (testresults)
}
function checkbae(){
if (document.layers||document.getElementById||document.all)
return checkemail()
else
return true
}

//Time in days to save form fields values after last visit
//Set to different value to reset cookie (ie: "101 days" instead of "100 days"):
var memoryduration="100 days"

function setformobjects(){
var theforms=document.forms
memorizearray=new Array()
for (i=0; i< theforms.length; i++){
for (j=0; j< theforms[i].elements.length; j++){
if (theforms[i].elements[j].className.indexOf("memorize")!=-1 && theforms[i].elements[j].type=="text")
memorizearray[memorizearray.length]=theforms[i].elements[j]
}
}
var retrievedvalues=get_cookie("mvalue"+window.location.pathname)
if (retrievedvalues!=""){
retrievedvalues=retrievedvalues.split("|")
if (retrievedvalues[retrievedvalues.length-1]!=parseInt(memoryduration)) //reset cookie if var memoryduration has changed
resetcookie("mvalue"+window.location.pathname)
else{
for (i=0; i<memorizearray.length; i++){
if (retrievedvalues[i]!="empty_value")
memorizearray[i].value=retrievedvalues[i]
}
}
}
}

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      end = document.cookie.indexOf(";", offset);
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function resetcookie(id){
var expireDate = new Date()
expireDate.setDate(expireDate.getDate()-10)
document.cookie = id+"=;path=/;expires=" + expireDate.toGMTString()
}

function saveformvalues(){
var formvalues=new Array(), temp
for (i=0; i<memorizearray.length; i++){
temp=memorizearray[i].value!=""? memorizearray[i].value : "empty_value"
formvalues[formvalues.length]=escape(temp)
}
formvalues[formvalues.length]=parseInt(memoryduration)
formvalues=formvalues.join("|")
var expireDate = new Date()
expireDate.setDate(expireDate.getDate()+parseInt(memoryduration))
document.cookie = "mvalue"+window.location.pathname+"="+formvalues+"; path=/;expires=" + expireDate.toGMTString()
}

if (window.addEventListener)
window.addEventListener("load", setformobjects, false)
else if (window.attachEvent)
window.attachEvent("onload", setformobjects)
else if (document.getElementById)
window.onload=setformobjects
if (document.getElementById)
window.onunload=saveformvalues


function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

// ***** at_click *****

function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

// ***** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}
function cikissor() {
	var soru = "Gerçekten Çıkış Yapmak İstiyor musunuz?";
	var grayscale = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
	var ht = document.getElementsByTagName("body")[0];	
	var sbox = document.getElementsByTagName("select");
	ht.style.filter = grayscale;
	for(var i = 0; i < sbox.length; i++) {
	sbox[i].style.background = "#8E8E8E";
	}
if(confirm(soru)) {
location = "cikis.php";
}
else {
	ht.style.filter = "";
	for(var i = 0; i < sbox.length; i++) {
	sbox[i].style.background = "#515151";
	}
}

}

function confirm_del_msg() {
msg = "Bu Mesajı Silmek istediğinizden Emin Misiniz?";
if(confirm(msg)) {
document.msg_del.submit();
}
}


function switch_img(src, desc) {
var img = document.getElementById("photo");
var description = document.getElementById("desc");
img.src = src;
description.innerHTML = desc;

}

function change_p(formname) {
document.formname.submit();
}

function remove_photo(id) {
var msg = "Bu Fotoğrafı Silmek istediğinizden emin misiniz?";
if(confirm(msg)) {
var loc = "/resimler.php?resim=sil&id=" + id;
location = loc;
} 
}

function sil_onay_arkadas(nick) {
var msg = "Bu Kişi ile Arkadaşlığınızı Bitirmek istediğinizden Emin Misiniz?";
if(confirm(msg)) {
var loc = "arkadaslar/sil/" + nick;
location = loc;
} 
}
function profil_ata_onay(id, pid) {
var msg = "Bu Fotoğrafı Profil Resmi Olarak Ayarlamak istediğinizden Emin Misiniz?";
if(confirm(msg)) {
var loc = "resimler/degistir/" + id + "-" + pid;
location = loc;
} 
}
function teklif_check(user) {
	var msg = "Bu kullanıcı sadece arkadaşlarından mesaj almak istiyor.\nBu Kullanıcı ile Arkadaş olmalısınız.\n\nŞimdi arkadaşlık teklif et?";
	if(confirm(msg)) {
	var loc = "teklifler/yeni/" + user;
	location = loc;	
	}
	else {
		return false;
	}
}
function setsmil(ktery,content) {

  var areas = document.getElementsByTagName('textarea');
  for (var i = 0; ar = areas[i]; i++) {
    if (ar && ar.getAttribute('id') == ktery) {

      // Insert the code
      /* IE */
      if (document.selection) {
        ar.focus();
        cursor = document.selection.createRange();
        cursor.text = content + " ";
   
      } else if (ar.selectionStart || ar.selectionStart == "0") { /* Gecko-based engines: Mozilla, Camino, Firefox, Netscape */
        var startPos  = ar.selectionStart;
        var endPos    = ar.selectionEnd;
        var body      = ar.value;
        ar.value = body.substring(0, startPos) + content + body.substring(endPos, body.length);
   
      } else { /* Worst case scenario: browsers that don't know about cursor position, Safari, OmniWeb, Konqueror */
        ar.value += content + " ";
      }

    } 
  }
}
function checkcomment() {
	var el = document.yorum_ekle.mesaj;
	if(el.value.length < 5) {
	alert("Lütfen minimum 5 Karakter yazınız.")
	return false;
	}
	else {
	document.yorum_ekle.submit();	
	}
}
function seffaf_y(obj, par) {

var mozop = par;
var strength = par * 100;

obj.style.MozOpacity = mozop;
obj.filters.alpha.opacity = strength;


}
function select_o(obj) {
var get = obj;	
var el = document.getElementById(obj);
var hotm = document.getElementById("msnx");
var gma = document.getElementById("gmailx");
var yaho = document.getElementById("yahoox");
var dom = document.getElementById("domain");
var type = document.getElementById("typex");
type = get;
	
if(get == "msn") {
hotm.style.border = '3px solid #FFFFFF';
dom.innerHTML = "hotmail.com";	

		if(gma.style.border || yaho.style.border) {
	if(gma.style.border) {
	gma.style.border = "";
	}
	else {
	yaho.style.border = "";
	}	
		} 		
}
if(get == "gmail") {
gma.style.border = '3px solid #FFFFFF';	
dom.innerHTML = "gmail.com";	
		if(hotm.style.border || yaho.style.border) {
	if(hotm.style.border) {
	hotm.style.border = "";
	}
	else {
	yaho.style.border = "";
	}	
		} 		
}
if(get == "yahoo") {
yaho.style.border = '3px solid #FFFFFF';
dom.innerHTML = "yahoo.com";		
		if(gma.style.border || hotm.style.border) {
	if(gma.style.border) {
	gma.style.border = "";
	}
	else {
	hotm.style.border = "";
	}	
		} 		
}	
	
}
function checkdavet() {
var filternick  = /^([\w-]+(?:\.[\w-]+)*)$/i;	
var strun = document.getElementById("usernamex").value;
var pw = document.getElementById("passwordx").value;
var msg = "E-Posta Adresini Kontrol Ediniz.";
var msg2 = "Şifreniz Min. 6 Karakter Olmalıdır.";

if(!strun.match(filternick) || pw.length < 6) {
		if(!strun.match(filternick) && pw.length < 6) {
		alert(msg + "\n\n" + msg2);
		}
		else if(!strun.match(filternick)) {
		alert(msg);
		}
		else if(pw.length < 6) {
		alert(msg2);
		}	
}
else {
	document.davet.submittin.value = 'Bekleyiniz..';
	document.davet.submittin.disabled = 'true';
	document.davet.submit();
}	
}
function konugir() {
	var select = document.getElementById("konutype");
	var konugir = document.getElementById("konugir");
	if(select.value == "6") {
	konugir.innerHTML = "<br><br>Konuyu Giriniz: <input type=\"textbox\" name=\"manualkonu\" class=\"textbox\" size=\"50\"><br>";	
	}
	else {
	konugir.innerHTML = "";	
	}
}

function popupwindow(url) {

window.open(url, 'Chat', 'width=600, height=500, status=no, location=no, toolbar=no, scrollbars=yes');

}

function offpopupwindow(url) {
var msg = "Bu üye şuanda çevrimdışı.Yinede sohbet penceresini açmak istiyor musunuz?";
if(confirm(msg)) {
window.open(url, 'Chat', 'width=600, height=500, status=no, location=no, toolbar=no, scrollbars=yes');
}
}