/*
 * project: ajax dynamic content
 * author : Mehmet BAT 
 */
$(document).ready(function () {
	/* main page news */
    $.ajax({
        type: "GET",
        url: "xml/news.xml",
        dataType: "xml",
        success: function (xml) {
            $(xml).find('news').each(function () {
                var id = $(this).attr('id');
                var title = $(this).find('title').text();
                var url = $(this).find('url').text();
                $('<div class="news" id="link_' + id + '"></div>').html('<a href="' + url + '" target="_blank">' + title + '</a>').appendTo('.newsList');
            });
        }
    });
	/* end: main page news */	
	
	/* tab fish */
    $.ajax({
		type: "GET",
		url: "xml/fish.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var id = $(this).attr('id');
				var name = $(this).find('name').text();
				var url = $(this).find('url').text();
				var images = $(this).find('images').text();
				var price = $(this).find('price').text();
				$('<div class="productBox" id="link_'+id+'"></div>').html('<h2>'+name+'</h2><span>'+price+'</span>').appendTo('.tabFish');
			});
			mBAT();
		}
	});

	/* end: tab fish */
	
	/* tab OtherSeaProduct */
    $.ajax({
		type: "GET",
		url: "xml/other_sea_product.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var id = $(this).attr('id');
				var name = $(this).find('name').text();
				var url = $(this).find('url').text();				
				var images = $(this).find('images').text();
				var price = $(this).find('price').text();
				$('<div class="productBox" id="link_'+id+'"></div>').html('<h2>'+name+'</h2><span>'+price+'</span>').appendTo('.tabOtherSeaProduct');
			});
			mBAT();
		}
	});

	/* end: tab OtherSeaProduct */
	
	/* tab salad */
    $.ajax({
		type: "GET",
		url: "xml/salad.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var id = $(this).attr('id');
				var name = $(this).find('name').text();
				var url = $(this).find('url').text();		
				var images = $(this).find('images').text();
				var price = $(this).find('price').text();
				$('<div class="productBox" id="link_'+id+'"></div>').html('<h2>'+name+'</h2><span>'+price+'</span>').appendTo('.tabSalad');
			});
			mBAT();
		}
	});

	/* end: tab salad */
	
	/* tab OtherProduct */
    $.ajax({
		type: "GET",
		url: "xml/other_product.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var id = $(this).attr('id');
				var name = $(this).find('name').text();
				var url = $(this).find('url').text();		
				var images = $(this).find('images').text();
				var price = $(this).find('price').text();
				$('<div class="productBox" id="link_'+id+'"></div>').html('<h2>'+name+'</h2><span>'+price+'</span>').appendTo('.tabOtherProduct');
			});
			mBAT();
		}
	});

	/* end: tab OtherProduct */
	
	
	/* tab desserts */
    $.ajax({
		type: "GET",
		url: "xml/desserts.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var id = $(this).attr('id');
				var name = $(this).find('name').text();	
				var url = $(this).find('url').text();				
				var images = $(this).find('images').text();
				var price = $(this).find('price').text();
				$('<div class="productBox" id="link_'+id+'"></div>').html('<h2>'+name+'</h2><span>'+price+'</span>').appendTo('.tabDesserts');
			});
			mBAT();
		}
	});

	/* end: tab desserts */
	
	/* tab drinks */
    $.ajax({
		type: "GET",
		url: "xml/drinks.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var id = $(this).attr('id');
				var name = $(this).find('name').text();				
				var images = $(this).find('images').text();
				var price = $(this).find('price').text();
				$('<div class="productBox" id="link_'+id+'"></div>').html('<h2>'+name+'</h2><span>'+price+'</span>').appendTo('.tabDrinks');
			});
		}
	});

	/* end: tab drinks */
	
	
	/* fish week */
    $.ajax({
		type: "GET",
		url: "xml/fish_week.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var name = $(this).find('name').text();				
				var images = $(this).find('images').text();				
				$('<div class="fishOfTheWeek"></div>').html('<span>'+name+'</span><div class="fishWeek"><img src="images/fishWeek/'+images+'.jpg" width="237" height="116" alt="Haftanın Balığı" /></div>').appendTo('.rightContainer');
			});
		}
	});

	/* end: fish week */
	
	
	/* Lightbox */
	function mBAT(){
		$("a#big").fancybox({
			'overlayShow'	: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic'
		});	
	}
	/* end: Lightbox */	

    /* **** En Page **** */	
	/* main page news */
    $.ajax({
        type: "GET",
        url: "../xml/news.xml",
        dataType: "xml",
        success: function (xml) {
            $(xml).find('news').each(function () {
                var id = $(this).attr('id');
                var title = $(this).find('title').text();
                var url = $(this).find('url').text();
                $('<div class="news" id="link_' + id + '"></div>').html('<a href="' + url + '" target="_blank">' + title + '</a>').appendTo('.newsListEn');
            });
        }
    });
	/* end: main page news */	
	
	/* tab fish */
    $.ajax({
		type: "GET",
		url: "../xml/fish.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var id = $(this).attr('id');
				var name = $(this).find('name').text();
				var url = $(this).find('url').text();
				var images = $(this).find('images').text();
				var price = $(this).find('price').text();
				$('<div class="productBox" id="link_'+id+'"></div>').html('<h2>'+name+'</h2><span>'+price+'</span>').appendTo('.tabFishEn');
			});
			mBAT();
		}
	});

	/* end: tab fish */
	
	/* tab OtherSeaProduct */
    $.ajax({
		type: "GET",
		url: "../xml/other_sea_product.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var id = $(this).attr('id');
				var name = $(this).find('name').text();
				var url = $(this).find('url').text();				
				var images = $(this).find('images').text();
				var price = $(this).find('price').text();
				$('<div class="productBox" id="link_'+id+'"></div>').html('<h2>'+name+'</h2><span>'+price+'</span>').appendTo('.tabOtherSeaProductEn');
			});
			mBAT();
		}
	});

	/* end: tab OtherSeaProduct */
	
	/* tab salad */
    $.ajax({
		type: "GET",
		url: "../xml/salad.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var id = $(this).attr('id');
				var name = $(this).find('name').text();
				var url = $(this).find('url').text();		
				var images = $(this).find('images').text();
				var price = $(this).find('price').text();
				$('<div class="productBox" id="link_'+id+'"></div>').html('<h2>'+name+'</h2><span>'+price+'</span>').appendTo('.tabSaladEn');
			});
			mBAT();
		}
	});

	/* end: tab salad */
	
	/* tab OtherProduct */
    $.ajax({
		type: "GET",
		url: "../xml/other_product.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var id = $(this).attr('id');
				var name = $(this).find('name').text();
				var url = $(this).find('url').text();		
				var images = $(this).find('images').text();
				var price = $(this).find('price').text();
				$('<div class="productBox" id="link_'+id+'"></div>').html('<h2>'+name+'</h2><span>'+price+'</span>').appendTo('.tabOtherProductEn');
			});
			mBAT();
		}
	});

	/* end: tab OtherProduct */
	
	
	/* tab desserts */
    $.ajax({
		type: "GET",
		url: "../xml/desserts.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var id = $(this).attr('id');
				var name = $(this).find('name').text();	
				var url = $(this).find('url').text();				
				var images = $(this).find('images').text();
				var price = $(this).find('price').text();
				$('<div class="productBox" id="link_'+id+'"></div>').html('<h2>'+name+'</h2><span>'+price+'</span>').appendTo('.tabDessertsEn');
			});
			mBAT();
		}
	});

	/* end: tab desserts */
	
	/* tab drinks */
    $.ajax({
		type: "GET",
		url: "../xml/drinks.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var id = $(this).attr('id');
				var name = $(this).find('name').text();				
				var images = $(this).find('images').text();
				var price = $(this).find('price').text();
				$('<div class="productBox" id="link_'+id+'"></div>').html('<h2>'+name+'</h2><span>'+price+'</span>').appendTo('.tabDrinksEn');
			});
		}
	});

	/* end: tab drinks */
	
	
	/* fish week */
    $.ajax({
		type: "GET",
		url: "../xml/fish_week.xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('fish').each(function(){
				var name = $(this).find('name').text();				
				var images = $(this).find('images').text();				
				$('<div class="fishOfTheWeekEn"></div>').html('<span>'+name+'</span><div class="fishWeek"><img src="../images/fishWeek/'+images+'.jpg" width="237" height="116" alt="Haftanın Balığı" /></div>').appendTo('.rightContainerEn');
			});
		}
	});

	/* end: fish week */
	/* **** end: En Page **** */
	$(".tab li:first").trigger('click');
    $(".tab li:first").click();
	
	if(navigator.userAgent.match(/iPhone/i) || (navigator.userAgent.match(/iPod/i))){
    	$('.historyPage').css('height','auto !important');
		$('.historyText').css('height','auto !important');
		$('.newsAll').css('height','auto !important');
		$('.mainPage').css('height','auto !important');
		$('.leftContainer').css('height','auto !important');
		$('.monuPage').css('height','auto !important');
		$('.contentBox').css('height','auto !important');
	}

});
