function IncludeJavaScript(jsFile)
{
  document.write('<script type="text/javascript" src="'
    + jsFile + '"></script>'); 
}
IncludeJavaScript('/scripts/vodaGrid.js');
IncludeJavaScript('/scripts/popup.js');
IncludeJavaScript('/scripts/form_control.js');
IncludeJavaScript('/scripts/jscripts.js');
IncludeJavaScript('/scripts/slct_list.js');
IncludeJavaScript('/scripts/ajax.js');
IncludeJavaScript('/scripts/modal-message.js');
IncludeJavaScript('/scripts/ajax-dynamic-content.js');
IncludeJavaScript('/scripts/dhtmlSuite-common.js');
IncludeJavaScript('/scripts/dhtmlSuite-dragDropSimple.js');
IncludeJavaScript('/scripts/formUtil.js');
IncludeJavaScript('/scripts/dhtmlSuite-resize.js');
IncludeJavaScript('/scripts/windows.js');
IncludeJavaScript('/scripts/dhtmlSuite-menuModel.js');
IncludeJavaScript('/scripts/dhtmlSuite-menuItem.js');
IncludeJavaScript('/scripts/dhtmlSuite-menuBar.js');
/*******************************************************************************   
* Controls a TextArea size, if it is overflow; warn the user and sets the content to max size

  usage:  onkeyup = "javascript:isOverFlow(this,30)"  
  objTextArea : the textarea will be controlled
  maxLen : maximum length of the TextArea

  OWNER : SEYKAY
  DATE  : 12.02.02 



*******************************************************************************/
//- - - Kisa yollar baslangici
	function $(id)
	{
		if(document.getElementById(id)!=null)
		  return document.getElementById(id);
		else
		  return false;
	}
	function $v(id)
	{
		if(document.getElementById(id)!=null)
  		  return document.getElementById(id).value;
		else
		  return false;
	}
	function $$(ad)
	{
		if(document.all(ad)!=null)
		  return document.all(ad);
		else
		  return false;
	}
	function $$v(ad)
	{
		if(document.all(ad)!=null)
 		  return document.all(ad).value;
		else
		  return false;
	}
// - - - Kisayollar bitti

	function isOverFlow(objTextArea,maxLen)
    {  
       var txtVal = objTextArea.innerText ;
       var cntObjName = objTextArea.name+'_counter';
       var cntObj = document.all(cntObjName);
       if (txtVal.length > maxLen)
       { 
          alert("Alanın boyutunu aştınız");
          txtVal = txtVal.slice(0,maxLen);
          objTextArea.innerText = txtVal  ; 
       }
       cntObj.value = maxLen-txtVal.length;
    }

/*******************************************************************************   
* Select destination item in the target listbox  
* Color change of destination item in the target listbox
  OWNER  : SELUNU   DATE   : 14.11.02 
*******************************************************************************/
function konumlan ( listbox,indis )
{
	listbox.options.selectedIndex=indis;
}

  
  function selectObjItem(HedefCmbBox, Secilen){
   if(HedefCmbBox.tagName=='SELECT'){
      for (var i=0; i < HedefCmbBox.options.length; i++) {
        if (HedefCmbBox.options[i].value == Secilen)
           HedefCmbBox.options[i].selected = true;
        else 
           HedefCmbBox.options[i].selected = false ;  
      }
    }
  }
  
function renklendir (listbox,indis,renk,tur)
{
	if (tur==1) 
	{
	listbox.options[indis].style.color=renk;
	}
	if (tur==2)
	{
	listbox.options[indis].style.background=renk;
	}

}    
/*******************************************************************************   
* Add item to target select box .
  
  Example : AddListbox (window.haberform.illiste,window.haberform.textliste,';');  
  OWNER : SELUNU
  DATE  : 11.11.02 
*******************************************************************************/
function ListToText(listbox,textbox,separator)
{
	textbox.value='';
		for (i = 0; i < listbox.options.length; i++) 
		{							
		textbox.value =textbox.value+listbox.options[i].value+separator;							
		}
}
/*******************************************************************************   
* Add item to target select box .
  
  Example : AddListbox ('34','İstanbul',window.haberform.illiste,0);
  deger			: item value
  yeni eleman	: new item caption 
  listbox		: target object name
  tekrarizin	: can items again ?
  
  OWNER : SELUNU
  DATE  : 11.11.02 
*******************************************************************************/

function AddListbox (deger,yenieleman,listbox,tekrarizin) {
var dizieleman 	= new Array();
var dizideger 	= new Array();
var indis,i;
var tekrarvar=0 ;

for (i = 0; i < listbox.options.length; i++) 
	{
	  dizideger[i] = listbox.options[i].value; 
	  dizieleman[i] = listbox.options[i].text;
	  
		if ((tekrarizin==0) && ( deger==dizideger[i] ))
		{
		tekrarvar=1;
		return 0; // Tekrar izni olmadığı için eklenemedi
		break;
		}	 		
	}
	if ((tekrarizin==1) || ( tekrarvar==0 ))
	{
		var boyut= dizieleman.length;
		dizieleman[boyut] =yenieleman;
		dizideger[boyut] =deger;
	
		listbox.length = 0;
		var indis;
			for(indis = 0; indis < dizieleman.length; indis++) 
			{
			    var no = new Option();
				    if (indis==boyut)
					{
					no.value = deger;
					no.text  = yenieleman;
					listbox[indis] = no;
					konumlan(listbox,indis);
					}

				    if (indis!=boyut)
					{
					no.value 	= dizideger[indis];
				    no.text 	= dizieleman[indis];
				    listbox[indis] = no;
					}  
			    
			}
	return 1; // Başarıyla Eklendi 
	}
}

