﻿//Adobe Flash Scripts
function createSWF(swf_id, swf_src, swf_w, swf_h) {
    if (AC_FL_RunContent == 0) {
        alert("This page requires AC_RunActiveContent.js.");
    } else {
        AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', swf_w,
			'height', swf_h,
			'src', swf_src,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', swf_id,
        //'bgcolor', '#ffffff',
			'name', swf_id,
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess', 'always',
			'movie', swf_src,
			'salign', ''
			); //end AC code
    }
}
function openHeaderBig() {
    $("#header_big").height(510);
}
function closeHeaderBig() {
    $("#header_big").height(167);
}

//Ajax Box Scripts
$(document).ready(ab_launch);
function ab_launch() {
    $("a.ajax_box").click(function() {
        var t = this.title || this.innerHTML || this.href;
        var urlString = /.jpg|.JPG|.jpeg|.JPEG|.png|.PNG|.gif|.GIF|.bmp|.BMP|.swf|.SWF|.flv|.FLV|.mp3|.MP3/g;
        var urlType = this.href.match(urlString);

        if ($(this).hasClass("ab_type_custom")) {
            urlType = 'custom';
        }

        if (urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif'
		|| urlType == '.JPG' || urlType == '.JPEG' || urlType == '.PNG' || urlType == '.GIF'
		|| urlType == '.bmp' || urlType == '.BMP') {
            ab_open(this.href, 'img', t, 1);
        } else if (urlType == 'custom') {
            ab_open(this.href, 'custom', t);
        } else {
            ab_open(this.href, 'url', t);
        }

        this.blur();
        return false;
    });
}

function ab_close(sp) {
    if (sp == 1) {
        $("#ab_window").hide();
        $('#ab_window').remove();
        $("#ab_overlay").hide();
        $('#ab_overlay').remove();
    } else {
        $("#ab_window").fadeOut("fast", function() {
            $("#ab_window").hide();
            $('#ab_window').remove();
            $("#ab_overlay").hide();
            $('#ab_overlay').remove();
        });
    }
    return false;
}
function ab_position() {
    var de = document.documentElement;
    var w = self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
    var h = self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;

    if (window.innerHeight && window.scrollMaxY) {
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        yScroll = document.body.offsetHeight;
    }

    if (window.innerWidth && window.scrollMaxX) {
        xScroll = window.innerWidth + window.scrollMaxX;
    } else if (document.body.scrollWidth > document.body.offsetWidth) { // all but Explorer Mac
        xScroll = document.body.scrollWidth;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
    }
    ab_win_W = $("#ab_window").width();
    ab_win_H = $("#ab_window").height();
    tx = (w - ab_win_W) / 2 + document.documentElement.scrollLeft;
    ty = (h - ab_win_H) / 2 + document.documentElement.scrollTop;
    if (tx < 0) {
        tx = 0;
    }
    if (ty < 0) {
        ty = 0;
    }
    $("#ab_window").css({ left: tx + "px", top: ty + "px" });
    $("#ab_overlay").css("height", yScroll + "px");
}
function ab_open(url, contentType, contentTitle, closeButton,ep1,ep2,ep3) {
    $(".banner_container").hide();
    $("body").append('<div id="ab_overlay" class="ab_overlay_' + contentType + '"></div><div id="ab_window"></div>');
    if (contentType == 'img') {
    	closeButton = 0;
        var imgPreloader = new Image();
        imgPreloader.onload = function() {
            $("#ab_window").append('<img id="ab_image" onclick="ab_position();" src="' + url + '" width="' + imgPreloader.width + '" height="' + imgPreloader.height + '" alt="' + contentTitle + '"/>');
            $("#ab_window").append('<div class="cbhz">&nbsp;</div>');
            
            if(ep1=="gallery"){
				$("#ab_window").append('<a class="ab_box_prev" onclick="'+ep2+'" href="javascript:void(0);"><span>geri</span></a>');
				$("#ab_window").append('<a class="ab_box_next" onclick="'+ep3+'" href="javascript:void(0);"><span>ileri</span></a>');
			}
			
			$("#ab_window").append('<a class="ab_box_close_button close_img" href="javascript:void(0);" onclick="ab_close();"><span>kapat</span></a>');
            ab_position();
            $("#ab_window").show();
            ab_position();
            //$("#ab_window").slideDown("normal");
            //setTimeout("ab_position()", 1000);
        }

        imgPreloader.src = url;
    } else if (contentType == 'url') {
        $("#ab_window").append('<div class="ab_box"><div class="ab_box_top"></div><div class="ab_box_middle"><div class="ab_box_content" id="ab_box_content"></div></div><div class="ab_box_bottom">&nbsp;</div></div>');
        $("#ab_box_content").load(url, function() {
            ab_position();
            $("#ab_window").fadeIn("normal");
        });
    } else if (contentType == 'txt') {
        $("#ab_window").append(url);
        ab_position();
        $("#ab_window").fadeIn("normal");
    } else if (contentType == 'not') {
        $("#ab_window").append('<div class="ab_box"><div class="ab_box_top"></div><div class="ab_box_middle"><div class="ab_box_content" id="ab_box_content"></div></div><div class="ab_box_bottom">&nbsp;</div></div>');
        $("#ab_box_content").append(url);
        ab_position();
        $("#ab_window").fadeIn("normal");
    } else if (contentType == 'custom') {
        $("#ab_window").append('<div class="ab_box_content_custom" id="ab_box_content"></div>');
        $("#ab_box_content").load(url, function() {
            ab_position();
            $("#ab_window").fadeIn("normal");
        });
        ab_position();
        $("#ab_window").slideDown("normal");
    } else if (contentType == 'html') {
        $("#ab_window").append(url);
        ab_position();
        $("#ab_window").fadeIn("normal");
    } else if (contentType == 'html_wbg' || contentType == 'html_wbg2') {
        $("#ab_window").append(url);
        ab_position();
        $("#ab_window").fadeIn("normal");
    } else if (contentType == 'swf') {
		var s = '<object type="application/x-shockwave-flash" data="'+url+'" width="'+ep1+'" height="'+ep2+'" id="abSwf" align="middle">';
		s += '<param name="movie" value="'+url+'" />';
		s += '<param name="quality" value="high" />';
		s += '<param name="play" value="true" />';
		s += '<param name="loop" value="true" />';
		if(ep3==1){
			s += '<param name="wmode" value="opaque" />';
		}else{
			s += '<param name="wmode" value="transparent" />';
		}
		s += '<param name="scale" value="showall" />';
		s += '<param name="menu" value="true" />';
		s += '<param name="devicefont" value="false" />';
		s += '<param name="salign" value="" />';
		s += '<param name="allowScriptAccess" value="sameDomain" />';
		s += '</object>';
		$("#ab_window").append('<div style="width:'+ep1+'px; height:'+ep2+'px;">'+s+'</div>');
		ab_position();
		$("#ab_window").fadeIn("normal");
		$("#ab_overlay").addClass("ab_overlay_img");
	}

    if (closeButton == 1) {
        $("#ab_window").append('<a class="ab_box_close_button" href="javascript:void(0);" onclick="ab_close();"><span>kapat</span></a>');
    }
    ab_position();
    $(window).resize(ab_position());
    if (contentType != 'html' && contentType != 'html_wbg') {
        $("#ab_overlay").click(ab_close);
    }
}

