function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentHeight = document.getElementById('content').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
			}
			else {
				footerElement.style.top = '0px';
			}
		}
	}
}
window.onload = function() {
	setFooter();
}
window.onresize = function() {
	setFooter();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; ia.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&id.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function searchVal()
{
	var elem = document.forms["search"].GenSearchStr;
	if(elem.value=="")
	{
		alert("Please input a search string");		
		return false;
	}
}
theObjects = document.getElementsByTagName("object"); 
for (var i = 0; i < theObjects.length; i++) { 
   theObjects[i].outerHTML = theObjects[i].outerHTML; 
}

function checkmail(formName)  {
  if (formName.mail.value == "") {
     formName.mail.value ="kullaniciadi"     
  }
}
function checkmail2(formName)  {
       formName.mail.value =""     
  }
  function checksifre(formName)  {
  if (formName.sifre.value == "") {
     formName.sifre.value ="123456"     
  }
}
function checksifre2(formName)  {
       formName.sifre.value =""     
  }
  
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)
}

var highlightcolor="lightyellow"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}

//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}
//formatli para yazma başla
function FindComma(value){
var len=value.length-1;

for (i=len;i>=0;i--){
if(value.charAt(i)== ",") { return i;}
}
return 0;
}


function NewMoneyFormat(obj) {

var value=obj.value;
var len=obj.value.length-1;

var fstr="";
var fstr_comma="";

var zerocount=4; // numbers before comma as 111,xxxx

var tmp="";
var comma=0;
var intlen=0;
var upperlimit=0;

comma=FindComma(value); // finds comma position

for (i=0;i<=len;i++){
(
(
value.charAt(i).match(/^([0-9])$/) 
|| (value.charAt(i)== "," && (comma && comma==i))
)
&& value.charAt(i)!= "."
) ? tmp=tmp+value.charAt(i) : NaN;
}
comma=FindComma(tmp); 

if(comma>0) { intlen=comma-1; }
else { intlen = tmp.length-1; }

j=0
for (i=intlen;i>=0;i--){
j++;
if ((j % 3)==0 && i>0){
fstr="." + tmp.charAt(i) + fstr;
j=0;
} 
else
fstr=tmp.charAt(i) + fstr;
}

if (comma>0) {
upperlimit = comma+zerocount // upperlimit = len 

for (i=upperlimit;i>=comma;i--){
fstr_comma=tmp.charAt(i) + fstr_comma;
}
}
return fstr+fstr_comma;
}
//formatli para yazma bitti
//rakam giriş kontrol
function SadeceRakam(field, msg) {
  var reInt = /^\d+$/;
  if (field.value != "")
  {
	  if (!reInt.test(field.value)) {
		alert("Lütfen ilgili alana sadece rakam giriniz! [0-9]");
		if (field.value) {
		  field.value="";
		}
		//if (field.select) {
		  //field.select();
		//}
		return false;
	  }
  }
}
function uyeekle1kontrol() {
	if (document.getElementById("edts1").value == 0) {
		alert("En az 1 sektör seçiniz giriniz")
		document.getElementById("edts1").focus();
		return false;
		}  else if (document.getElementById("EdtFirma").value == "") {
		alert("Firma ismi giriniz")
		document.getElementById("EdtFirma").focus();
		return false;
	}  else if (document.getElementById("edtAdi").value == "") {
		alert("Firma yetkili ismi giriniz")
		document.getElementById("Edtadi").focus();
		return false;
	}  else if (document.getElementById("edtil").value == 0) {
		alert("Firma şehir seçiniz")
		document.getElementById("edtil").focus();
		return false;
	} else if (document.getElementById("EDTSIFRE").value == "") {
		alert("Şifre  giriniz")
		document.getElementById("EDTSIFRE").focus();
		return false;
	}else if (document.getElementById("EDTSIFRE2").value == "") {
		alert("Şifre  giriniz")
		document.getElementById("EDTSIFRE2").focus();
		return false;
	}else if (document.getElementById("edtGvn").value == "") {
		alert("Güvenlik kodunu giriniz")
		document.getElementById("EdtGvn").focus();
		return false;
	} else if (document.getElementById("Edtmail").value == "") {
		alert("E-posta adresi giriniz")
		document.getElementById("Edtmail").focus();
		return false;
		}
	return true;
}