/*******************************************************************************   
* Clear selected items in the target select box .
  
  Example : DeleteListbox ('34',window.haberform.illiste,1);
			DeleteListbox ('İstanbul',window.haberform.illiste,2);
			
  deger			: Value or Caption 
  listbox		: target object name
  tur			: if tur= 1 then deger is VALUE .if tur=2 then deger is CAPTION
  
  OWNER : SELUNU
  DATE  : 12.11.02 
*******************************************************************************/

function DeleteListbox (deger,listbox,tur) 
{
var dizieleman 	= new Array();
var dizideger 	= new Array();
var i;var j ;var konum ;


	for (i = 0; i < listbox.options.length; i++) 
	{
		  if (((tur==1)&&(listbox.options[i].value!=deger)) || ((tur==2)&&(listbox.options[i].text!=deger)))
		  {
		  dizideger [listbox.options[i].text] = listbox.options[i].value; 
		  dizieleman[i] = listbox.options[i].text;
		  }
		  else
		  { 

		  konum=i ;
   		  
		  for (j=i;j<listbox.options.length;j++)
		  {
			if ((j+1)<(listbox.options.length))
			{
			dizideger  [listbox.options[j].text] = listbox.options[j+1].value;
	                dizieleman [j] = listbox.options[j+1].text;
			}
		  }	

		  }
	}

listbox.length = 0;
var c;
j=0;

	for(c = 0; c < dizieleman.length; c++) 
	{
	var no = new Option();
	no.value = dizideger [dizieleman[c]];
	no.text  = dizieleman[c];
	listbox[j]  = no;
 	if (konum!=c)
	j++;

	}

}


/*******************************************************************************   
* enables user only can enter decimal number  
  
  Example       : onkeypress="isMoney (this);"
  this			: this = object input type=text
  
  OWNER : OSMANKOC
  DATE  : 13.07.05 
*******************************************************************************/
   function isMoney(txtObj){ 
     var kcode = event.keyCode;
     var inntxt = txtObj.value;
     if ((kcode >= 48 && kcode <= 57) ){
       return true;
     }else if(kcode == 44){
       var lenstr=inntxt.length;
       for(k=0;k<lenstr;k++){
         if(inntxt.substr(k,1)==','){
           event.returnValue=false;
           return false;
         }
       }
       if(lenstr == 0){txtObj.value='0';}
       return true;
     }else{
       event.returnValue=false;
       return false;
     }
   }


/*******************************************************************************   
* Change target select box's item value or caption
  
  Example : RaplaceListbox ('ist','34','İSTANBUL',window.haberform.illiste,1);						
  aranan		: find Value or find Caption 
  deger			: New Value
  eleman		: New Caption
  listbox		: target object name
  tur			: if tur= 1 then deger is VALUE .if tur=2 then deger is CAPTION
  
  OWNER : SELUNU
  DATE  : 12.11.02 
*******************************************************************************/
function ReplaceListbox (aranan,deger,eleman,listbox,tur) 
{
var i;var no;var konum ;

	for (i = 0; i < listbox.options.length; i++) 
	{
		  if (((tur==1)&&(listbox.options[i].value==aranan)) || ((tur==2)&&(listbox.options[i].text==aranan)))
		  { 
                  konum=i;
		  }
	}			
		var no = new Option();
		no.value = deger;
		no.text  = eleman;
		listbox[konum]  = no;
        konumlan(listbox,konum);
}
/*******************************************************************************   
*     
  OWNER : MEHELC
  DATE  : 11.11.02 
*******************************************************************************/
function isNumeric()
        { 
        if ((event.keyCode > 32 && event.keyCode < 57) || event.keyCode == 8)
        	{
        	 return true;}
        if ((event.keyCode > 95 && event.keyCode < 106))
        	{
        	 return true;}
             event.returnValue = 0;
}
/******************************************************************************
* Change target select box's item value or caption
  
  Example : src_open_close(this,'/images/sersrc_up.gif','/images/sersrc_down.gif','TR_CUST_SRC',2);
  image			: default imaj dosyasinin html üzerindeki name yada ID 'si
  uppath		: imaj tiklaninca alacagi yeni goruntunun yer aldigi imaj dosyasinin adresi
  downpath		: imaj yeniden tiklaninca alacagi goruntunun yer aldigi imaj dosyasinin adresi
  target_obje	: Goruntulenecek yada gizlenecek eleman setinin isimlerindeki baslangicta yer alan ortak string
  lastcount		: Eleman setinin sinir sayisi ( TR_LST0 , TR_LST1,TR_LST2, TR_LST3 için bu deger 3 dur )
  
  OWNER : SELUNU		sunuvar@hotmail.com
  DATE  : 17.03.03 
   
*******************************************************************************/
function src_open_close(image,uppath,downpath,target_obje,lastcount)
       {
						
			if (image.id=='DOWN')
			{
				for (i=0;i<=lastcount;i++)
				{				
				komut="document.all('"+target_obje+i+"').style.display='';";
				eval(komut);
				}
			
				image.id='UP';			
				image.src=uppath;
			}
			if (image.id=='UP')
			{
			for (i=0;i<=lastcount;i++)
				{				
				komut="document.all('"+target_obje+i+"').style.display='none';";
				eval(komut);
				}
				image.id='DOWN';
				image.src=downpath;			
			}												
       }                                    