/*
* Tooltip script 
* powered by jQuery (http://www.jquery.com)
* 
* written by Alen Grakalic (http://cssglobe.com)
* 
* for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
*
*/



this.tooltip = function() {
    /* CONFIG */
    xOffset = -42;
    yOffset = 0;
    // these 2 variable determine popup's distance from the cursor
    // you might want to adjust to get the right result		
    /* END CONFIG */
    $(".tooltip").hover(function(e) {
        this.t = this.title || this.alt;
        $("#tooltip_container .ttc_body").html(this.t);
        yOffset = $("#tooltip_container").height() + 28;
        $("#tooltip_container")
			.css("top", (e.pageY - yOffset) + "px")
			.css("left", (e.pageX + xOffset) + "px")
			.show();
    },
	function() {
	    $("#tooltip_container").hide();
	});
    $(".tooltip").mousemove(function(e) {
        $("#tooltip_container")
			.css("top", (e.pageY - yOffset) + "px")
			.css("left", (e.pageX + xOffset) + "px");
    });
};



// starting the script on page load
$(document).ready(function() {
    //tooltip();
});


function ab_wait(txt) {
    var html = '<div class="ab_wait"><div class="ab_wait_title">Lütfen Bekleyiniz</div><div class="ab_wait_content">';
    if (txt != '') {
        //html += txt;
    }
    html += '</div><div class="loadingGif"><img src="/img/loading.gif" alt="Lütfen bekleyiniz" /></div></div>';
    ab_open(html, 'not', 'Lütfen bekleyiniz', 0);
}

