$(document).ready (function (){
	FireFrontgateWidgets();
});

function FireFrontgateWidgets (){
	$('a.ContactHoverLink')
		.hover(
			function(){
				$inlineImage = $(this).children('img');
				$inlineImage.attr('src', $inlineImage.attr('src').replace('.png', '-Hover.png'));
			},
			function(){
				$inlineImage = $(this).children('img');
				$inlineImage.attr('src', $inlineImage.attr('src').replace('-Hover', ''));
			}
		);
	
	try
	{
		$('marquee')
			.marquee({speed: 2000})
			.mouseover(function(){ $(this).trigger('stop');} )
			.mouseout(function(){ $(this).trigger('start'); })
	}
	catch ($exp){}
		
	try { $('#SliderContent').bxSlider({displaySlideQty: 6, moveSlideQty: 1, auto: true, autoControls: false, autoHover: false, pager: false, controls: false}); } catch($exp){}		
	try { FireBxSlider('#NewsContainer'); } catch ($exp){}
	
	$('a.FancyImageNonEffect').Fancy('image', 'none');
	
	try { $("#NationalId").mask("99999999999"); } catch($exp){}
	try { $("#GSM").mask("0-599-999-99-99"); } catch($exp){}
}

function FireBxSlider(selector)
{
	$(selector).bxSlider(
	{
		auto: true,
		autoHover: true,
		controls: false,
   		autoControls: false,
		infiniteLoop: false,
		prevText: 'Önceki',
		nextText: 'Sonraki',
		pager: true,
		pagerActiveClass: 'Active',
		speed: 1000,
		pause: 5000
	});
}

jQuery.fn.FancyForceLink = function(){
    return this.each(function(){
		source = $(this).attr('href');

		$(this).fancybox({'type': 'image', 'href': source, 'transitionIn': 'none', 'transitionOut': 'none', 'titlePosition': 'over', 'titleFormat': function(title, currentArray, currentIndex, currentOpts){ return '<span id="fancybox-title-over">Fotoğraf ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>'; }});;
    })
};

/* Homepage client scripts */

$.fn.Fancy = function (contentType, interactionEffect)
{
	return (this.each
	(
		function()
		{
			sourceHref = $(this).attr('value');
			
			$(this).fancybox(
			{
				'type': contentType,
				'href': sourceHref,
				'autoSize': true,
				'minWidth': '250',
				'minHeight': '50',
				'maxWidth': '640',
				'maxHeight': '480',
				'openEffect': interactionEffect,
				'closeEffect': interactionEffect,
				'nextEffect': interactionEffect,
				'prevEffect': interactionEffect
			});
		}
	));
}