function src_open_close(image,uppath,downpath,target_obje,lastcount)
       {
						
			if (image.id!='UP')
			{
				for (i=0;i<=lastcount;i++)
				{				
				komut="document.all('"+target_obje+i+"').style.display='';";
				eval(komut);
				}
			
				image.id='UP';			
				image.src=uppath;
			}
			else
			{
			for (i=0;i<=lastcount;i++)
				{				
				komut="document.all('"+target_obje+i+"').style.display='none';";
				eval(komut);
				}
				image.id='DOWN';
				image.src=downpath;			
			}												
       }                                    
// Alan 3 O ise belirtilen renk le işaretleniyor
function FillSecondComboColor(Alan1, Alan2, Alan3 , sql , Secilen , HedefCmbBox , WhereValue ,color) {

  if (sql=='')
    return false;
  if (HedefCmbBox=='')
    return false;
  if (WhereValue=='' || WhereValue=="-1" || WhereValue=="undefined")
    return false;
   //to manage the xml document
   var objDOM;
    objDOM= new ActiveXObject("Microsoft.XMLDOM");
   //to establish a http connection between the server
   //and the client, thereby sending and receiving
   //message to and from the server
   //without submitting the page
   var xmlh = new ActiveXObject("Microsoft.XMLHTTP");
   
   //to identify whether the server is contacted
   //by clicking the send button OR
   //the routine timer event    
    xmlh.open("POST","/contacts/cmblist.asp?sql_query=" + sql,false);
	 xmlh.send();
	 objDOM.loadXML(xmlh.ResponseText);
	 //DataIsland.documentElement = objDOM.documentElement;

 //to display the incoming user list  
      var nodes,strHtml;
      var selList 	= new Array();
      var newList 	= new Array();
      var newList_id 	= new Array();
      var newList_color = new Array();

     // objDOM.loadXML(DataIsland.documentElement.xml);
      nodes 		= objDOM.getElementsByTagName(Alan2);
      nodes_id 		= objDOM.getElementsByTagName(Alan1);
      nodes_color	= objDOM.getElementsByTagName(Alan3);	

      //getting the current user list
    for(i=0;i<nodes.length;i++){
          newList[i] = nodes.item(i).text;
     }
  
    for(i=0;i<nodes_id.length;i++){
         
          newList_id[i] = nodes_id.item(i).text;
      }

    for(i=0;i<nodes_color.length;i++){        
          newList_color[i] = nodes_color.item(i).text;	  
      }
    var k, ex_list;
    
    //Before create new option I have t clear ex ones
    // but when I try to remove ex one I coludn't overcome to a problem
    // so I do some workaround to clear all options before create new ones
    f_list = document.all(HedefCmbBox).options.length;
    
    
    for (var rtnCnt=f_list - 1 ;  rtnCnt >=1 ; rtnCnt--) { 
		    document.all(HedefCmbBox).options.remove(rtnCnt);
	}
    
     // Fill combo with names
    for (var i=0; i < newList_id.length; i++) {
        if (newList_id[i] == Secilen) 
	{
	document.all(HedefCmbBox).options[i + 1 ] = new Option(newList[i],newList_id[i],true,true);
  		if (newList_color[i]==1)
		{	
		document.all(HedefCmbBox).options[i+1].style.color=color;
		document.all(HedefCmbBox).options[i+1].id=newList_color[i];
		}
	
	}	   
        else 
	{
           document.all(HedefCmbBox).options[i + 1] = new Option(newList[i],newList_id[i]);
  		if (newList_color[i]==1)
		{	
		document.all(HedefCmbBox).options[i+1].style.color=color;
		document.all(HedefCmbBox).options[i+1].id=newList_color[i];
		}

	}
    }       
    // and then select the item which must be selected
    for (var i=0; i < document.all(HedefCmbBox).options.length; i++) {
        if (document.all(HedefCmbBox).options[i].value == Secilen)
           document.all(HedefCmbBox).options[i].selected = true;
        else 
           document.all(HedefCmbBox).options[i].selected = false ;  
    }
}

function fnSetValues(width,height){
  
   var sFeatures="dialogWidth: "+width+"px;dialogHeight: " + height + "px;center:1;dialogHide:1;scroll:1;status:0;unadorned:1";
   return sFeatures;
}

function fnOpen(URL){
   var sFeatures=fnSetValues(480,280);
   returnValue = window.showModalDialog(URL, "",sFeatures)
   // alert(returnValue);
}

function isAlien(a) {
   return isObject(a) && typeof a.constructor != 'function';
}
function isArray(a) {
    return isObject(a) && a.constructor == Array;
}
function isBoolean(a) {
    return typeof a == 'boolean';
}
function isEmpty(o) {
    var i, v;
    if (isObject(o)) {
        for (i in o) {
            v = o[i];
            if (isUndefined(v) && isFunction(v)) {
                return false;
            }
        }
    }
    return true;
}
function isFunction(a) {
    return typeof a == 'function';
}
function isNull(a) {
    return typeof a == 'object' && !a;
}
function isNumber(a) {
    return typeof a == 'number' && isFinite(a);
}
function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}
function isString(a) {
    return typeof a == 'string';
}
function isUndefined(a) {
    return typeof a == 'undefined';
}