function ab_popUp(obj) {
    var html = '<div class="ab_popUp"><div class="ab_popUpTitle">&nbsp;</div><div class="ab_popUpContent">';
    html += obj.html();
    html += '</div></div>';
    ab_open(html, 'not', 'Lütfen bekleyiniz', 1);
}



function setWorkTime() {
    var d1 = $('input[name="wt1"]').val();
    if ($('select[name="worktime0"]').val() == 1) {
        for (var i = 1; i <= 7; i++) {
            if ($('select[name="wt' + i + 's"]').val() == 1) {
                $('input[name="wt' + i + '"]').val(d1);
            } else {
                $('input[name="wt' + i + '"]').val("-");
            }
        }
    }
}
$(document).ready(function() {
    for (var i = 1; i <= 7; i++) {
        $('select[name="wt' + i + 's"]').change(function() {
            if ($(this).val() == -1) {
                var id = $(this).attr('name').substring(0, 3);
                $('input[name="' + id + '"]').val('-');
            }
        });
    }
});
function addFavorites(oId, ot, tObj) {
    if (oId > 0 && ot != null) {
        ab_wait('<h3>Lütfen bekleyiniz</h3><h2>Favorilere ekleniyor</h2>');
        $.post("/Users/AddFavorites",
            { "objectId": oId, "objectType": ot },
            function(xml) {
                $(xml).find('user').each(function() {
                    if ($(this).attr("total") >= 0) {
                        tObj.children(".texts").html($(this).attr("total") + " kişi");
                    }
                    if ($(this).attr("title") == "added") {
                        tObj.children(".icons").remove();
                        tObj.prepend('<span class="icons removeFavorites" onclick="removeFavorites(' + oId + ',\'' + ot + '\',$(this).parent());"><span>favorilerden çıkar</span></span>');
                    }
                    if ($(this).attr("title") == "notConnected" || $(this).attr("title") == "noUser") {
                        FB.Connect.requireSession(function() { window.location.reload(); }, function() { window.location.reload(); });
                    }
                });
                $(xml).find('fbPublish').each(function() {
                    publishOnFace(
                        $(this).find("pofName").text(),
                        $(this).find("pofHref").text(),
                        $(this).find("pofCaption").text(),
                        $(this).find("pofDescription").text(),
                        $(this).find("pofMediaType").text(),
                        $(this).find("pofMediaSrc").text(),
                        $(this).find("pofMediaHref").text(),
                        $(this).find("pofMessage").text()
                    );
                });
                ab_close();


            },
            "xml");
    } else {
        return false;
    }
}

function removeFavorites(oId, ot, tObj) {
    if (oId > 0 && ot != null) {
        ab_wait('<h3>Lütfen bekleyiniz</h3><h2>Favorilerden çıkarılıyor</h2>');
        $.post("/Users/RemoveFavorites",
            { "objectId": oId, "objectType": ot },
            function(xml) {
                $(xml).find('user').each(function() {
                    if ($(this).attr("total") >= 0) {
                        tObj.children(".texts").html($(this).attr("total") + " kişi");
                    }
                    if ($(this).attr("title") == "removed") {
                        tObj.children(".icons").remove();
                        tObj.prepend('<span class="icons addFavorites" onclick="addFavorites(' + oId + ',\'' + ot + '\',$(this).parent());"><span>favorilere ekle</span></span>');
                    }
                });
                ab_close();
            },
            "xml");
    } else {
        return false;
    }
}
function publishOnFace(pofName, pofHref, pofCaption, pofDescription, pofMediaType, pofMediaSrc, pofMediaHref, pofMessage) {

    if (fbUserId != null && fbUserId!=0) {
        FB.Connect.showPermissionDialog('publish_stream', function(perms) {
            if (!perms) {
                return;
            }
            FB.Facebook.apiClient.callMethod(
                "stream.publish",
                {
                    'uid': fbUserId,
                    'attachment': {
                        'name': pofName,
                        'href': pofHref,
                        'caption': pofCaption,
                        'description': pofDescription,
                        'media': {
                            0: {
                                'type': pofMediaType, //image
                                'src': pofMediaSrc,
                                'href': pofMediaHref
                            }
                        }
                    },
                    'message': pofMessage
                },
                function(m) {
                    //console.log(m);
                }
            );
        });
    }
}
function rateThis(oId, ot, rate, tObj) {
    if (oId > 0 && ot != null) {
        ab_wait('<h3>Lütfen bekleyiniz</h3><h2>Oylanıyor</h2>');
        $.post("/Users/Rate",
            { "objectId": oId, "objectType": ot, "rate": rate },
            function(xml) {
                $(xml).find('user').each(function() {
                    if ($(this).attr("total") >= 0) {
                        tObj.children(".texts").html($(this).attr("total") + " kişi");
                    }
                    if ($(this).attr("title") == "rated") {
                        tObj.children(".icons").remove();
                        var html = '<span class="icons">';
                        for (var i = 1; i <= 5; i++) {
                            var rp = 'P';
                            if (i < $(this).attr("rate")) {
                                rp = 'A';
                            }
                            html += '<a id="rateLink-' + i + '" class="rateIcons' + rp + '" href="javascript:void(0);" onclick="rateThis(' + oId + ',\'' + ot + '\',' + i + ',$(this).parent().parent());"><span>*</span></a>';
                        }
                        html += '</span>';
                        tObj.prepend(html);

                        prepareRateLinks();
                    }
                    if ($(this).attr("title") == "notConnected" || $(this).attr("title") == "noUser") {
                        FB.Connect.requireSession(function() { window.location.reload(); }, function() { window.location.reload(); });
                    }
                });
                $(xml).find('fbPublish').each(function() {
                    publishOnFace(
                        $(this).find("pofName").text(),
                        $(this).find("pofHref").text(),
                        $(this).find("pofCaption").text(),
                        $(this).find("pofDescription").text(),
                        $(this).find("pofMediaType").text(),
                        $(this).find("pofMediaSrc").text(),
                        $(this).find("pofMediaHref").text(),
                        $(this).find("pofMessage").text()
                    );
                });
                ab_close();


            },
            "xml");
    } else {
        return false;
    }
}
function checkEmail(inputvalue) {
    var pattern = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if (pattern.test(inputvalue)) {
        return true;
    } else {
        return false;
    }
}

