

window.onresize = setUpImage;

function setUpImage()
{
	try{
		document.getElementById("tdMain").style.height = document.documentElement.clientHeight - 30 + "px";
	}
	catch(ex)
	{}
}


function tumCbSec(chk)
{
	var allInput = document.getElementsByTagName("input");
	for(var i=0; i<allInput.length; i++)
	{
		if(allInput[i].type == "checkbox")
		{
			allInput[i].checked = chk;
		}
	}
}

function emailKontrol(s){
	var OK = true;
	var karakter = "";
	var strOK = "1234567890-_.^~@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	
	if(s.indexOf("@") == -1 || s.indexOf(".") == -1){
		return false;
	}
	else{
  	for(var i=0; i<= s.length && OK == true; i++){
    	karakter = s.substr(i,1);
    	if(strOK.indexOf(karakter) == -1) OK = false;
  	}
  
  	atsonra = s.substring(s.indexOf("@")+1,s.length);
    
  	if(s.substr(s.indexOf("@")+1,1) == "." || 
  			s.substr(s.length-1, 1) == "@" || 
  			s.substr(s.length-1, 1) == "." ||
  			atsonra.indexOf(".") == -1 ||
				atsonra.indexOf("@") > -1) OK = false;
		
		
		if(s.indexOf("@")<1) OK = false;
  
		return OK;
	}        
}

function checkEmail(email){
	var str=email;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	return filter.test(str);
}



function checkDate(field)
{
var allowBlank = false;
var minYear = 1902;
var maxYear = (new Date()).getFullYear();

var errorMsg = "";

// regular expression to match required date format
re = /^(\d{1,2})\.(\d{1,2})\.(\d{4})$/;

if(field.value != '') {
  if(regs = field.value.match(re)) {
    if(regs[1] < 1 || regs[1] > 31) {
      errorMsg = "Invalid value for day: " + regs[1];
    } else if(regs[2] < 1 || regs[2] > 12) {
      errorMsg = "Invalid value for month: " + regs[2];
    } else if(regs[3] < minYear || regs[3] > maxYear) {
      errorMsg = "Invalid value for year: " + regs[3] + " - must be between " + minYear + " and " + maxYear;
    }
  } else {
    errorMsg = "Invalid date format: " + field.value;
  }
} else if(!allowBlank) {
  errorMsg = "Empty date not allowed!";
}

if(errorMsg != "") {
  field.style.backgroundColor = "#ffcc99";
  field.focus();
  return false;
}
else
{
	field.style.backgroundColor = "";
}

return true;
}


function submitFormById(id)
{
	document.getElementById(id).submit();
}

function setValue(elmId, value)
{
	document.getElementById(elmId).value = value;
}

function cellMouseOver(cell)
{
	var outClass = cell.className;
	cell.onmouseout = function(){ this.className = outClass; }
	cell.className = "cellOver";
}

function Trim(s){
	   	
	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
 	{ s = s.substring(1,s.length); }
   
 	
  	while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
 	{ s = s.substring(0,s.length-1); }
   
 	return s;
}


function numericCharControl(e)
{
	//alert(e.keyCode);
	var allowedChars = "8,9,16,17,35,36,37,38,39,40,46,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105,110,188";
	
	
	if(e){
		if(allowedChars.indexOf(e.keyCode) == -1){
			e.cancelBubble = true;
			if(window.event) e.returnValue = null;
			else e.preventDefault();
		}
	}
	
}

var lastActiveTab;

function tabGoster(tab)
{
	if(lastActiveTab){
		document.getElementById("tdTab_"+lastActiveTab).className = "tdTab";
		document.getElementById("divTab_"+lastActiveTab).style.display = 'none';
	}
	
	document.getElementById("tdTab_"+tab).className = "tdTabActive";
	document.getElementById("divTab_"+tab).style.display = 'inline';
	if(document.getElementById("fixedRow_"+tab)) setFixedRow(tab);
	lastActiveTab = tab;
}

function setFixedRow(exp)
{
	document.getElementById("fixedRow_"+exp).style.top = document.getElementById("divScroll_"+exp).scrollTop -1 + "px";
}


function tagSil(str){
	while(str.indexOf("<") != -1 && str.indexOf(">") != -1){
		strsil = str.substring(str.indexOf("<"),str.indexOf(">")+1);
		str = str.replace(strsil,"");
	}
	str = str.toLowerCase().replace(/&nbsp;/g,"");
	str = str.replace(" ","");
	return str;
}

function filtreHTML(str){
	str = str.replace(/%/g,"([%])");
	str = str.replace(/&/g,"([amp])");
	return str;
}

function p2Ac()
{
	window.open("p2.htm","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no");
}

function setLng(lng){
	var loc = window.location.href;
	var path = window.location.pathname;
	var page = path.substring(path.lastIndexOf('/') + 1);
	
	var rx = new RegExp("#.*");
	
	loc = loc.replace(rx, "");
	
	switch(page)
	{
		case "List.php": loc = "Search.php";
	}
	
	if( loc.indexOf('?') != -1 ){
		new_loc = loc+'&lng='+lng;
	}
	else {
		new_loc = loc+'?lng='+lng;
	}
	
	
	location.href = new_loc;
}