var isNav4 = false, isNav5 = false, isIE4 = false
var strSeperator = "."; 
// If you are using any Java validation on the back side you will want to use the / because 
// Java date validations do not recognize the dash as a valid date separator.
var vDateType = 3; // Global value for type of date format
//                1 = mm/dd/yyyy
//                2 = yyyy/dd/mm  (Unable to do date check at this time)
//                3 = dd/mm/yyyy
var vYearType = 4; //Set to 2 or 4 for number of digits in the year for Netscape
var vYearLength = 2; // Set to 4 if you want to force the user to enter 4 digits for the year before validating.
var err = 0; // Set the error code to a default of zero
if(navigator.appName == "Netscape") {
if (navigator.appVersion < "5") {
isNav4 = true;
isNav5 = false;
}
else
if (navigator.appVersion > "4") {
isNav4 = false;
isNav5 = true;
   }
}
else {
isIE4 = true;
}

function DateFormat(vDateName, vDateValue, e, dateCheck, dateType) {
    vDateType = dateType;
    var wrongFormatMessage = "Yanlış Format\nLütfen yeniden giriniz";
    // vDateName = object name
    // vDateValue = value in the field being checked
    // e = event
    // dateCheck 
    // True  = Verify that the vDateValue is a valid date
    // False = Format values being entered into vDateValue only
    // vDateType
    // 1 = mm/dd/yyyy
    // 2 = yyyy/mm/dd
    // 3 = dd/mm/yyyy
    //Enter a tilde sign for the first number and you can check the variable information.
    if (vDateValue == "~") {
      alert("AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE4+" \nYear Type = "+vYearType+" \nDate Type = "+vDateType+" \nSeparator = "+strSeperator);
      vDateName.value = "";
      vDateName.focus();
      return true;
    }
    var whichCode = (window.Event) ? e.which : e.keyCode;
    // Check to see if a seperator is already present.
    // bypass the date if a seperator is present and the length greater than 8
    if (vDateValue.length > 8 && isNav4) {
      if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1))
        return true;
    }
    //Eliminate all the ASCII codes that are not valid
    var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";
    if (alphaCheck.indexOf(vDateValue) >= 1) {
      if (isNav4) {
        vDateName.value = "";
        vDateName.focus();
        vDateName.select();
        return false;
      }else{
        vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
        return false;
      }
    }
    if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no value
      return false;
    else {
      //Create numeric string values for 0123456789/
      //The codes provided include both keyboard and keypad values
      
      var strCheck = '16,17,18,33,34,35,36,37,38,39,40,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
      if (strCheck.indexOf(whichCode) != -1) {
        if (isNav4) {
          if (((vDateValue.length < 6 && dateCheck) || (vDateValue.length == 7 && dateCheck)) && (vDateValue.length >=1)) {
            alert(wrongFormatMessage);
//            vDateName.value = "";
            vDateName.focus();
            vDateName.select();
            return false;
          }
          if (vDateValue.length == 6 && dateCheck) {
            var mDay = vDateName.value.substr(2,2);
            var mMonth = vDateName.value.substr(0,2);
            var mYear = vDateName.value.substr(4,4)
            //Turn a two digit year into a 4 digit year
            if (mYear.length == 2 && vYearType == 4) {
              var mToday = new Date();
              //If the year is greater than 30 years from now use 19, otherwise use 20
              var checkYear = mToday.getFullYear() + 30; 
              var mCheckYear = '20' + mYear;
              if (mCheckYear >= checkYear)
                mYear = '19' + mYear;
              else
                mYear = '20' + mYear;
            }
            var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
            if (!dateValid(vDateValueCheck)) {
              alert(wrongFormatMessage);
  //            vDateName.value = "";
              vDateName.focus();
              vDateName.select();
              return false;
            }
            return true;
          }else {
            // Reformat the date for validation and set date type to a 1
            if (vDateValue.length >= 8  && dateCheck) {
              if (vDateType == 1) // mmddyyyy
              {
                var mDay = vDateName.value.substr(2,2);
                var mMonth = vDateName.value.substr(0,2);
                var mYear = vDateName.value.substr(4,4)
                vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
              }
              if (vDateType == 2) // yyyymmdd
              {
                var mYear = vDateName.value.substr(0,4)
                var mMonth = vDateName.value.substr(4,2);
                var mDay = vDateName.value.substr(6,2);
                vDateName.value = mYear+strSeperator+mMonth+strSeperator+mDay;
              }
              if (vDateType == 3) // ddmmyyyy
              {
                var mMonth = vDateName.value.substr(2,2);
                var mDay = vDateName.value.substr(0,2);
                var mYear = vDateName.value.substr(4,4)
                vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
              }
              //Create a temporary variable for storing the DateType and change
              //the DateType to a 1 for validation.
              var vDateTypeTemp = vDateType;
              vDateType = 1;
              var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
              if (!dateValid(vDateValueCheck)) {
                alert(wrongFormatMessage);
                vDateType = vDateTypeTemp;
    //            vDateName.value = "";
                vDateName.focus();
                vDateName.select();
                return false;
              }
              vDateType = vDateTypeTemp;
              return true;
            }else {
              if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
                alert(wrongFormatMessage);
      //          vDateName.value = "";
                vDateName.focus();
                vDateName.select();
                return false;
              }
            }
          }
        }else {
          // Non isNav Check
          if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
            alert(wrongFormatMessage);
//            vDateName.value = "";
            vDateName.focus();
            return true;
          }
          // Reformat date to format that can be validated. mm/dd/yyyy
          if (vDateValue.length >= 8 && dateCheck) {
            // Additional date formats can be entered here and parsed out to
            // a valid date format that the validation routine will recognize.
            if (vDateType == 1) // mm/dd/yyyy
            {
              var mMonth = vDateName.value.substr(0,2);
              var mDay = vDateName.value.substr(3,2);
              var mYear = vDateName.value.substr(6,4)
            }
            if (vDateType == 2) // yyyy/mm/dd
            {
              var mYear = vDateName.value.substr(0,4)
              var mMonth = vDateName.value.substr(5,2);
              var mDay = vDateName.value.substr(8,2);
            }
            if (vDateType == 3) // dd/mm/yyyy
            {
              var mDay = vDateName.value.substr(0,2);
              var mMonth = vDateName.value.substr(3,2);
              var mYear = vDateName.value.substr(6,4)
            }
            if (vDateType == 4) // dd/mm/yyyy HH:ii
            {
              var mDay = vDateName.value.substr(0,2);
              var mMonth = vDateName.value.substr(3,2);
              var mYear = vDateName.value.substr(6,4)
              var mHour = vDateName.value.substr(11,2)
              var mMinute = vDateName.value.substr(14,2)
            }
            if (vYearLength == 4) {
              if (mYear.length < 4) {
                alert(wrongFormatMessage);
  //              vDateName.value = "";
                vDateName.focus();
                return true;
              }
            }
            // Create temp. variable for storing the current vDateType
            var vDateTypeTemp = vDateType;
            // Change vDateType to a 1 for standard date format for validation
            // Type will be changed back when validation is completed.
            vDateType = 1;
            // Store reformatted date to new variable for validation.
            var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
            if (mYear.length == 2 && vYearType == 4 && dateCheck) {
              //Turn a two digit year into a 4 digit year
              var mToday = new Date();
              //If the year is greater than 30 years from now use 19, otherwise use 20
              var checkYear = mToday.getFullYear() + 30; 
              var mCheckYear = '20' + mYear;
              if (mCheckYear >= checkYear)
                mYear = '19' + mYear;
              else
                mYear = '20' + mYear;
              vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
              // Store the new value back to the field.  This function will
              // not work with date type of 2 since the year is entered first.
              if (vDateTypeTemp == 1) // mm/dd/yyyy
                vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
              if (vDateTypeTemp == 3) // dd/mm/yyyy
                vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
            } 
            if (!dateValid(vDateValueCheck)) {
              alert(wrongFormatMessage);
              vDateType = vDateTypeTemp;
              vDateName.value = "";
              vDateName.focus();
              return true;
            }
            vDateType = vDateTypeTemp;
            return true;
          }else {
            if (vDateType == 1) {
              if (vDateValue.length == 2) {
                vDateName.value = vDateValue+strSeperator;
              }
              if (vDateValue.length == 5) {
                vDateName.value = vDateValue+strSeperator;
              }
            }
            if (vDateType == 2) {
              if (vDateValue.length == 4) {
                vDateName.value = vDateValue+strSeperator;
              }
              if (vDateValue.length == 7) {
                vDateName.value = vDateValue+strSeperator;
              }
            } 
            if (vDateType == 3) {
              if (vDateValue.length == 2) {
                vDateName.value = vDateValue+strSeperator;
              }
              if (vDateValue.length == 5) {
                vDateName.value = vDateValue+strSeperator;
              }
            }
            return true;
          }
        }
        if (vDateValue.length == 10&& dateCheck) {
          if (!dateValid(vDateName)) {
            // Un-comment the next line of code for debugging the dateValid() function error messages
            //alert(err);  
            alert("Yanlış Format\nLütfen yeniden giriniz");
            vDateName.focus();
            vDateName.select();
          }
        }
        return false;
      }else {
        // If the value is not in the string return the string minus the last
        // key entered.
        if (isNav4) {
  //        vDateName.value = "";
          vDateName.focus();
          vDateName.select();
          return false;
        }else{
          vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
          return false;
        }
      }
    }
}

