﻿$(document).ready(function(){
	$.easy.tooltip();
	//$.easy.external();
	$.easy.rotate();
	$.easy.showhide();
	$.easy.jump();
	
	// Open PDF files in new tab
	/*
	$('a').each(function() { 
		var arr = ['.doc', '.xls', '.xlsx', '.htm', '.html', '.pdf'];
		for (var i=0; i < arr.length; i++)
		{
			var isApp = $(this).attr('href').search(arr[i]);
			if (isApp != -1)
			{
				$(this).attr('target', '_blank');
			}
		}
	});
	*/
	
	$('table td a').click(function() { 
		$(this).attr('target', '_blank');
	});
	
	if($('#document-link-top').length) {
		var documentLinkTop = $('#document-link-top');
		var documentLinkBottom = $('#document-link-bottom');
		documentLinkTop.attr('target', '_blank');
		documentLinkBottom.attr('target', '_blank');
		
		var isAppTop = documentLinkTop.attr('href').search('#');
		if(isAppTop != -1) {
			documentLinkTop.hide();
		}
		else {
			documentLinkBottom.attr('href', documentLinkTop.attr('href'));
		}
		
		var isAppBottom = documentLinkTop.attr('href').search('#');
		if(isAppBottom != -1) {
			documentLinkBottom.hide();
		}
	}
	
	// jQuery Lightbox Clone (Pretty Photo)
	//$("a[rel^='prettyPhoto'], .hnews .figure a").prettyPhoto();
	
	// jQuery Fancybox
	$(".lightbox").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayColor'		: '#000'
	});
	
	$("a[rel=prettyPhoto]").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayColor'		: '#000'
	});
	
	$(".map-link").fancybox({
		'width'				: 880,
		'height'			: 500,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'titlePosition'		: 'inside',
		'overlayColor'		: '#000'
	});
	
	// Block last item to right in table
	$("table.wide th:last-child strong").css("border-right", "0");
	$("table.wide td:last-child").css("padding-right", "0");
	
	//Last -1
	$(".breadcrumb > a").last().addClass("last-arrow");
	
	// initialize scrollable
	$(".scrollable").scrollable({
		circular: true
	}).autoscroll({
		interval: 6000
	});
	
	//scrolltop
	$("#pagetop").click(function() {
		$("html, body").animate( { scrollTop: 0 }, 'slow' );
		return false;
	});
	
	
	// jQuery BgTarget Plugin
	/*
	$(".bigtarget a").bigTarget({
		hoverClass: 'over', // CSS class applied to the click zone onHover
		clickZone : 'div:eq(0), li:eq(0)' // jQuery parent selector
	});
	*/
	
	$(".expanded").parent().addClass("expanded-list");
	$(".expanded-list ul").hide();
    $(".expanded-list span").click(function () {
        $(this).parent().children(':last-child').toggleClass("expanded");
        $(this).prev("ul").slideToggle("slow");
        return false;
    });
	
  $(".mapshow").click(function() {
		$("html, body").animate( { scrollTop: 400 }, 'slow' );
	});
	
	//$("#top .last .wrapper").hover(
	//	function(){
	//		$(this).find(".inner").stop(true, true).animate({"margin-top": 263 + "px"});
	//	},
	//	function () {
	//		$(this).find(".inner").animate({"margin-top": 177 + "px"});
	//	}
	//);
	
	// Product Filter Scripts
	$('#checkboxall').click(function () {
		$(this).parents('fieldset:eq(0)').find(':checkbox').attr('checked', this.checked);
	});
	
	$('#ProductFilterCollapser').click(function () {
		$('#categories').toggle();
		$('#ProductFilterCollapser').toggleClass('collapsed');
	});
	
	$("#ProductCategoryID").change(function() {
		if ($("#ProductCategoryID").val() == 0)
		{
			if ($("#frmProductSubCategoryIDCase").css("display") == "block")
			{
				$("#frmProductSubCategoryIDCase").hide();
			}
			if ($("#frmProductPropertiesIDCase").css("display") == "block")
			{
				$("#frmProductPropertiesIDCase").hide();
			}
			if ($("#frmProductBrandIDCase").css("display") == "block")
			{
				$("#frmProductBrandIDCase").hide();
			}
		}
		else
		{
			$("#ProductCategoryIDSpinner").show();;
			$.ajax({
			  url: "/xml/Product.Category.asp",
			  type: "POST",
			  data: "CategoryID=" + $("#ProductCategoryID").val(),
			  cache: false,
			  timeout: 40000,
			  success: function(html){
				$("#ProductSubCategoryID").html(html);
				$("#frmProductSubCategoryIDCase").show();;
				if ($("#frmProductPropertiesIDCase").css("display") == "block")
				{
					$("#frmProductPropertiesIDCase").hide();
				}
				$("#ProductCategoryIDSpinner").hide();
				$("#frmProductPropertiesIDCase").removeClass('three').addClass('four');
				$("#frmProductBrandIDCase").removeClass('four').addClass('three');
			  },
			  error: function(html){
				$("#ProductSubCategoryID").html("<option value=\"\">Kategori Seçiniz...</option>");
			  }
			});
			
			$.ajax({
			  url: "/xml/Product.Brands.asp",
			  type: "POST",
			  data: "CategoryID=" + $("#ProductCategoryID").val(),
			  cache: false,
			  timeout: 40000,
			  success: function(html){
				$("#frmProductBrandIDCase").html(html);
				if ($("#frmProductBrandIDCase").css("display") == "none")
				{
					$("#frmProductBrandIDCase").show();;
				}
			  }
			});
		}
		
	});
	$("#ProductSubCategoryID").change(function() {
		$("#ProductSubCategoryIDSpinner").show();
		$.ajax({
		  url: "/xml/Product.Properties.asp",
		  type: "POST",
		  data: "SubCategoryID=" + $("#ProductSubCategoryID").val(),
		  cache: false,
		  timeout: 40000,
		  success: function(html){
			if (html != "")
			{
				if ($("#frmProductPropertiesIDCase").css("display") == "none")
				{
					$("#frmProductPropertiesIDCase").show();;
					$("#frmProductBrandIDCase").removeClass('three').addClass('four');
					$("#frmProductPropertiesIDCase").removeClass('four').addClass('three');
				}
			}
			else
			{
				$("#frmProductPropertiesIDCase").hide();
				$("#frmProductPropertiesIDCase").removeClass('three').addClass('four');
				$("#frmProductBrandIDCase").removeClass('four').addClass('three');
			}
			$("#ProductPropertyID").html(html);
			$("#ProductSubCategoryIDSpinner").hide();
		  }
		});
		
		if ($("#ProductSubCategoryID").val() == 0)
		{
			$.ajax({
			  url: "/xml/Product.Brands.asp",
			  type: "POST",
			  data: "CategoryID=" + $("#ProductCategoryID").val(),
			  cache: false,
			  timeout: 40000,
			  success: function(html){
				$("#frmProductBrandIDCase").html(html);
				if ($("#frmProductBrandIDCase").css("display") == "none")
				{
					$("#frmProductBrandIDCase").show();;
					$("#frmProductPropertiesIDCase").removeClass('three').addClass('four');
					$("#frmProductBrandIDCase").removeClass('four').addClass('three');
					$("#ProductSubCategoryIDSpinner").hide();
				}
			  }
			});
		}
		else
		{
			$.ajax({
			  url: "/xml/Product.Subcategory.Brands.asp",
			  type: "POST",
			  data: "CategoryID=" + $("#ProductSubCategoryID").val(),
			  cache: false,
			  timeout: 40000,
			  success: function(html){
				$("#frmProductBrandIDCase").html(html);
				if ($("#frmProductBrandIDCase").css("display") == "none")
				{
					$("#frmProductBrandIDCase").show();;
					$("#frmProductPropertiesIDCase").removeClass('three').addClass('four');
					$("#frmProductBrandIDCase").removeClass('four').addClass('three');
					$("#ProductSubCategoryIDSpinner").hide();
				}
			  },
			  error: function(html){
				$("#frmProductBrandIDCase").html("");
			  }
			});
		}
	});
	
	$("#ProductPropertyID").change(function() {
		if ($("#ProductPropertyID").val() == 0)
		{
			$.ajax({
			  url: "/xml/Product.Subcategory.Brands.asp",
			  type: "POST",
			  data: "CategoryID=" + $("#ProductSubCategoryID").val(),
			  cache: false,
			  timeout: 40000,
			  success: function(html){
				$("#frmProductBrandIDCase").html(html);
				if ($("#frmProductBrandIDCase").css("display") == "none")
				{
					$("#frmProductBrandIDCase").show();;
				}
			  },
			  error: function(html){
				$("#frmProductBrandIDCase").html("");
			  }
			});
		}
		else
		{
			$.ajax({
			  url: "/xml/Product.Property.Brands.asp",
			  type: "POST",
			  data: "CategoryID=" + $("#ProductSubCategoryID").val() + "&ProductPropertyID=" + $("#ProductPropertyID").val(),
			  cache: false,
			  timeout: 40000,
			  success: function(html){
				$("#frmProductBrandIDCase").html(html);
				if ($("#frmProductBrandIDCase").css("display") == "none")
				{
					$("#frmProductBrandIDCase").hide();
				}
			  },
			  error: function(html){
				$("#frmProductBrandIDCase").html("");
			  }
			});
		}
	});
});

