/*
TASARIM ANINDA VERİLEN YÜKSELİK, GENİŞLİK VE SOL/ÜST BİLGİLERİNİN KULLANICININ EKRANINA GÖRE YENİDEN UPDATE EDİLMESİNİ SAĞLAYAN
FONKSİYONLAR...
*/
function moveElement(id, x, y)
{
  // move the element with id to x,y
  // where x,y are the horizontal
  // and vertical position in pixels

  var elm = null;
  if (document.getElementById)
  {
    // browser implements part of W3C DOM HTML
    // Gecko, Internet Explorer 5+, Opera 5+
    elm = document.getElementById(id);
  }
  else if (document.all)
  {
    // Internet Explorer 4 or Opera with IE user agent
    elm = document.all[id];
  }
  else if (document.layers)
  {
    // Navigator 4
    elm = document.layers[id];
  }

  if (!elm)
  {
    // browser not supported or element not found
  }
  else if (elm.style)
  {
    // browser implements part of W3C DOM Style
    // Gecko, Internet Explorer 4+, Opera 5+

    if (typeof(elm.style.left) == 'number')
    {
      // Opera 5/6 do not implement the standard correctly
      // and assume that elm.style.left and similar properties
      // are numbers.
	  if(x!=0)
      	elm.style.left = x;
	  if(y!=0)
      elm.style.top  = y;
    }
    else
    {
      // Gecko/Internet Explorer 4+
      // W3C DOM Style states that elm.style.left is a string
      // containing the length followed by the unit. e.g. 10px
      // Gecko will allow you to omit the unit only in Quirks 
      // mode. 
      // Gecko REQUIRES the unit when operating in Standards
      // mode.
	  if(x!=0)
      	elm.style.left = x + 'px';
	  if(y!=0)
      elm.style.top  = y + 'px';
    }
  }
  else if (typeof(elm.left) == 'number')
  {
    // Navigator 4
	if(x!=0)
    elm.left = x;
	if(y!=0)
    elm.top  = y;
  }
}

function textWidth() {
    if (document.layers)
        alert('1width = ' + document.layers['Layer_main'].document.width + ' height = ' + document.layers['Layer_main'].document.height);
    else if (document.all)
        alert('2width = ' + document.all['Layer_main'].clientWidth + ' height = ' +  document.all['Layer_main'].clientHeight);
}

function showLayer(layer_divid,layer_ma,ekran) {
	yuk=ekran-322; //322:Layer_govde yuksekligi
	if (document.layers){ // NS 4
		document.layers[layer_divid].height = yuk+"px";
		document.layers[layer_ma].height = ekran+"px";
	} else if (document.all){ // ie
		document.all(layer_divid).style.height = yuk+"px";
		document.all(layer_ma).style.height = ekran+"px";
	} else if (document.getElementById){ // NS 6+
		document.getElementById(layer_divid).style.height = yuk+"px";
		document.getElementById(layer_ma).style.height = ekran+"px";
	}
}

function stil(layer_divid,vis) {
	if (document.layers){ // NS 4
		document.layers[layer_divid].visibility = vis;
	} else if (document.all){ // ie
		document.all(layer_divid).style.visibility = vis;
	} else if (document.getElementById){ // NS 6+
		document.getElementById(layer_divid).style.visibility = vis;
	}
}