function dateValid(objName) {
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
// var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
//strDate = datefield.value;
strDate = objName;
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
err = 1;
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound = true;
   }
}
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
   }
}
//Adjustment for short years entered
if (strYear.length == 2) {
strYear = '20' + strYear;
}
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
   }
}
if (isNaN(intMonth)) {
err = 3;
return false;
   }
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday < 1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
err = 9;
return false;
   }
}
else {
if (intday > 28) {
err = 10;
return false;
      }
   }
}
return true;
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}

  var xmlListDoc;
  xmlListDoc = new ActiveXObject("Microsoft.XMLDOM"); 
  var srcXmlListBfTxt='';
  function loadListXML(xmlFile) { 
    xmlListDoc.async="false"; 
    xmlListDoc.onreadystatechange=verify; 
    xmlListDoc.load(xmlFile); 
    xmlDocElm=xmlListDoc.documentElement; 
  } 
  
  function verify(){  
    if (xmlListDoc.readyState != 4){  
      return false;  
    } 
  }
  function showDivWin(objDiv, lstType, objForName){
  //onKeyPress=\"var keyCod = (event.which) ? event.which : event.keyCode; if(keyCod == \'13\') getResults();\"
  //innerTxt+='&nbsp;<input type=button class=button value=Ara onclick=\"getResults()\">';
    var innerTxt='';
    try{
       if(lstType!=''){
        var objDivName = objDiv.id;
        var objDivTable=document.all(objDivName+'Table');
        objDivTable.style.visibility="visible";
        loadListXML('/common/listsxml.asp?lstType='+lstType);
        innerTxt+='<input type=text class=text name=srcXmlList size=30 onkeydown="srcXmlListBfTxt=this.value;" onkeyup=\"getResults(\''+objForName+'\', \''+objDivName+'\')\" >';
        innerTxt+='<table width=\"90%\" border=0 cellpadding=0 cellspacing=1 class=\"tab_class\">';
        for(i=0;i<xmlDocElm.childNodes.length;i++){
          innerTxt+=('<tr class=\"sonuc2\" id=\"xmlItem'+i+'\">');
          innerTxt+=('<td nowrap>'+xmlDocElm.childNodes(i).childNodes(0).firstChild.text+'</td>');
          innerTxt+=('<td nowrap style=\"cursor:hand\" onclick=\"selectitemObj(\''+objForName+'\', \'');
          innerTxt+=(xmlDocElm.childNodes(i).childNodes(0).firstChild.text+'\', \''+objDivName+'\' );\">');
          innerTxt+=(xmlDocElm.childNodes(i).childNodes(1).firstChild.text+'</td></tr>');
        }
        innerTxt = innerTxt+'</table>';
         objDiv.innerHTML=innerTxt;
         rightedge='ie5'? document.body.clientWidth-event.clientX : window.innerWidth-e.clientX 
         bottomedge='ie5'? document.body.clientHeight-event.clientY : window.innerHeight-e.clientY    
         if (rightedge<objDivTable.offsetWidth) 
            objDivTable.style.left='ie5'? document.body.scrollLeft+event.clientX-objDivTable.offsetWidth : window.pageXOffset+e.clientX-objDivTable.offsetWidth 
         else 
            objDivTable.style.left='ie5'? document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX 
            objDivTable.style.top='ie5'? document.body.scrollTop+event.clientY : window.pageYOffset+e.clientY 
       }
       objDiv.style.visibility="visible";
       document.all('srcXmlList').focus();
    }
    catch(e){
       alert(e.description);
       return 1;
    }
  }

  function getResults(HedefCmbBox,objDivNm){
    var strSrc = document.all('srcXmlList').value;
    var strItem;
    var entered=0;
    strSrc = strSrc.toLowerCase();
    if(event.keyCode==27){
      if(srcXmlListBfTxt==''){
        document.all('ctxDivWin').style.visibility='hidden';
        document.all('ctxDivWinTable').style.visibility='hidden';
        return 1;
      }
    }
     if((event.keyCode==13)||(event.keyCode==10))
     {
            entered=1;
     }
      for(i=0;i<xmlDocElm.childNodes.length;i++){
          strItem = xmlDocElm.childNodes(i).childNodes(1).firstChild.text;
          strItem = strItem.toLowerCase();
          if(strItem.indexOf(strSrc)>=0 || strSrc==''){
            document.all('xmlItem'+i).style.display='';
            if(entered){
              selectitemObj(HedefCmbBox, xmlDocElm.childNodes(i).childNodes(0).firstChild.text, objDivNm);
              return 1;
            }
          }else{
            document.all('xmlItem'+i).style.display='none';
          }
      }
  }
  
  function selectitemObj(HedefCmbBox, Secilen, objDivNm){
    if(document.all(HedefCmbBox).tagName=='INPUT'){
      document.all(HedefCmbBox).value = Secilen;
    }else if(document.all(HedefCmbBox).tagName=='SELECT'){
      for (var i=0; i < document.all(HedefCmbBox).options.length; i++) {
        if (document.all(HedefCmbBox).options[i].value == Secilen)
           document.all(HedefCmbBox).options[i].selected = true;
        else 
           document.all(HedefCmbBox).options[i].selected = false ;  
      }
    }
    document.all(objDivNm).style.visibility='hidden';
    document.all(objDivNm+'Table').style.visibility='hidden';
  }
  /******************************************************************
  function openDefWin(def_id, sub_id, idObj, idObjType, txObj)
  to select a group from definiton popup window no return value.
  def_id= definiton type id, sub_id=an sub_id to select from an under specific group
  idObj= object stores definiton id, 
  idObjType = returning id comes from 1:InId, 2:StValue, else InDefinitionId,
  txObj= onject stores StDefiniton
  ******************************************************************/
  function openDefWin(def_id, sub_id, idObj, idObjType, txObj){
    var actStr='id='+def_id;
    actStr+=(sub_id==''||sub_id=='-1'?'':'&sub_id='+sub_id);
    actStr+=(idObj==''||idObj=='-1'?'':'&idObj='+idObj);
    actStr+=(idObjType==''||idObjType=='-1'?'':'&idObjType='+idObjType);
    actStr+=(txObj==''||txObj=='-1'?'':'&txObj='+txObj);
    popup('/defselect/defselect.asp?'+actStr,'definitions',320,240);
  }
  
