﻿ //I.C. disabling backspace back function in IE and Firefox also disabling space scroll other than INPUT in Firefox
if (typeof window.event != 'undefined')
document.onkeydown = function()
{
	var test_var=event.srcElement.tagName.toUpperCase();
  	if ((test_var != 'INPUT' && test_var != 'TEXTAREA' ) &&  event.keyCode == 32) 
    {
        return (event.keyCode != 32);
    }
	if (test_var != 'INPUT' && test_var != 'TEXTAREA')
	{
		return (event.keyCode != 8);
	}
}
else
document.onkeypress = function(e)
{
	var test_var=e.target.nodeName.toUpperCase();
   	if (test_var == 'HTML'  &&  e.keyCode == 0) 
    {
        return (e.keyCode != 0);
    }
	
	if (test_var != 'INPUT' && test_var != 'TEXTAREA')
	{
		return (e.keyCode != 8);
	}
}
// genel degiskenler
var DateFormat = 'dd.dd.dddd';
try
{
    if(Sys)
    {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(InitializePage);
    }
}
catch(e)
{
    
}

window.onload = function()
{
    SetMsgDivPosition();
}
window.onscroll = function()
{
    SetMsgDivPosition();
}

function InitializePage()
{    
   SetMsgDivPosition();
   HideInfoMsg();
   //sortables_init();
   try
    {
        document.onclick = closeMessage;
    }
    catch(e)
    {

    }
}

var infoTimer;
function HideInfoMsg()
{
    window.clearTimeout(infoTimer);
    infoTimer = window.setTimeout('closeMessage();',3000);
}
function closeMessage()
{
	var obj_jsbrand = $('jsbrand');
	if(obj_jsbrand)
	{
		obj_jsbrand.style.visibility = 'hidden';
	}
}

//// JScript File
//try
//{
//    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(InitializePage);
//}
//catch(e)
//{
//    
//}

//window.onload = function()
//{
//    InitializePage();
//}
//window.onscroll = function()
//{
//    SetMsgDivPosition();
//}

function InitializePageOld()
{    
    if(document.readyState == 'complete')
    {
        SetMsgDivPosition();        
    }
    else
    {   
        //setInterval('InitializePage()',2000);
    }       
}
function SetMsgDivPosition23()
{

    var msgDiv = $('jsBrand');
    if(msgDiv)
    {
       msgDiv.style.top = document.documentElement.scrollTop + 10;
       msgDiv.style.left = document.documentElement.clientWidth - msgDiv.clientWidth - 10;
    }    
}
function SetMsgDivPosition()
{
    
    var msgDiv = document.getElementById("jsbrand");
    var msgDiv2 = document.getElementById("jsBrand");
    
    if(msgDiv)
    {
        
        msgDiv.style.display  ="block";
        msgDiv.style.position ="fixed";
        msgDiv.style.top      ="100px";
        msgDiv.style.right    ="30px";
//        msgDiv.style.z-index  =50;
    }
        if(msgDiv2)
    {
        
        msgDiv2.style.display  ="block";
        msgDiv2.style.position ="fixed";
        msgDiv2.style.top      ="100px";
        msgDiv2.style.right    ="30px";
    }
    SetDivPosition();
}


//Canteking:modalpopuplarda buton submiti icin yazilmistir
//Not:Sayfada enableeventvalidationu kapatmaniz lazim
function Submit(eventControl)
{
       __doPostBack(eventControl,null);
}
//I.C. : checkbox ile div gösterip gizlemek için
//sayfada postback olsa bile checkbox ta visible bilgisini tutar
//ilk parametre div in IDsi 
//ikinci parametre checkbox objesi
function toggleDiv(whichLayer,obj)
{
    // dont modify style2 to style (reserved word I.C.)
    var style2 = document.getElementById(whichLayer).style;
    if (obj.checked)
    {
         style2.display = style2.display? "":"block";
     }
     else 
     {
        style2.display = style2.display? "":"none";
     }
}

function popup(url,name,width,height,scrollbars,resizable,status,toolbar,menubar,location,directories)
{    
    var winl = (screen.width - width) / 2;
    var wint = (screen.height - height) / 2;                
    var option = "top=" + wint + 
                 ",left=" + winl + 
                 ",toolbar=" + toolbar +
                 ",location=" + location +
                 ",directories=" + directories +
                 ",status=" + status +
                 ",menubar=" + menubar +
                 ",scrollbars=yes "+
                 ",resizable="  + resizable +
                 ",width=" + width +
                 ",height="+ height;
    var win1 = window.open(url,name,option);
    win1.opener = window;
}
function popup2(url,name,width,height,top,left,scrollbars,resizable,status,toolbar,menubar,location,directories)
{    
           
    var option = "top=" + top + 
                 ",left=" + left + 
                 ",toolbar=" + toolbar +
                 ",location=" + location +
                 ",directories=" + directories +
                 ",status=" + status +
                 ",menubar=" + menubar +
                 ",scrollbars=yes "+
                 ",resizable="  + resizable +
                 ",width=" + width +
                 ",height="+ height;
    var win1 = window.open(url,name,option);
    win1.opener = window;
}
function popupModalOLD(url,opener,width,height,scrollbars,resizable,status,toolbar,menubar,location,directories)
{    
    var winl = (screen.width - width) / 2;
    var wint = (screen.height - height) / 2;                
    var option = "top=" + wint + 
                 ",left=" + winl + 
                 ",toolbar=yes" +
                 ",location=" + location +
                 ",directories=" + directories +
                 ",status=" + status +
                 ",menubar=yes" +
                 ",scrollbars=yes "+
                 ",resizable="  + resizable +
                 ",width=" + width +
                 ",height="+ height;
    window.showModalDialog(url,opener,option);    
}
//Maybe IE7 Problem I.C.
function popupModal(url,opener,width,height,resizable,scroll,status)
{    
    var winl = (screen.width - width) / 2;
    var wint = (screen.height - height) / 2;    
    var option = "dialogLeft:"+ winl +
                 ";dialogTop:"+ wint +
                 ";dialogWidth:"+ width +
                 "px;dialogHeight:"+ height +
                 "px;scroll:"+ scroll +
                 ";status:"+ status +
                 ";toolbar=1;menubar=1;";
    window.showModalDialog(url,opener,option);    
}

