MYROOT = ""
var breadCrumbArr = [];
breadCrumbArr.push(["Anasayfa", MYROOT + "/default.aspx"])
breadCrumbSpecialArr = [];


function createBreadCrumb() {
    if ($("#breadcrumb").size() > 0) {
        $("#mainMenu li").each(function() {      
            if (window.location.href.indexOf($(this).children("a").attr("href")) > 0) {
                $(this).addClass("sel");
                myLink = $(this).children("a")
                breadCrumbArr.push([myLink.attr("title"), myLink.attr("href")])
            }
        })

        $("#footer li").each(function() {
            if (window.location.href.indexOf($(this).children("a").attr("href")) > 0) {
                $(this).addClass("sel");
                myLink = $(this).children("a")
                breadCrumbArr.push([myLink.attr("title"), myLink.attr("href")])
            }
        })

        $("#menu .sel").each(function() {
            myLink = $(this).children("a")
            breadCrumbArr.push([myLink.attr("title"), myLink.attr("href")])
        })

        for (var i = 0; i < breadCrumbSpecialArr.length; i++) {
            breadCrumbArr.push(breadCrumbSpecialArr[i]);
        }
        if (breadCrumbArr.length > 1) {
            _appendText = "";
            for (i = 0; i < breadCrumbArr.length - 1; i++) {
                _appendText += "<li><a href=\"" + breadCrumbArr[i][1] + "\">" + breadCrumbArr[i][0] + "</a></li>";
            }
            _appendText += "<li class=\"s\">" + breadCrumbArr[breadCrumbArr.length - 1][0] + "</li>";
            $("#breadcrumb").append(_appendText);
        }
    }
}

function pagingCreater(_obj) {
    this.itemsPerPage = _obj.itemsPerPage || 4;
    this.itemsCount = _obj.itemsCount || this.itemsPerPage;
    this.allItems = _obj.allItems || "";
    this.type = _obj.type || "ids"; // "page"
    this.activePageObject = _obj.activePageObject || null;
    this.activePage = (this.activePageObject.val() == undefined) ? 1 : parseInt(this.activePageObject.val());
    this.pageAmount = 1;
    this.allItemsArr = [];
    this.pagingContainer = _obj.pagingContainer || null;
    this.objectName = _obj.objectName || "";
    this.formName = _obj.formName || "";
    this.requestData = _obj.requestData || null;
    this.init();
    
}

pagingCreater.prototype = {
    init: function() {
        if (this.type == "ids") {
            this.allItemsArr = this.allItems.split(",");
            this.pageAmount = Math.ceil(((this.allItemsArr.length) / this.itemsPerPage));
        }
        else {
            this.pageAmount = Math.ceil(((parseInt(this.itemsCount)) / this.itemsPerPage));
        }
        if (this.pageAmount > 1) {
            str = "";
            this.pagingContainer.css("display", "block");
            if (this.activePage > 1) {
                str += "<li class='previous'><a href='?p=" + (this.activePage - 1) + "' onclick='" + this.objectName + ".postForm(" + (this.activePage - 1) + ");return false;'>Geri</a></li>";
            }

            startCount = 1;
            finishCount = this.pageAmount;
            if (this.activePage > 6) startCount = this.activePage - 6;
            if (this.pageAmount - 6 > this.activePage) finishCount = this.activePage + 6;

            for (var i = startCount; i <= finishCount; i++) {
                _txt = (i == this.activePage) ? "class='sel'" : "";
                str += "<li><a href='?p=" + i + "' " + _txt + " onclick='" + this.objectName + ".postForm(" + i + ");return false;'>" + i + "</a></li>";
            }
            if (this.activePage < this.pageAmount) {
                str += "<li class='next'><a href='?p=" + (this.activePage + 1) + "' onclick='" + this.objectName + ".postForm(" + (this.activePage + 1) + ");return false;'>Żleri</a></li>";
            }
            else {
                str += "<li><a href='#'></a></li>";
            }
            //this.pagingContainer.html(str);
            this.pagingContainer.html(str);

        }
    },

    postForm: function(_pageNumber) {

        this.activePageObject.val(_pageNumber);
        if (this.requestData != null) {
            if (this.type == "ids") {
                startPosition = (this.itemsPerPage) * (_pageNumber - 1);
                finishPosition = ((startPosition + this.itemsPerPage) >= this.allItemsArr.length) ? this.allItemsArr.length : startPosition + this.itemsPerPage;
                str = ""
                for (var i = startPosition; i < finishPosition - 1; i++) {
                    str += this.allItemsArr[i] + ","
                }
                str += this.allItemsArr[finishPosition - 1]
                this.requestData.val(str);
            }
            else {
                //sadece sayfa
            }
        }
        document.forms[this.formName].submit();
    }
}