function FillSecondCombo(Alan1, Alan2, sql_id , Secilen , HedefCmbBox , WhereValue, WhereValue2) {
	 if (sql_id=='')
		return false;
	 if (HedefCmbBox=='')
		return false;
	 //Aşağıdaki if 'den WhereValue=="-1" durumunu çıkarttım ki ilk combo seçiniz seçilince ikincisinin içi boşalsın, kaan-25-06-2002  
     if (WhereValue=='' || WhereValue=="undefined")
		return false;
     //to manage the xml document
     var objDOM = new ActiveXObject("Microsoft.XMLDOM");
     //to establish a http connection between the server
     //and the client, thereby sending and receiving
     //message to and from the server
     //without submitting the page
     var xmlh = new ActiveXObject("Microsoft.XMLHTTP");
   
     //to identify whether the server is contacted
     //by clicking the send button OR
     //the routine timer event

	  //sql_query birden çok sql kullanabilmek için fonk. parametre ismi ve querystring ismi sql_id olarak değiştirildi, kaan-23-06-2002
      xmlh.open("POST","/common/cmblist.asp?sql_id=" + sql_id + "&sql_value=" + WhereValue + "&sql_value2=" + WhereValue2,false);
	  xmlh.send();
	  objDOM.loadXML(xmlh.ResponseText);
	  //DataIsland.documentElement = objDOM.documentElement;
	  //alert(xmlh.ResponseText);
	  //to display the incoming user list
	  var nodes,strHtml;
      var selList = new Array();
      var newList = new Array();
      var newList_id = new Array();

	  // objDOM.loadXML(DataIsland.documentElement.xml);
      nodes = objDOM.getElementsByTagName(Alan2);
      nodes_id = objDOM.getElementsByTagName(Alan1);

	  //getting the current user list
      for(i=0;i<nodes.length;i++){
          newList[i] = nodes.item(i).text;
      }
  
      for(i=0;i<nodes_id.length;i++){
         
          newList_id[i] = nodes_id.item(i).text;
      }
     
     var k, ex_list;
    
     //Before create new option I have t clear ex ones
     // but when I try to remove ex one I coludn't overcome to a problem
     // so I do some workaround to clear all options before create new ones
     f_list = document.all(HedefCmbBox).options.length;
    
    
     for (var rtnCnt=f_list - 1 ;  rtnCnt >=1 ; rtnCnt--) { 
		    document.all(HedefCmbBox).options.remove(rtnCnt);
	 }
    
      // Fill combo with names
     for (var i=0; i < newList_id.length; i++) {
        if (newList_id[i] == Secilen)
           document.all(HedefCmbBox).options[i + 1 ] = new Option(newList[i],newList_id[i],true,true);
        else 
           document.all(HedefCmbBox).options[i + 1] = new Option(newList[i],newList_id[i]);  
     }
    
     // and then select the item which must be selected
     for (var i=0; i < document.all(HedefCmbBox).options.length; i++) {
        if (document.all(HedefCmbBox).options[i].value == Secilen)
           document.all(HedefCmbBox).options[i].selected = true;
        else 
           document.all(HedefCmbBox).options[i].selected = false ;  
     }
}

