$(function() {
	
		
	$("#fragrance #large-copy :header").each(function(i) {
		var div = $("<div>").attr("id","tab"+(i));
		$(this).next("p").appendTo(div);	
		$(this).prependTo(div);
		div.appendTo("#scent");	
	});
	
	var urlArray = location.href.split('/');
	// The language initials should be in the fourth (index 3) spot of the split array 
	var currLang = urlArray[3];
	var menuText = {};
	switch(currLang) {
		case "ar":
			menuText = {
				topNote: "المكونات المتطايرة", 
				heartNote: "المكونات الوسطية",
				baseNote: "المكونات الأساسية",
				back: "رجوع"
			};
			break;
		case "en":
		default:
			menuText = {
				topNote: "Top Note", 
				heartNote: "The Heart",
				baseNote: "Base Note",
				back: "Back"
			};
	}
	
	var menu_tab0 = $("<ul>").addClass("scentmenumain").html("<li><a class='gototop' href='#'>" + menuText.topNote + "</a></li><li><a  href='#' class='gotoheart'>" + menuText.heartNote + "</a></li><li><a  href='#' class='gotobase'>" + menuText.baseNote + "</a></li>").appendTo("#tab0");	
	var menu_tab1 = $("<ul>").addClass("scentmenu").html("<li class='backbutton'><a class='gotomain' href='#'>" + menuText.back + "</a></li><li class='prevbutton'></li><li class='nextbutton'><a  href='#' class='gotoheart'></a></li>").appendTo("#tab1");
	var menu_tab2 = $("<ul>").addClass("scentmenu").html("<li class='backbutton'><a class='gotomain' href='#'>" + menuText.back + "</a></li><li class='prevbutton'><a  href='#' class='gototop'></a></li><li class='nextbutton'><a  href='#' class='gotobase'></a></li>").appendTo("#tab2");
	var menu_tab3 = $("<ul>").addClass("scentmenu").html("<li class='backbutton'><a class='gotomain' href='#'>" + menuText.back + "</a></li><li class='prevbutton'><a  href='#' class='gotoheart'></a></li><li class='nextbutton'></li>").appendTo("#tab3");	


				var $scent = $('#scent').tabs( {
				  fx: { opacity: 'toggle', duration: 'fast' } 
				}); // first tab selected
				$('.gotomain').click(function() { // bind click event to link
					$scent.tabs('select', 0); // switch tab
					return false;
				});
				$('.gototop').click(function() { // bind click event to link
					$scent.tabs('select', 1); // switch tab
					return false;
				});				
				$('.gotoheart').click(function() { // bind click event to link
					$scent.tabs('select', 2); // switch tab
					return false;
				});
				$('.gotobase').click(function() { // bind click event to link
					$scent.tabs('select', 3); // switch tab
					return false;
				});			
				
	$("#fragrance .tabify").attr("style","display:none;");
			});