$(document).ready(function() {
    $('#flashMenu').flash({ src: MYROOT + '/_swf/topmenu3.swf?aaayttsssssasda',
        width: 980,
        height: 95,
        wmode: 'transparent',
        flashvars: { ROOTLINK: MYROOT + '/default.aspx' }
    },
	{ version: 9, update: false }
	);
    $('#flashContainer').flash({ src: MYROOT + '/_swf/main.swf?xu55jjjufffufd',
        width: "100%",
        height: 357,
        wmode: 'transparent',
        salign: 'ct',
        scale: 'noscale',
        flashvars: { MYNEWS: MYROOT + '/_xml/news.xml', Rand: Math.random(1000) }
    },
	{ version: 9, update: false, executeCustomFunction: function() { ShowCampaign(); $("#nonFlashContent").css("background-position", "0 0"); } }
	);
    $("#mainMenu span").animate({ 'opacity': 0.0 }, 1);
    $("#mainMenu a").hover(
		 function() {
		     $(this).find("span").css("margin-top", "-14px");
		     $(this).find("span").animate({ 'opacity': 0.6 }, 250);
		 },
		  function() {
		      $(this).find("span").animate({ 'opacity': 0.0 }, 250);
		      $(this).find("span").dequeue();

		  }
	);
    // breadcrumb
    createBreadCrumb();
    $(".tableView_1").attr("cellspacing", "0");
    $(".tableView_1").attr("cellpadding", "0");
    $(".tableView_1 tbody tr:odd").addClass("sel");

    //othersites link

    $("a[href^='http']").bind("click", function() {
        if ($(this).attr("href").indexOf(window.location.hostname) < 0) {
            window.open($(this).attr("href"));
            return false;
        }
        //return false;
    })
    $("a.backBtn").bind("click", function() {
        window.history.back();
        return false;
    })

});


function checkSearchPost(_type) {
    returnStr = "";
    if (_type == "searchPage") {
        if ($("#ctl00_ContentPlaceHolder1_TextSearch").val().length > 2) {         
            return true;
        }
    } else {
        if ($("#txtSearch").val().length > 2) {
            returnStr = $("#txtSearch").val().replace(">", "&gt;").replace("<", "&lt;").replace("<", "&lt;").replace("%3C", "&lt;").replace("%3c", "&lt;").replace("%3E", "&gt;").replace("%3e", "&gt;");
            $("#txtSearch").val("");
            $("#hdnTxtSearch").val(returnStr);
            return true;
        }
    }
    return false;
}

function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function openisube() {
    theURL = "https://internetsube.turkiyefinans.com.tr/";
    var mytop = Math.abs((screen.height - 543) / 2);
    var myleft = Math.abs((screen.width - 790) / 2);
    var s = "top=" + mytop + ",left=" + myleft;
    scrll = 0;
    var brws = navigator.userAgent.toLowerCase();
    var _isIE = ((brws.indexOf("msie") != -1) && (brws.indexOf("opera") == -1)) ? true : false;

    if (_isIE) {
        myarr = navigator.appVersion.split("compatible; MSIE");
        vers = parseFloat(myarr[1].substring(1, 4));
        if (vers < 5.0) {
            window.navigate('browser.htm')
        }
        else {
            h = 543;
            if (vers == 7) { h = 563; }
            splashWin = window.open(theURL, "anadolu_isube", "toolbar=0,width=790 , height=" + h + "," + s + "; location=0, directories=0, status=1, scrollbars=" + scrll + ", menubar=0, resizable=0, copyhistory=0");
        }
    }
    else {
        Opera = (brws.indexOf("opera") != -1)
        if (Opera) { scrll = 1; }
        splashWin = window.open(theURL, "anadolu_isube", "toolbar=0,width=790 , height=546," + s + "; location=0, directories=0, status=1, scrollbars=" + scrll + ", menubar=0, resizable=0, copyhistory=0");
        //window.location.href="browser.html"
    }
}
