(function($){
    $.fn.hoverIntent = function(f, g){
        // default configuration options
        var cfg = {
            sensitivity: 7,
            interval: 100,
            timeout: 500
        };
        // override configuration options with user supplied object
        cfg = $.extend(cfg, g ? {
            over: f,
            out: g
        } : f);
        
        // instantiate variables
        // cX, cY = current X and Y position of mouse, updated by mousemove event
        // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
        var cX, cY, pX, pY;
        
        // A private function for getting mouse position
        var track = function(ev){
            cX = ev.pageX;
            cY = ev.pageY;
        };
        
        // A private function for comparing current and previous mouse position
        var compare = function(ev, ob){
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            // compare mouse positions to see if they've crossed the threshold
            if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) {
                $(ob).unbind("mousemove", track);
                // set hoverIntent state to true (so mouseOut can be called)
                ob.hoverIntent_s = 1;
                return cfg.over.apply(ob, [ev]);
            }
            else {
                // set previous coordinates for next time
                pX = cX;
                pY = cY;
                // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
                ob.hoverIntent_t = setTimeout(function(){
                    compare(ev, ob);
                }, cfg.interval);
            }
        };
        
        // A private function for delaying the mouseOut function
        var delay = function(ev, ob){
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            ob.hoverIntent_s = 0;
            return cfg.out.apply(ob, [ev]);
        };
        
        // A private function for handling mouse 'hovering'
        var handleHover = function(e){
            // copy objects to be passed into t (required for event object to be passed in IE)
            var ev = jQuery.extend({}, e);
            var ob = this;
            
            // cancel hoverIntent timer if it exists
            if (ob.hoverIntent_t) {
                ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            }
            
            // if e.type == "mouseenter"
            if (e.type == "mouseenter") {
                // set "previous" X and Y position based on initial entry point
                pX = ev.pageX;
                pY = ev.pageY;
                // update "current" X and Y position based on mousemove
                $(ob).bind("mousemove", track);
                // start polling interval (self-calling timeout) to compare mouse coordinates over time
                if (ob.hoverIntent_s != 1) {
                    ob.hoverIntent_t = setTimeout(function(){
                        compare(ev, ob);
                    }, cfg.interval);
                }
                
                // else e.type == "mouseleave"
            }
            else {
                // unbind expensive mousemove event
                $(ob).unbind("mousemove", track);
                // if hoverIntent state is true, then call the mouseOut function after the specified delay
                if (ob.hoverIntent_s == 1) {
                    ob.hoverIntent_t = setTimeout(function(){
                        delay(ev, ob);
                    }, cfg.timeout);
                }
            }
        };
        
        // bind the function to the two event listeners
        return this.bind('mouseenter', handleHover).bind('mouseleave', handleHover);
    };
})(jQuery);
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend(jQuery.easing, {
    def: 'easeOutQuad',
    swing: function(x, t, b, c, d){
        //alert(jQuery.easing.default);
        return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
    },
    easeInQuad: function(x, t, b, c, d){
        return c * (t /= d) * t + b;
    },
    easeOutQuad: function(x, t, b, c, d){
        return -c * (t /= d) * (t - 2) + b;
    },
    easeInOutQuad: function(x, t, b, c, d){
        if ((t /= d / 2) < 1) 
            return c / 2 * t * t + b;
        return -c / 2 * ((--t) * (t - 2) - 1) + b;
    },
    easeInCubic: function(x, t, b, c, d){
        return c * (t /= d) * t * t + b;
    },
    easeOutCubic: function(x, t, b, c, d){
        return c * ((t = t / d - 1) * t * t + 1) + b;
    },
    easeInOutCubic: function(x, t, b, c, d){
        if ((t /= d / 2) < 1) 
            return c / 2 * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t + 2) + b;
    },
    easeInQuart: function(x, t, b, c, d){
        return c * (t /= d) * t * t * t + b;
    },
    easeOutQuart: function(x, t, b, c, d){
        return -c * ((t = t / d - 1) * t * t * t - 1) + b;
    },
    easeInOutQuart: function(x, t, b, c, d){
        if ((t /= d / 2) < 1) 
            return c / 2 * t * t * t * t + b;
        return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
    },
    easeInQuint: function(x, t, b, c, d){
        return c * (t /= d) * t * t * t * t + b;
    },
    easeOutQuint: function(x, t, b, c, d){
        return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
    },
    easeInOutQuint: function(x, t, b, c, d){
        if ((t /= d / 2) < 1) 
            return c / 2 * t * t * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
    },
    easeInSine: function(x, t, b, c, d){
        return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
    },
    easeOutSine: function(x, t, b, c, d){
        return c * Math.sin(t / d * (Math.PI / 2)) + b;
    },
    easeInOutSine: function(x, t, b, c, d){
        return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
    },
    easeInExpo: function(x, t, b, c, d){
        return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
    },
    easeOutExpo: function(x, t, b, c, d){
        return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
    },
    easeInOutExpo: function(x, t, b, c, d){
        if (t == 0) 
            return b;
        if (t == d) 
            return b + c;
        if ((t /= d / 2) < 1) 
            return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
        return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
    },
    easeInCirc: function(x, t, b, c, d){
        return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
    },
    easeOutCirc: function(x, t, b, c, d){
        return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
    },
    easeInOutCirc: function(x, t, b, c, d){
        if ((t /= d / 2) < 1) 
            return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
        return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
    },
    easeInElastic: function(x, t, b, c, d){
        var s = 1.70158;
        var p = 0;
        var a = c;
        if (t == 0) 
            return b;
        if ((t /= d) == 1) 
            return b + c;
        if (!p) 
            p = d * .3;
        if (a < Math.abs(c)) {
            a = c;
            var s = p / 4;
        }
        else 
            var s = p / (2 * Math.PI) * Math.asin(c / a);
        return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
    },
    easeOutElastic: function(x, t, b, c, d){
        var s = 1.70158;
        var p = 0;
        var a = c;
        if (t == 0) 
            return b;
        if ((t /= d) == 1) 
            return b + c;
        if (!p) 
            p = d * .3;
        if (a < Math.abs(c)) {
            a = c;
            var s = p / 4;
        }
        else 
            var s = p / (2 * Math.PI) * Math.asin(c / a);
        return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
    },
    easeInOutElastic: function(x, t, b, c, d){
        var s = 1.70158;
        var p = 0;
        var a = c;
        if (t == 0) 
            return b;
        if ((t /= d / 2) == 2) 
            return b + c;
        if (!p) 
            p = d * (.3 * 1.5);
        if (a < Math.abs(c)) {
            a = c;
            var s = p / 4;
        }
        else 
            var s = p / (2 * Math.PI) * Math.asin(c / a);
        if (t < 1) 
            return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
        return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
    },
    easeInBack: function(x, t, b, c, d, s){
        if (s == undefined) 
            s = 1.70158;
        return c * (t /= d) * t * ((s + 1) * t - s) + b;
    },
    easeOutBack: function(x, t, b, c, d, s){
        if (s == undefined) 
            s = 1.70158;
        return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
    },
    easeInOutBack: function(x, t, b, c, d, s){
        if (s == undefined) 
            s = 1.70158;
        if ((t /= d / 2) < 1) 
            return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
        return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
    },
    easeInBounce: function(x, t, b, c, d){
        return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b;
    },
    easeOutBounce: function(x, t, b, c, d){
        if ((t /= d) < (1 / 2.75)) {
            return c * (7.5625 * t * t) + b;
        }
        else 
            if (t < (2 / 2.75)) {
                return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
            }
            else 
                if (t < (2.5 / 2.75)) {
                    return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
                }
                else {
                    return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
                }
    },
    easeInOutBounce: function(x, t, b, c, d){
        if (t < d / 2) 
            return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
        return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
    }
});