function emailThis(t, u) {
    if (u == null)
        u = location.href;
    if (t == null)
        t = document.title;

    t = t.replace(/&apos;/gi, "\\\'");
    t = t.replace(/'/gi, "\\\'");
        
    var html = '<div class="abShareBox">';
    html += '<h2>Gönder</h2>';
    html += '<div class="abShareBoxContent"><div id="abShareBoxSendForm">';
    html += '<h3>Adınız ve soyadınız</h3>';
    html += '<input type="text" id="abShareBoxSendFormName" />';
    html += '<h3>E-posta adresiniz</h3>';
    html += '<input type="text" id="abShareBoxSendFormFrom" />';
    html += '<h3>Arkadaşlarınızın e-posta adresleri</h3>';
    html += '<input type="text" id="abShareBoxSendFormTo" />';
    html += ' &nbsp; <input type="button" onclick="addToEmailThisBox();" value="" class="ekle" />';
    html += '<div id="abShareBoxSendFormToWarning"></div>';
    html += '<div id="abShareBoxSendFormTos"></div>';
    html += '<h3>Mesajınız</h3>';
    html += '<textarea id="abShareBoxSendFormMessage"></textarea>';
    html += '<br /><input type="button" value="" onclick="emailThisSendEmail(\'' + t + '\',\'' + u + '\');" />';
    html += '</div>';
    html += '</div></div>';
    ab_open(html, 'not', 'Gönder', 1);
}
function addToEmailThisBox() {
    var email = $('#abShareBoxSendFormTo').val();
    $('#abShareBoxSendFormToWarning').html('');
    if (checkEmail(email)) {
        $('#abShareBoxSendFormTo').val('');
        var html = '<div id="' + email + '">' + email + ' <a href="javascript:void(0);" onclick="$(this).parent().remove();">sil</a></div>';
        $('#abShareBoxSendFormTos').append(html);
    } else {
        $('#abShareBoxSendFormToWarning').html('<h4>Lütfen geçerli bir e-posta adresi giriniz!');
    }
}
function emailThisSendEmail(t,u) {
    //ab_wait('<h3>Lütfen bekleyiniz</h3><h2>E-posta gönderiliyor</h2>');
    //t = t.replace(/'/gi, "\\\'");
    var mTitle = t;
    var mMessage = $('#abShareBoxSendFormMessage').val();
    var mHref = u;
    var mFromName = $('#abShareBoxSendFormName').val();
    var mFrom = $('#abShareBoxSendFormFrom').val();
    var mTo = $('#abShareBoxSendFormTo').val()+',';

    $('#abShareBoxSendFormTos div').each(function() {
        mTo += $(this).attr('id') + ',';
    });
    
    $.post("/Users/SendEmail",
        { "title": mTitle, "message": mMessage, "href": mHref, "fromName": mFromName, "from": mFrom, "to": mTo },
        function(xml) {
            $(xml).find('user').each(function() {
                
            });
            ab_close();
        },
        "xml");
}
function shareThis(objTitle, objUrl) {
    if (objUrl == null)
        objUrl = location.href;
    if (objTitle == null)
        objTitle = document.title;
    objTitle = objTitle.replace(/&apos;/gi, "\\\'");
    
    var html = '<div class="abShareBox">';
    html += '<h2>Paylaş</h2>';
    html += '<div class="abShareBoxContent"><ul>';
    html += '<li><a href="javascript:void(0);" onclick="fbs_click(\'' + objTitle + '\',\'' + objUrl + '\');ab_close();" class="sBLinkFb"><span>facebook</span></a></li>';
    html += '<li><a href="javascript:void(0);" onclick="tws_click(\'' + objTitle + '\',\'' + objUrl + '\');ab_close();" class="sBLinkTw"><span>twitter</span></a></li>';
    html += '<li><a href="javascript:void(0);" onclick="ffs_click(\'' + objTitle + '\',\'' + objUrl + '\');ab_close();" class="sBLinkFf"><span>friendfeed</span></a></li>';
    html += '</ul>';
    html += '</div></div>';
    ab_open(html, 'not', 'Paylaş', 1);
}
function ffs_click(t,u) {
    if(u==null)
        u = location.href;
    if (t == null)
        t = document.title;
    var url = 'http://friendfeed.com/?url=' + encodeURIComponent(u) + '&title=' + encodeURIComponent(t);
    window.open(url, '_sharer', 'toolbar=0, status=0, width=626, height=436');
    return false;
}
function tws_click(t, u) {
    if (u == null)
        u = location.href;
    if (t == null)
        t = document.title;
    var url = 'http://twitter.com/home?status=' + encodeURIComponent(t) + ' ' + encodeURIComponent(u);
    window.open(url,'_sharer', 'toolbar=0, status=0, width=626, height=436');
    return false;
}
function fbs_click(t, u) {
    if (u == null)
        u = location.href;
    if (t == null)
        t = document.title;
    var url = 'http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t);
    window.open(url,'_sharer', 'toolbar=0, status=0, width=626, height=436');
    
    return false;
}


function fbRequireSession(reloadUrl) {
    if (reloadUrl != null && reloadUrl != "") {
        FB.Connect.requireSession(function() { window.open(reloadUrl, '_self'); }, function() { window.open(reloadUrl, '_self'); });
    } else {
        FB.Connect.requireSession(function() { window.location.reload(); }, function() { window.location.reload(); });
    }
}
function flashToFace(xml) {
    $(xml).find('fbPublish').each(function() {
        publishOnFace(
                        $(this).find("pofName").text(),
                        $(this).find("pofHref").text(),
                        $(this).find("pofCaption").text(),
                        $(this).find("pofDescription").text(),
                        $(this).find("pofMediaType").text(),
                        $(this).find("pofMediaSrc").text(),
                        $(this).find("pofMediaHref").text(),
                        $(this).find("pofMessage").text()
                    );
    });
}

function onlineBasvur() {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open('http://www.akbank.com/webkredi/WingsBasvuru', '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=585,left = 265,top = 162');");
}
function oldPopUp2(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=585,left = 265,top = 162');");
} 



/*
* Tooltip script 
* powered by jQuery (http://www.jquery.com)
* 
* written by Alen Grakalic (http://cssglobe.com)
* 
* for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
*
*/



this.tooltip = function () {
    /* CONFIG */
    xOffset = -110;
    yOffset = 0;
    // these 2 variable determine popup's distance from the cursor
    // you might want to adjust to get the right result		
    /* END CONFIG */
    $(".tooltip").hover(function (e) {
        this.t = this.title || this.alt;
        $("#tooltip_container .ttc_body").html(this.t);
        yOffset = $("#tooltip_container").height() + 0;
        if ($.browser.msie == true && $.browser.version.toString().substring(0, 1) == "7")
            yOffset = $("#tooltip_container").height() + 20;
        $("#tooltip_container")
			.css("top", (e.pageY - yOffset) + "px")
			.css("left", (e.pageX + xOffset) + "px")
			.show();
    },
	function () {
	    $("#tooltip_container").hide();
	});
    $(".tooltip").mousemove(function (e) {
        $("#tooltip_container")
			.css("top", (e.pageY - yOffset) + "px")
			.css("left", (e.pageX + xOffset) + "px");
    });
};



// starting the script on page load
$(document).ready(function () {
    tooltip();
});
