﻿$(document).ready(function(){


    $("#proje-lister").click(function(event){
        event.preventDefault();		
		$("#proje-list").toggle();
	 });

    $("#close_proje_list").click(function(event){
        event.preventDefault();
        $("#proje-list").toggle();
	});
	


    if($("#tabDegis").html() == null)
        $("#tabs").tabs({ cookie: { expires: 30 } });
    else
        $("#tabs").tabs({ selected: $("#tabDegis").html(),
                          cookie: { expires: 30 }  });

    $("#tabs-in").tabs({ cookie: { expires: 30 } });
    
    $(".SpreadOnayConfirm a").mousedown(function(event){
        if(confirm("Onaylı belge üzerinde değişiklik yapılamaz.\n\nBelgeyi onaylamak istediğinize emin misiniz ?"))
        {
            $(this).trigger("click");
        }
        else
        {
            event.preventDefault();
            return false;
        }
    });
        
    $(".onayConfirm").click(function(event){
        if(confirm("Onaylı belge üzerinde değişiklik yapılamaz.\n\nBelgeyi onaylamak istediğinize emin misiniz ?"))
        {
            return true;
        }
        else
        {
            event.preventDefault();
            return false;
        }
    });
    $(".silConfirm").click(function(event){
        if(confirm("Belgeyi silmek istediğinize emin misiniz ?"))
        {
            return true;
        }
        else
        {
            event.preventDefault();
            return false;
        }
    });
    $(".TobKaydetConfirm").click(function(event){
        if(confirm("Bu işlemden sonra değişiklik yapılamaz.\n\nTip onay belgesini/belgelerinilerini oluşturmak istediğinize emin misiniz ?"))
        {
            return true;
        }
        else
        {
            event.preventDefault();
            return false;
        }
    });
    
    if($("#msg").html()!=null)
    {    
    
        $("body").append("<div id=\"msgDiv\" title=\"\"><p><span class=\"ui-icon " + $("#msg").attr('class') + "\" style=\"float:left; margin:0 7px 50px 0;\"></span>" + $("#msg").html() + "</p></div>");
  
        $("#msgDiv").dialog({   bgiframe: true,
                                modal: true,
                                width: 300,
                                width: 500,
                                buttons: {  Tamam: function() {$(this).dialog('close');}}
		                    });
    }
    
    
    $(".TakvimGoster").datepicker({ changeMonth: true,
			                        changeYear: true,
                                    clearText: 'Temizle',
                                    closeText: 'Kapat',
		                            prevText: '&#x3c;Geri',
		                            nextText: 'İleri&#x3e;',
		                            currentText: 'Bugün',
		                            monthNames: ['Ocak','Şubat','Mart','Nisan','Mayıs','Haziran','Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık'],
		                            monthNamesShort: ['Oca','Şub','Mar','Nis','May','Haz','Tem','Ağu','Eyl','Eki','Kas','Ara'],
		                            dayNames: ['Pazar','Pazartesi','Salı','Çarşamba','Perşembe','Cuma','Cumartesi'],
		                            dayNamesShort: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
		                            dayNamesMin: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
		                            dateFormat: 'dd.mm.yy', firstDay: 1,
		                            isRTL: false
		                          });

    $('#navs').superfish({
        animation: { height: 'show' },   // slide-down effect without fade-in 
        delay: 1200               // 1.2 second delay on mouseout 
    });
		                            
		                                                            
});

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

var tempX = 0
var tempY = 0
var fpFlag;
var oldKeyCode;

function getMouseXY(e) {

var posx = 0;
	var posy = 0;/*
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY || document.body) 	
	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	*/
    tempX = posx;
    tempY = posy;

    	
  return true;
}
    
function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} 

function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} 

function popitup(url,_width,_height) {
	newwindow=window.open(url,"popup","height="+_height+",width="+_width+",status=0,scrollbars=1,left = "+tempX+",top = "+tempY+"");
	if (window.focus) {newwindow.focus()}

    return false;
}
function popitupmodal(url,_width,_height) {
newwindow=window.open(url,"popup","height="+_height+",width="+_width+",status=0,scrollbars=1,left = "+tempX+",top = "+tempY+"");
	//newwindow=window.showModalDialog(url,"popup","height="+_height+",width="+_width+",status=0,scrollbars=1,left = "+tempX+",top = "+tempY+"");
	if (window.focus) {newwindow.focus()}

    return false;
}

var fpKeyControl;





window.onload = function() {

    fpKeyControl = window.document.getElementById("ctl00_MstrCPH_fpSpread1");  
    if (fpKeyControl)
    {
        fpKeyControl.onkeydown = kDown;
        fpKeyControl.onEditStart=turnFlagOff;      
        fpKeyControl.onEditStopped=turnFlagOn;      
        turnFlagOn();
    }  	    
} 


function turnFlagOn() {      
    fpFlag=true;    
}     
function turnFlagOff() {      
    fpFlag=false;    
}
function kDown() 
{
    if (fpFlag)
    {
        if(event.keyCode==37 || event.keyCode==38 || event.keyCode==39 || event.keyCode==40 ||
           event.keyCode==13 || event.keyCode==17 || event.keyCode==18) //yön tuşları, Enter, Alt, Ctrl
        { 
            var r = fpKeyControl.ActiveRow; 
            var c = fpKeyControl.ActiveCol; 
            fpKeyControl.EndEdit(); 
            //fp.SetActiveCell(r, c+1); 
        } 
        else if(event.keyCode!=113) //F2 tuşu dışında sil
        { 
            if (oldKeyCode!=17)
            {
                var r = fpKeyControl.ActiveRow; 
                var c = fpKeyControl.ActiveCol; 
                fpKeyControl.SetValue(r,c,""); 
            } 
            
        }        
    } 
    oldKeyCode = event.keyCode;   

}
function satirEkle(ctlFpSpread, ctlDDL)
{
    var nSatirSayisi = window.document.getElementById(ctlDDL).value;
    var fpSatirEkle = window.document.getElementById(ctlFpSpread);  
    for (var i=0;i<nSatirSayisi;i++)
    {
        fpSatirEkle.Add();    
    }
    

}

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function showOrHideAllDropDowns(newState) {
    
    var elements = document.documentElement.getElementsByTagName('select');
    for (var i=0; i<elements.length; i++) {
        elements[i].style.visibility = newState;
    }
}

function SinavKatilimciEgitimKontrolFormuGetir()
{
    popitup("/TSEPBWeb/Sinav/SinavKatilimciEgitimKontrolFormu.aspx",900,750);
}
function FirmaEkle()
{
    popitup("/TSEPBWeb/Firma/FirmaEkle.aspx",900,750);
}