/***********loading info label process******************/
//Divin pozisyonunu ayarlamak icin
function SetDivPosition()
{	
	var dWait = document.getElementById("Indicator");
	if (dWait == null )
		return ;
	try
		{
			
			if (window.opener==null)
			{
 				dWait.style.top=(screen.height/2)-150;
				dWait.style.left=(screen.width/2)-150;
			}
			else//popup
			{	
				dWait.style.top=300;
				dWait.style.left=300;
			}
			
	}
	catch (oException)
	{
		dWait.style.top=300;
		dWait.style.left=300;
	}
}
//Canteking:
//heryerde uzun uzun yazmiyalim diye verilen id li objeyi donderir
function $(id) 
{ 
    return document.getElementById(id); 
}
//Canteking:
//SearchBox degistiginde valueyi setlemek icin
function SearchBoxEdited(hdn)
{
    hdn.value = '';
}
function DeleteItem(objListBox,hdnID)
{
    var hdn = $(hdnID);
    var lbx = $(objListBox)
    
    for(var i = 0; i < lbx.options.length; i++ )
    {
        if(lbx.options[i] != null && lbx.options[i].selected)
        {//silinecek kayit
            if(confirm('Kayıt silinecek?'))
            {
                hdn.value = hdn.value.replace('#' + lbx.options[i].value + '#,','');  
                lbx.options[i] = null;          
            }
        }
    }
}

function HtmlEncode(strText)
{
    strText=escape(strText);
    strText=strText.replace(/%u0131/g,"%C4%B1"); //ı
    strText=strText.replace(/%DC/g,"%C3%9C"); //Ü
    strText=strText.replace(/%FC/g,"%C3%BC"); //ü
    strText=strText.replace(/%u011F/g,"%C4%9F"); //ğ
    strText=strText.replace(/%u011E/g,"%C4%9E"); // Ğ
    strText=strText.replace(/%u0130/g,"%C4%B0"); //İ
    strText=strText.replace(/%u015F/g,"%C5%9F"); //ş
    strText=strText.replace(/%u015E/g,"%C5%9E"); //Ş
    strText=strText.replace(/%E7/g,"%C3%A7"); //ç
    strText=strText.replace(/%C7/g,"%C3%87"); //Ç
    strText=strText.replace(/%F6/g,"%C3%B6");//ö
    strText=strText.replace(/%D6/g,"%C3%96"); //Ö
    return strText;
}

//onkeydown="checkTextAreaLength('txtNot', 100);"
//onchange="checkTextAreaLength('txtNot', 100);" 
//onfocus="checkTextAreaLength('txtNot', 100);"
function checkTextAreaLength(element, MaxLen) {
    elementTA = document.forms(0).elements[element];
    //elementCL = document.getElementById(element+ "CHARLEFT");//forms(0).elements[element + "CHARLEFT"];
    var StrLen = elementTA.value.length, CharsLeft = 0;
    if (StrLen == 1 && elementTA.value.substring(0, 1) == " ") {
	    elementTA.value = "";
	    StrLen = 0;
    }
    if (StrLen > MaxLen ) {
	    elementTA.value = elementTA.value.substring(0, MaxLen);
    }
    else {
	    CharsLeft = StrLen;	
    }
    //elementCL.innerText = MaxLen - CharsLeft;
}
var divInfo;
var timer;
function ShowInfo(element)
{
    window.clearTimeout(timer);

    //var parent = element.parentElement.parentElement.parentElement;//.parentElement.parentElement.parentElement;
    
    //var child = element.firstChild.firstChild.firstChild;
    var parent = element.parentNode.parentNode.parentNode;
    var child = element.firstChild.firstChild.firstChild;
    
    if(divInfo == null)
    {
        divInfo = document.createElement("div");
        divInfo.id = 'showInfo';      
        divInfo.className = 's';  
        
        document.forms[0].appendChild(divInfo);
    }
    if(parent)
    {
        divInfo.style.top = getTopPos(parent) + "px";
        divInfo.style.left = getLeftPos(parent) + "px";
        divInfo.style.visibility = 'visible';
        divInfo.innerHTML = child.innerHTML; 
        
        if(parent.width != null && parent.width != '')
        {
            divInfo.style.width = parent.width;
        }
        else
        {
            divInfo.style.width = 100;
        }
    }
}

function HideInfo()
{
    window.clearTimeout(timer);
    timer = window.setTimeout('divInfo.style.visibility = \'hidden\'',1500);
}

function getTopPos(inputObj)
{		
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML') returnValue += inputObj.offsetTop;
  }
  return returnValue;
}

function getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
}