// JavaScript Document

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; i<a.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&&i<d.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];}

}

//



//visit http://www.dynamicdrive.com



function modelesswin(url,mwidth,mheight){



eval('window.open(url,"","width='+mwidth+'px,height='+mheight+'px,resizable=no,scrollbars=no")')

}

//<a href="javascript:modelesswin('http://yahoo.com',600,400)">Click here</a>



//

function gotosite1(Fm){

var URL = Fm.options[Fm.selectedIndex].value;

window.location.href = URL;

}

//-->

		// Calendar callback. When a date is clicked on the calendar

		// this function is called so you can do as you want with it

		function calendarCallback(day, month, year)
		{
             date = day + '.' + month + '.' + year ;
			document.getElementById("searchByDate").date.value = date;
		}

				

		function calendarCallback2(day, month, year)
		{
			date = day + '.' + month + '.' + year ;
			document.getElementById("searchByDate").date2.value = date;
		}

	// -->

var TRange = null;

var dupeRange = null;

var TestRange = null;

var win = null;



var nom = navigator.appName.toLowerCase();

var agt = navigator.userAgent.toLowerCase();

var is_major   = parseInt(navigator.appVersion);

var is_minor   = parseFloat(navigator.appVersion);

var is_ie      = (agt.indexOf("msie") != -1);

var is_ie4up   = (is_ie && (is_major >= 4));

var is_not_moz = (agt.indexOf('netscape')!=-1)

var is_nav     = (nom.indexOf('netscape')!=-1);

var is_nav4    = (is_nav && (is_major == 4));

var is_mac     = (agt.indexOf("mac")!=-1);

var is_gecko   = (agt.indexOf('gecko') != -1);

var is_opera   = (agt.indexOf("opera") != -1);





//  GECKO REVISION



var is_rev=0

if (is_gecko) {

temp = agt.split("rv:")

is_rev = parseFloat(temp[1])

}





var frametosearch = self;





function search(whichform, whichframe) {



//  TEST FOR IE5 FOR MAC (NO DOCUMENTATION)



if (is_ie4up && is_mac) return;



//  TEST FOR NAV 6 (NO DOCUMENTATION)



if (is_gecko && (is_rev <1)) return;



//  TEST FOR Opera (NO DOCUMENTATION)



if (is_opera) return;



//  INITIALIZATIONS FOR FIND-IN-PAGE SEARCHES



if(whichform.findthis.value!=null && whichform.findthis.value!='') {



       str = whichform.findthis.value;

       win = whichframe;

       var frameval=false;

       if(win!=self)

{



       frameval=true;  // this will enable Nav7 to search child frame

       win = parent.frames[whichframe];



}



    

}



else return;  //  i.e., no search string was entered



var strFound;





if(is_nav4 && (is_minor < 5)) {

   

  strFound=win.find(str); 

}



if (is_gecko && (is_rev >= 1)) {

   

    if(frameval!=false) win.focus(); 

    strFound=win.find(str, false, false, true, false, frameval, false);





    if (is_not_moz)  whichform.findthis.focus();





}



 if (is_ie4up) {



  // EXPLORER-SPECIFIC CODE revised 5/21/03



  if (TRange!=null) {

	  

   TestRange=win.document.body.createTextRange();

 

	  



   if (dupeRange.inRange(TestRange)) {



   TRange.collapse(false);

   strFound=TRange.findText(str);

    if (strFound) {

        //the following line added by Mike and Susan Keenan, 7 June 2003

        win.document.body.scrollTop = win.document.body.scrollTop + TRange.offsetTop;

        TRange.select();

        }





   }

   

   else {



     TRange=win.document.body.createTextRange();

     TRange.collapse(false);

     strFound=TRange.findText(str);

     if (strFound) {

        //the following line added by Mike and Susan Keenan, 7 June 2003

        win.document.body.scrollTop = TRange.offsetTop;

        TRange.select();

        }







   }

  }

  

   if (TRange==null || strFound==0) {

   TRange=win.document.body.createTextRange();

   dupeRange = TRange.duplicate();

   strFound=TRange.findText(str);

    if (strFound) {

        //the following line added by Mike and Susan Keenan, 7 June 2003

        win.document.body.scrollTop = TRange.offsetTop;

        TRange.select();

        }



   

   }



 }



  if (!strFound) alert ("Kelime '"+str+"' bulunamadư!") // string not found



        

}

// -->



function findPos(coord, obj)
{
  var curleft = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      if (coord == 'x') {curleft += obj.offsetLeft;}
      else {curleft += obj.offsetTop}
      obj = obj.offsetParent;
    }
  }
  else if (obj.coord)
    curleft += obj.coord;
    
	return curleft;
}