function formatPageView() {
	var e=document.getElementsByTagName("div");
	var mainDiv=e["Layer_main"]; //ana layer
	var footerDiv=e["Layer_footer"]; // footer layer
	var reklamDiv=e["Layer61"];
	
	var sizes=getWindowSizes();

	var sw=sizes.split(",")[0]; //kullanıcının ekran genişliği
	var sh=sizes.split(",")[1]; //kullanıcının ekran yüksekliği
	
	

	to_x=(sw-920)/2;
	moveElement("Layer_main", to_x, 0);

	a_to_x=(sw-792)/2;
	kalan_x=(a_to_x-160)/2;
	
	var dosya=document.URL; //http://www.kod1.net/index-tr.htm
	var mdH=mainDiv.offsetHeight; //ana layer.ın tasarımlanmış yüksekliği=1.477
	var footerH=footerDiv.offsetHeight; //ana layer.ın tasarımlanmış yüksekliği, 43px
	if(dosya=='http://www.kod1.net/index-tr.htm' || dosya=='http://kod1.net/index-tr.htm') {
		footerTop=mdH-footerH-140; //1.434, 97:Layer_yazi'nin Top.ı
		wh_layer="Layer61";
	} else {
		footerTop=mdH-footerH-540; //1.434, 97:Layer_yazi'nin Top.ı
		wh_layer="Layer56";
	}

	
	if(sw>1024) {
		stil(wh_layer,"visible");
		moveElement(wh_layer, kalan_x, 0);
	} else {
		stil(wh_layer,"hidden");
		//reklamDiv.style.display="none";
	}

	moveElement("Layer_footer", 0, footerTop);
	
/*
	
	
	
	
	if(mdH<sh) { //ana_layer, ekran yüksekliğinden küçükse, onu uzat..
		showLayer("Layer_yatay_thin","Layer_main",sh);
	}
	moveElement("Layer_footer", 0, footerTop);
	//alert(footerTop+"\n"+footerH);
*/
/*	
	mainDiv.style.left=(sw-920)/2; //ana layer.ı ekranda ortala

	var forFooter=mainDiv.offsetHeight;
	ft=(forFooter-223); //176=footer_layer.ının yüksekliği
	footerDiv.style.top=ft+"px"; //footer.ı en alta yerleştir..
*/
	return true;
}
//*******************************************************************************************************************
function getWindowSizes() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return (myWidth+","+myHeight);
}
//*******************************************************************************************************************
function logMe() {
	var myform=document.forms["logger_form"];
	var uname=myform.username.value;
	var psw=myform.password.value;
	if(charChecker(uname)=="A" && charChecker(psw)=="A") {
		myform.submit();
		var tt=setTimeout("reloader();",1700);
	} else {
		alert("Lütfen Kullanıcı Adı ve Şifrenizi kontrol ediniz.\nPlease check your Username and password");
		return false;
	}
}
//*******************************************************************************************************************
function charChecker(myWord) {
	var yasaklar=";,:,|,=,&,%,+,!,^,/,(,),*,-,#,$,{,[,],},\\,@,<,>,\',~";
	var yasak_arr=yasaklar.split(",");
	
	if(myWord=="") return "B";

	for(i=0;i<yasak_arr.length;i++) {
		var ch=yasak_arr[i];
		if(myWord.indexOf(ch)>0) {
			return "B";
			break;
		}
	}
	
	return "A";
}
//*******************************************************************************************************************
function reloader() {
	window.location.reload();
}
//*******************************************************************************************************************
function logOut(sid) {
	var myfrm=document.getElementById('logger_frm');
	var murl="http://www.kod1.net/forum/ucp.php?mode=logout&sid="+sid;
	myfrm.src=murl;
	var tt=setTimeout("reloader();",1700);
}
function gosterGizle(layer_divid) { 
	if (document.layers){ // NS 4
		if(document.layers[layer_divid].visibility == "hidden") { 
			document.layers[layer_divid].visibility = "visible";
		} else {
			document.layers[layer_divid].visibility = "hidden";
		}
	} else if (document.all){ // ie
		if(document.all(layer_divid).style.visibility == "hidden") {
			document.all(layer_divid).style.visibility = "visible";
		} else {
			document.all(layer_divid).style.visibility = "hidden"
		}
	} else if (document.getElementById){ // NS 6+
		if(document.getElementById(layer_divid).style.visibility == "hidden") {
			document.getElementById(layer_divid).style.visibility = "visible";
		} else {
			document.getElementById(layer_divid).style.visibility = "hidden"
		}
	}
}

//*******************************************************************************************************************