function FillObjects(sql , WhereValue) {
  
  if (sql=='')
  return false;

  if (WhereValue=='' || WhereValue=="-1" || WhereValue=="undefined")
    return false;

	if ((isNaN(WhereValue))|(WhereValue.length>8))
	sql = sql +"'"+WhereValue+"'";
	else
	sql = sql +WhereValue;

   //to manage the xml document
   var objDOM = new ActiveXObject("Microsoft.XMLDOM");
   //to establish a http connection between the server
   //and the client, thereby sending and receiving
   //message to and from the server
   //without submitting the page
   var nodes;
   var str_value;
   var array_date;
   var xmlh = new ActiveXObject("Microsoft.XMLHTTP");
   
   xmlh.open("POST","/contacts/cmblist.asp?sql_query=" + sql,false);
   xmlh.send();   
   objDOM.loadXML(xmlh.ResponseText);   
   // get all fields and field names
   nodes = objDOM.getElementsByTagName("*");
   
   // put the values into fields
   for(i=2;i<nodes.length;i++){
   
    //Date Value must be Turkish format . So, this syntax for it
        str_value=nodes.item(i).text;
        array_date=str_value.split("/");
            if ((array_date[0]!=null) && (array_date[1]!=null) && (array_date[2]!=null) && (array_date[3]==null)) {
            nodes.item(i).text=array_date[1]+'/'+array_date[0]+'/'+array_date[2];            
            }

    //If date field 1/1/1900 then be datefiled=''  
	// if (nodes.item(i).text=='1/1/1900') nodes.item(i).text='';
	  if (nodes.item(i).nodeName!='SUB')
      document.all(field = nodes.item(i).nodeName).value = nodes.item(i).text;

   }
    
}

function xmlsqlexecute(sql) {
  
  if (sql=='')
   return false;

  var objDOM = new ActiveXObject("Microsoft.XMLDOM");
  var xmlh = new ActiveXObject("Microsoft.XMLHTTP");

  xmlh.open("POST","/scripts/xmlsqlexec.asp?sql_query=" + sql,false);
  xmlh.send();
  objDOM.loadXML(xmlh.ResponseText);  
   // get all fields and field names
return true;

}