$(function(){
		
	$(window).load(function(e){
		var urlstring = e.target.URL;
		var RegexUrl = new RegExp(/\/videos\//);
		if(RegexUrl.test(urlstring)){
			$('.addtoany_share_save_container').css({'position':'absolute','margin-top' : '20px','margin-left' : '0px'})
		}
	});
	
    /* DİGER İŞLER */
    $('.iscesiti-button').click(function(){
        var l = $('div.top-link');
        var lt = l.offset().top;
        $('body,html').animate({
            scrollTop: lt
        }, {
            duration: 500,
            complete: function(){
                l.addClass('focus');
            }
        }).delay(500).animate({
            opacity: 1
        }, {
            duration: 500,
            complete: function(){
            
                l.removeClass('focus');
                
            }
        })
    });
	
    var scrolnow = true;
    $(window).scroll(function(){
        var scroldiv = $('<div class="scrolltop" />');
        var args = {
            "width": "99px",
            "height": "38px",
            "z-index": 99999,
            "cursor": "pointer",
            "bottom": "50px",
            "right": "10px",
            "position": "fixed"
        };
        var wtop = $(this).scrollTop();
        if (wtop > 320) {
            if (scrolnow === true) {
                scroldiv.css(args).appendTo('body').fadeIn(1000).click(function(){
                    $('body, html').animate({
                        scrollTop: 0
                    }, 500);
                    scrolnow = true;
                })
                scrolnow = false;
            }
        }
        else {
            if (scrolnow === false) {
                $('.scrolltop').animate({
                    opacity: 0
                }, 500, function(){
                    $(this).remove();
                });
                scrolnow = true;
            }
        }
    })
    /* loading and animation image */
    
    //$('body').imgloading();
    
    $('.tg_feature_menu').children('li:first').css({
        "border-left": 0
    });
    $('.search').children('form').submit(function(){
        if ($(this).children('input[type="text"]').val() == 'Arama...') 
            return false;
    })
    $('.search').children('form').children('input[type="text"]').focus(function(){
        if (this.value == "Arama...") 
            this.value = "";
    }).blur(function(){
        if (this.value == "") 
            this.value = "Arama...";
    });
    var hovercontent = $('#hover-video-content'), hovertrue = true, t;
    
    $('.tg_feature_menu').children('li').hoverIntent(function(){
        var $this = $(this);
        
        if ('menu-item-89' == $this.attr('id')) {
            if (hovertrue === true) {
                hovertrue = false;
                hovercontent.clone().appendTo($this);
                $this.children('#hover-video-content').fadeIn(500);
            }
        }
        else {
        
            $this.children('ul:first').stop(true, true).fadeIn(200);
            
        }
    }, function(){
        var $this = $(this);
        if ('menu-item-89' == $(this).attr('id')) {
        
            $('#hover-video-content', $this).fadeOut(500, function(){
                $(this).remove();
                hovertrue = true;
            });
            
        }
        else {
        
            $(this).children('ul:first').stop(true, true).fadeOut(200);
        }
    });
    
    
    //$('.tg_feature_menu').children('li.anasayfa').children('a').html('').addClass('homeimg');
    
    $('.top-link-div').children('ul').children('li').hoverIntent(function(){
        if ($(this).children().is('ul')) {
            $(this).children('a').addClass('hover-active');
            $(this).children('ul').css({
                "position": "absolute",
                "z-index": 99
            }).fadeIn(500).children('li:first').children('a').css({
                'border-top': 0
            });
        }
    }, function(){
        $(this).children('a').removeClass('hover-active');
        $(this).children('ul').css({
            "position": "absolute"
        }).fadeOut(500);
    });
    
    $('.bookmarks').children('a').hover(function(){
        $(this).stop().animate({
            width: 120
        }, 300).siblings().stop().animate({
            width: 35
        }, 300);
    }, function(){
        $(this).stop().animate({
            width: 35
        }, 300);
    }).click(function(){
        var type = $(this).attr('rel');
        var hrefs = $(this).attr('ref');
        switch (type) {
            case 'rss2':
                window.open(hrefs);
                break;
        }
    });
    
    /* AGT TAB */
    var mosttabs = $('.most-video').children('div.tab');
    var mostwidth = mosttabs.width();
    var mostheight = mosttabs.height();
    $('.most-video').children('div.tab').remove();
    mosttabs.css({
        "width": mostwidth,
        'height': mostheight,
        'float': 'left'
    });
    $('<div class="tab-wrap" style="width:' + (mosttabs.length * mostwidth) + 'px;"/>').appendTo('.most-video');
    mosttabs.clone().appendTo('.tab-wrap');
    $('.most-video').css({
        "width": mostwidth,
        'height': mostheight,
        'overflow': 'hidden'
    });
    var tabs = $('.most-tab').children('ul').children('li');
    tabs.click(function(){
        $(this).addClass('active').siblings().removeClass('active');
        $('.tab-wrap').animate({
            marginLeft: '-' + ($(this).index() * mostwidth)
        }, 500, 'easeInOutBack');
    });
    /* FEATURE MENU */
    
    $('ul.content-menu li:not(".current-menu-item") a').hover(function(){
        $(this).stop().animate({
            paddingLeft: 20
        }, 300, "easeOutQuart");
        
        
    }, function(){
        $(this).stop().animate({
            paddingLeft: 5
        }, 300, "easeOutQuart");
        
    });    
   
   $(window).load(function(){
   		/*** hizmet ara ***/
		var hcontainer = $('#hizmetler'),
			hinput     = $('#hizmetara').find('input[type="text"]'),
			hspan      = $('#hizmetara').find('span'),
			Q;
			
		hinput.bind({
			'focus': function(){
				if ($(this).val() == 'Hizmetlerimiz Başlıklarında Ara') {
					$(this).val('')
				}
			},
			'blur': function(){
				if ($(this).val() == '') {
				
					$(this).val('Hizmetlerimiz Başlıklarında Ara');
				}
			}
		})
			
		hinput.keyup(function(){
			var dv = $(this).val();
			
			$('a', hcontainer).removeClass('select');
			hspan.html('');
			clearTimeout(Q);
			Q = setTimeout(function(){
				
				var fl = $('li[data-value*="'+dv+'"]', hcontainer),
					flc = fl.length;
					
				if(flc >  0){
					
					hspan.html('Bulunan Toplam sonuç '+ flc + ' <a href="#" class="scroll-link">İlk Sonuca git</a>');
					
					
					
					fl.each(function(){
						
						
						$('a:first',this).addClass('select');
						$(this).children('.m.button').trigger('click');
						$(this).parents().find('.m-button').each(function(){
							var _b = $(this);
							
							if(!_b.is('.m-button-open')){
								_b.trigger('click');
							}
							
						});
													
					});
					
					$('a.scroll-link').bind('click',function(e){
						$('body, html').animate({
							scrollTop : fl.eq(0).offset().top - 30
						},800);
						
						e.preventDefault();	
					})
					
					
				}
				
				
			},1000);
			
		});

   })
    
});


(function($){
    $.fn.extend({
        referanshome: function(op){
            var options = {
                imgurl: 'http://markaofis.com.tr/root_old/ref_logo/',
                imgheight: 85,
                imgwidth: 143,
                delay: 5000,
                ease: "easeInOutExpo"
            }, o = $.extend(options, op);
            var $t = $(this);
            var tw = ($t.width() - 66);
            var reflength = o.ref.length;
            var ulwidth = (reflength * (o.imgwidth + 5));
            var nextclick = Math.floor(ulwidth / tw);
            //alert(ulwidth+' - '+ nextclick);
            $t.append('<ul />');
            $t.children('ul').css({
                width: ulwidth,
                height: o.imgheight
            }).wrap('<div class="ref-home" />');
            $t.children('.ref-home').css({
                width: tw,
                height: o.imgheight
            });
            $.each(o.ref, function(i, v){
                $t.children('.ref-home').children('ul').append('<li alt="' + o.ref[i][0] + '" rel="' + o.ref[i][1] + '" style="background:#fff url(' + o.imgurl + o.ref[i][2] + ') center center no-repeat; height:' + o.imgheight + 'px; width:' + o.imgwidth + 'px;" />');
            });
            $t.children('.ref-home').children('ul').append('<div class="clear" />');
            //console.log(o.ref); 
            $t.css({
                'position': 'relative'
            }).append('<div class="ref-prev" /><div class="ref-next" />');
            $t.children('.ref-prev').css({
                height: o.imgheight,
                opacity: 0.8
            });
            $t.children('.ref-next').css({
                height: o.imgheight,
                opacity: 0.8
            });
            
            var slideleft = 0;
            slidertime = setInterval(function(){
                if (slideleft == nextclick) 
                    slideleft = 0;
                slideleft++;
                $t.children('.ref-home').children('ul').animate({
                    marginLeft: '-' + (tw * slideleft)
                }, 500, o.ease);
                
            }, o.delay);
            
            $t.hover(function(){
                clearInterval(slidertime);
            }, function(){
                slidertime = setInterval(function(){
                    if (slideleft == nextclick) 
                        slideleft = 0;
                    slideleft++;
                    $t.children('.ref-home').children('ul').animate({
                        marginLeft: '-' + (tw * slideleft)
                    }, 500, o.ease);
                    
                }, o.delay);
            });
            
            $t.children('.ref-next').hover(function(){
                $(this).stop().animate({
                    opacity: 1
                }, 500);
                
            }, function(){
                $(this).stop().animate({
                    opacity: 0.8
                }, 500)
            }).click(function(){
                if (slideleft == nextclick) 
                    slideleft = 0;
                slideleft++;
                $t.children('.ref-home').children('ul').animate({
                    marginLeft: '-' + (tw * slideleft)
                }, 500, o.ease);
                
            });
            $t.children('.ref-prev').hover(function(){
                $(this).stop().animate({
                    opacity: 1
                }, 500);
            }, function(){
                $(this).stop().animate({
                    opacity: 0.8
                }, 500)
            }).click(function(){
                if (slideleft == nextclick) 
                    slideleft = 0;
                if (slideleft != 0) 
                    slideleft--;
                $t.children('.ref-home').children('ul').animate({
                    marginLeft: '-' + (tw * slideleft)
                }, 500, o.ease);
            });
            $t.children('.ref-home').children('ul').children('li').hover(function(){
            
                var lio = $(this).offset();
                var title = $(this).attr('alt');
                $('body').append('<div class="ref-pop" style="display:none;position:absolute; left:' + (lio.left - 20) + 'px; top:' + (lio.top - 115) + 'px;">' + title + '</div>');
                $('body').find('.ref-pop').fadeIn(200);
            }, function(){
                $('body').find('.ref-pop').fadeOut(200, function(){
                    $(this).remove();
                });
            }).click(function(){
                var refhref = $(this).attr('rel');
                if (refhref != "") {
                    window.open(refhref);
                }
            });
            
        },
        fastpost: function(op){
            var o = {
                delay: 5000
            }, options = $.extend(o, op);
            /* fast post */
            var posts = $(this), postslink = posts.children('ul').children('li'), d = 0, litotal = postslink.length;
            posts.children('ul').children('li').not(':first').remove();
            t = setInterval(function(){
                posts.children('ul').children('li').fadeOut(500, function(){
                    $(this).remove();
                    posts.children('ul').append(postslink[d]).children('li').fadeIn(500);
                });
                if (d + 1 == litotal) {
                    d = 0;
                }
                else {
                    d++;
                }
            }, options.delay);
            
            posts.hover(function(){
                t = clearInterval(t);
            }, function(){
                t = setInterval(function(){
                    posts.children('ul').children('li').fadeOut(500, function(){
                        $(this).remove();
                        posts.children('ul').append(postslink[d]).children('li').fadeIn(500);
                    });
                    if (d + 1 == litotal) {
                        d = 0;
                    }
                    else {
                        d++;
                    }
                }, options.delay);
            });
            
        },
        mapsrun: function(op){
            var map = $(this);
            var bodydiv = $('<div class="top-body" />');
            var args = {
                'position': 'fixed',
                'width': '100%',
                'height': '100%',
                'top': 0,
                'left': 0,
                'z-index': 9999
            }
            bodydiv.css(args).appendTo('body');
            var ankara = '<iframe width="100%" height="100%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?msa=0&amp;msid=217200716215365090218.00046d3b0078974b493d4&amp;hl=tr&amp;ie=UTF8&amp;source=embed&amp;ll=39.928983,32.84705&amp;spn=0.00288,0.00456&amp;output=embed"></iframe>';
            $('.top-body').append(ankara);
            var closediv = $('<div class="mapsclose" />');
            var args = {
                'position': 'fixed',
                'width': '300px',
                'height': '200px',
                'top': '200px',
                'left': '-300px',
                'background-color': '#ffffff',
                'border': '1px solid #e2e2e2',
                'padding': '2em',
                'z-index': 99999
            };
            var argshtml = '<h2>Ankara Ofis </h2><p>ETİ MAH.BİRECİK SOK. GAZİ İŞ MERKEZİ KAT:2 NO:1/13 PK:06570 MALTEPE/ANKARA <br> Tel  : 312 550 50 50<br> Fax : 312 550 50 55 <br>Tel  : 212 573 01 01 <br> Fax : 212 468 82 00</p><p class="yoltarifi">Yol Tarifi Alın </a><p class="mapclose" style="padding:1em 0; color:red; font-weight:bold;">Kapatmak İçin Tıklayın</p>';
            closediv.css(args).appendTo('body').animate({
                left: 0
            }, 500).html(argshtml);
            ;
            $('.mapclose').click(function(){
                $('.mapsclose').animate({
                    left: '-300px'
                }, 500, function(){
                    $(this).remove();
                    $('.top-body').remove();
                })
            })
            $('.yoltarifi').click(function(){
                $('.top-body').html('<iframe width="100%" height="100%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=d&amp;source=s_d&amp;saddr=K%C4%B1z%C4%B1lay,+%C3%87ankaya,+Ankara,+T%C3%BCrkiye&amp;daddr=Ali+Suavi+Sk&amp;geocode=Fb0kYQIdd0_1ASlvIZ2hqk_TFDF25YPZrpOlcw%3BFTZEYQIdtjP1AQ&amp;hl=tr&amp;mra=dme&amp;mrsp=1&amp;sz=19&amp;sll=39.928855,32.846777&amp;sspn=0.001732,0.003484&amp;ie=UTF8&amp;ll=39.926005,32.849895&amp;spn=0.001732,0.003484&amp;t=h&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=d&amp;source=embed&amp;saddr=K%C4%B1z%C4%B1lay,+%C3%87ankaya,+Ankara,+T%C3%BCrkiye&amp;daddr=Ali+Suavi+Sk&amp;geocode=Fb0kYQIdd0_1ASlvIZ2hqk_TFDF25YPZrpOlcw%3BFTZEYQIdtjP1AQ&amp;hl=tr&amp;mra=dme&amp;mrsp=1&amp;sz=19&amp;sll=39.928855,32.846777&amp;sspn=0.001732,0.003484&amp;ie=UTF8&amp;ll=39.926005,32.849895&amp;spn=0.001732,0.003484&amp;t=h" style="color:#0000FF;text-align:left">Daha Büyük Görüntüle</a></small>');
            })
        },
        referanslar: function(op){
        
            var o = {
                'imgroot': '',
                data: []
            }, options = $.extend(o, op), $this = this, imglen = o.data.length, start = 0, startprev = 36;
            
            var rol = Math.ceil(imglen / 6), rolw = rol * 90;
            $this.css({
                height: 540,
                'overflow': 'hidden',
                'position': 'relative'
            });
            $('<div class="ref-top" />').appendTo($this);
            $('<div class="ref-bottom" />').appendTo($this);
            $thiswrap = $('<div id="ref_rol" style="width : 100%; height:' + rolw + 'px; position:relative;" />').appendTo($this);
            var refcontrol = [];
            for (var z = 0; z < 18; z++) {
                refcontrol[z] = true;
            }
            $animnext = function(s, n, st){
                if (refcontrol[st] == true) {
                    while (s < n) {
                        $('<div id="ref-' + s + '" rel="' + o.data[s].href + '" style="background:url(' + o.imgroot + o.data[s].url + ') center center no-repeat; cursor:pointer; width:145px; height:83px; border:1px solid #CCC; float:left; margin:0 5px 5px 0;" alt="' + o.data[s].title + '" />').appendTo($thiswrap);
                        $this.children('#ref_rol').children('div#ref-' + s).hover(function(){
                            var tref = $(this), posP = tref.offset(), pos = {
                                rt: posP.top,
                                rl: posP.left
                            }, title = tref.attr('alt');
                            $('body').append('<div class="ref-pop" style="display:none;position:absolute; left:' + (pos.rl - 20) + 'px; top:' + (pos.rt - 115) + 'px;">' + title + '</div>');
                            $('body').find('.ref-pop').fadeIn(500);
                        }, function(){
                            $('body').find('.ref-pop').fadeIn(500, function(){
                                $(this).remove();
                            });
                        }).click(function(){
                            var refhref = $(this).attr('rel');
                            if (refhref != "") {
                                window.open(refhref);
                            }
                        });
                        s++;
                    }
                    refcontrol[st] = false;
                }
            }
            
            $animnext(start, startprev, 0);
            
            $(document).keyup(function(event){
                if ('40' == event.keyCode && start != 18) {
                    start++;
                    var prev = startprev * start;
                    $animnext(prev, prev + 36, start);
                    $this.children('#ref_rol').stop(true, true).animate({
                        opacity: 0.3
                    }, 500).animate({
                        marginTop: '-' + 540 * start + 'px'
                    }, 800, "easeInOutBack").animate({
                        opacity: 1
                    }, 500);
                    
                }
                else 
                    if ('38' == event.keyCode && start != 0) {
                        start--;
                        var prev = startprev * start;
                        $animnext(prev, prev + 36, start);
                        $this.children('#ref_rol').stop(true, true).animate({
                            opacity: 0.3
                        }, 500).animate({
                            marginTop: '-' + 540 * start + 'px'
                        }, 800, "easeInOutBack").animate({
                            opacity: 1
                        }, 500);
                        
                    }
                
                //console.log(start)
            });
            $this.children('.ref-bottom').click(function(){
                start++;
                var prev = startprev * start;
                $animnext(prev, prev + 36, start);
                $this.children('#ref_rol').stop(true, true).animate({
                    opacity: 0.3
                }, 500).animate({
                    marginTop: '-' + 540 * start + 'px'
                }, 800, "easeInOutBack").animate({
                    opacity: 1
                }, 500);
            });
            $this.children('.ref-top').click(function(){
				if (start > 0) {
					start--;
					var prev = startprev * start;
					$animnext(prev, prev + 36, start);
					$this.children('#ref_rol').stop(true, true).animate({
						opacity: 0.3
					}, 500).animate({
						marginTop: '-' + 540 * start + 'px'
					}, 800, "easeInOutBack").animate({
						opacity: 1
					}, 500);
				}
            });
        },
        agttabs: function(op){
            var $this = $(this);
            var args = {
                'height': '280px',
                'width': $this.width(),
                'overflow': 'hidden'
            };
            $this.css(args);
            var tabs = $this.children('.tabs');
            tabs.not(':first').hide();
            var tabbutton = $('.top-tab').children('ul').children('li');
            var margintop = 0;
            tabbutton.click(function(){
                $(this).addClass('active-tab').siblings().removeClass('active-tab');
                var tindex = $(this).index();
                tabs.eq(tindex).fadeIn(500).siblings().hide();
                
            })
        },
        imgloading: function(op){
            var options = {
                img: true,
                name: '.loading'
            }, o = $.extend(options, op);
            var imgs = $(o.name);
            
            imgs.each(function(i){
                var imgwrap = $('<div class="img-wrap" id="img-wrap-id-' + i + ' />');
                $(this).wrap(imgwrap);
                //$(this).remove();
                //$('#img-wrap-id-'+i).html($(imgs[i]).attr('src'));
            });
            
        },
		agtPopUp : function(o){
			var po = $.extend({},{
				'img' : '',
				'time' : 1,
				'content' : $(this)
			},o);
			var p = $('<div />').css({'width' : '100%','height' : '100%','top' : '0', 'left' : '0','position' : 'absolute'}).addClass('popup-bg');
			
			var pXY = {
				left: $(window).width(),
				top: $(window).height()
			}			
			var pc = $('<div />').css({'width' : 600,'height' : 400,'z-index' : 99999999,'position' : 'fixed','left' : (pXY.left - 582) / 2,'top' : (pXY.top - 380) / 2});
			
			setTimeout(function(){
				p.appendTo('body').animate({
					opacity : 0.6
				},500,function(){
					var imgs = $('<img />').attr({'src' : po.img});
					var cikis = $('<div />').addClass('popup-cikis tool-button').attr('title','Bu Bencereyi Kapatır').bind('click',PC);
					var giris = $('<div />').addClass('popup-giris tool-button').attr('title','Yatırım Formunu Doldurmak İçin Tıklayın').bind('click',PG);
					var pd = $('<div />').addClass('button-div').append(cikis).append(giris);
					pc.append(imgs).append(pd).appendTo('body');
					$('.tool-button').agttooltip();
				});
			},po.time);			
			function PC(){
				pc.fadeOut(500,function(){
					$(this).remove();
					p.fadeOut(500,function(){
						$(this).remove();
					})
				});
			};
			function PG(){
				location.href = 'http://www.tesvik.com.tr/formlar/?ref=tesvik'; 
			};
		},
        agttooltip: function(op){
            options = {
                delay: 300
            }, option = $.extend(options, op);
            this.each(function(){
                $(this).attr({
                    'tool': $(this).attr('title')
                }).removeAttr('title');
                $(this).hover(function(){
                    var tool = $(this);
                    var tooloffset = $(this).offset(), toolElements = {
                        t: Math.floor(tooloffset.top),
                        l: tooloffset.left + (tool.width() / 2),
                        title: tool.attr('tool')
                    }, tooldiv = $('<div class="tooltip-agt" />'), toolarrow = $('<div />'), toolcss = {
                        'position': 'absolute',
                        'border': '1px solid #000',
                        'background': '#080808',
                        'padding': '2px 10px',
                        'max-width': "320px",
                        'top': (toolElements.t - 20) + "px",
                        opacity: 0,
                        'color': "#fff",
                        'font-family': "Arial",
                        'font-size': "12px",
                        'z-index': "999999999"
                    
                    }, toolarrowcss = {
                        "width": "0%",
                        "lineheight": "0%",
                        "border-bottom-width": 0,
                        "border-top-width": "6px",
                        "border-top-color": "black",
                        "border-top-style": "solid",
                        "border-right-width": "6px",
                        "border-right-color": "transparent",
                        "border-right-style": "solid",
                        "border-left-width": "6px",
                        "border-left-color": "transparent",
                        "border-left-style": "solid",
                        "position": "absolute",
                        "bottom": "-6px"
                    }
                    tooldiv.css(toolcss).html(toolElements.title).append(toolarrow.css(toolarrowcss)).appendTo('body');
                    var toolhover = $('body').children('.tooltip-agt');
                    var toolarrowhover = toolhover.children('div:first');
                    var lwidth = toolhover.width() / 2;
                    toolarrowhover.css({
                        "left": lwidth + "px"
                    });
                    
                    if (jQuery.browser.safari === true) {
                        lwidth += 5;
                    }
                    else {
                        lwidth += 0;
                    }
                    var nof = {
                        l: toolElements.l - lwidth,
                        t: toolElements.t - toolhover.height() - 15
                    };
                    toolhover.css({
                        'left': nof.l + 'px'
                    }).animate({
                        opacity: 1,
                        top: nof.t + "px"
                    }, option.delay);
                }, function(){
                    $('body').children('.tooltip-agt').remove();
                }).click(function(){
					$('body').children('.tooltip-agt').remove();
				});
            });
        }
    });
}(jQuery));