Cufon.replace('table.catalog-table p, #top .last h4, #content h2, h3, .product-details h4, .product-details h5, .product-details .heading-alt, #FeatureMatrix thead th, .cufon-replace, #timeline td strong, legend, fieldset.filterBox label, .nav-lang li a, .button, .button-download, #FeatureMatrix td.heading, #top .date', {hover: true});
Cufon('ul.post-list li h4 a, #FeatureMatrix td.matrixItem', {
	color: '#358356',
	textShadow: '0 1px 0 #f0f0f0',
	hover: {
		color: 'black'
	}

});


// jQuery Slider
function formatText(index, panel) {
	  return null;
  };

$(function () {
	
	$('#product-slider').anythingSlider({
		easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
		autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
		delay: 3000,                    // How long between slide transitions in AutoPlay mode
		startStopped: false,            // If autoPlay is on, this can force it to start stopped
		animationTime: 600,             // How long the slide transition takes
		hashTags: true,                 // Should links change the hashtag in the URL?
		buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
			pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
			startText: "Go",                // Start text
			stopText: "Stop",               // Stop text
			navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
	});
	
});

$(document).ready(function() {

	/* This is basic - uses default settings */
		
	/* Using custom settings */
	
	$("a#inline").fancybox({
		'hideOnContentClick': true,
		'overlayColor': '#000'
	});
	
	if (!($.cookie('IsFirstVisit')==='false')) {
		$("#inline").trigger('click');
		$.cookie('IsFirstVisit', 'false', { expires: 1 });
	}
	
	$(".foot-nav > span > a:first-child").click(function(){
		$.cookie('IsFirstVisit', 'true');
	});
	
});