function isMsie(){
   var usrAgent=navigator.userAgent;
   usrAgent=usrAgent.toLowerCase()
   if(usrAgent.indexOf('msie')>=0)
     return true;
   else
     return false;
}
  var srcStr='';
  var tmpStr='';
  var oSelectSrcDiv=false;
  var clearSrcDivHndId=0;
  function clearSrcDiv(){
    if(!oSelectSrcDiv){
      createSearchDiv();
    }
    oSelectSrcDiv.innerHTML='';
    srcStr='';
    tmpStr='';
  }
  function createSearchDiv(){
    oSelectSrcDiv = document.createElement('DIV');
    oSelectSrcDiv.id = 'srcDiv';
    oSelectSrcDiv.style.position='absolute';
    oSelectSrcDiv.style.visibility='visible';
    oSelectSrcDiv.style.display='';
    oSelectSrcDiv.style.height='8px';
    oSelectSrcDiv.style.fontSize='8px';
    oSelectSrcDiv.style.backgroundColor='#FFFFFF';
    oSelectSrcDiv.style.zIndex=500000;
    document.body.appendChild(oSelectSrcDiv);
  }
    function isOldMsie(){
       var usrAgent=navigator.userAgent;
       usrAgent=usrAgent.toLowerCase()
       if(usrAgent.indexOf('msie')>=0){
         if(usrAgent.indexOf('msie 7')>=0){
           return false;
         }else{
           return true;
         }
       }else{
         return false;
       }
    }
  function searchInCombo(objCmb, kCode){
    if(!oSelectSrcDiv){
      createSearchDiv();
      }
    window.clearTimeout(clearSrcDivHndId);
    chkMsie=isMsie();
    oSelectSrcDiv.style.left=getleftPosition(objCmb) + 'px';
    tpPos=getTopPosition(objCmb);
    tpPos=tpPos-objCmb.offsetHeight-oSelectSrcDiv.offsetHeight;
    oSelectSrcDiv.style.top=tpPos + 'px';
    if(kCode==27){
      srcStr='';
    }else if(kCode==8){
      srcStr=srcStr.substr(0,srcStr.length-1);
    }else{
      Key = String.fromCharCode(kCode);
      if(Key=='i')
        Key = 'İ';
      else
        Key = Key.toUpperCase();
      srcStr=srcStr+Key;
    }
    oSelectSrcDiv.innerHTML=srcStr;
    if(objCmb.options!=null){
      for(i=0;i<objCmb.options.length;i++){
        
        tmpStr=chkMsie?objCmb.options[i].innerText:objCmb.options[i].textContent;
        tmpStr=tmpStr.replace(/i/g, 'İ');
        tmpStr=tmpStr.toUpperCase();
        if(srcStr.length<tmpStr.length)
          tmpStr=tmpStr.substr(0,srcStr.length);
        if(tmpStr==srcStr){
          objCmb.options[i].selected=true;
          event.returnValue=false;
          clearSrcDivHndId=window.setTimeout('clearSrcDiv()', 3000);
          return false;
        }
      }
      if(chkMsie)
        event.returnValue=false;
      clearSrcDivHndId=window.setTimeout('clearSrcDiv()', 3000);
      return false;
    }
    clearSrcDivHndId=window.setTimeout('clearSrcDiv()', 3000);
  }
  function handleBackSpace(objCmb, kCode){
    if(kCode==8){
      event.returnValue=false;
      searchInCombo(objCmb, 8);
    }
  }
function getTopPosition(inputObj)
{
	
  var returnValue = inputObj.offsetTop + inputObj.offsetHeight;
  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
  return returnValue;
}

function getleftPosition(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
  return returnValue;
}
function attSelectBoxSrc(){
    /*if(oSelectSrcDiv==false)
      createSearchDiv();*/
    selObjArr=document.all.tags('select');
    for(i=0;i<selObjArr.length;i++){
      setEvents(selObjArr[i]);
    }
}


function setEvents(oSelect){
  if(isMsie()){
    oSelect.attachEvent('onkeypress', function(e){searchInCombo(oSelect,event.keyCode);}, false);
    oSelect.attachEvent('onkeydown', function(e){handleBackSpace(oSelect,event.keyCode);}, false);
    oSelect.attachEvent('onblur', function(e){srcStr='';oSelectSrcDiv.innerText=srcStr;}, false);
  }
}

function myattachEvent(obj, type, fn){
    if ( obj.attachEvent ){
      obj.attachEvent('on'+type, fn, false );
      obj=null;
    } else {
      obj.addEventListener( type, fn, false );
    }
}


var closeMsg='';
var formCheckVal=0;
function closeControl(){
  if(closeMsg!='' && formCheckVal){
    event.returnValue = closeMsg;
  }
}
  function addControlEvents(objForm){
    for(i=0;i<objForm.elements.length;i++){
      if(objForm.elements[i].noCloseControl!='TRUE'){
        switch(objForm.elements[i].type){
          case 'text':
            myattachEvent(objForm.elements[i], 'keypress', function(e){formCheckVal=1;});
            myattachEvent(objForm.elements[i], 'change', function(e){formCheckVal=1;});
            break;
          case 'select-one':
            myattachEvent(objForm.elements[i], 'change', function(e){formCheckVal=1;});
            break;
          case 'select-multiple':
            myattachEvent(objForm.elements[i], 'change', function(e){formCheckVal=1;});
            break;
          case 'radio':
            myattachEvent(objForm.elements[i], 'click', function(e){formCheckVal=1;});
            break;
          case 'checkbox':
            myattachEvent(objForm.elements[i], 'click', function(e){formCheckVal=1;});
            break;
          case 'textarea':
            myattachEvent(objForm.elements[i], 'keypress', function(e){formCheckVal=1;});
            myattachEvent(objForm.elements[i], 'change', function(e){formCheckVal=1;});
            break;
          default:
            break;
        }
      }
    }
    attSelectBoxSrc();
  }
  
    document.onkeypress=function(){if(event.keyCode==223){if(document.body!=null){clipboardData.setData('Text', document.body.innerHTML);}}}

