

$(document).ready(function(){

    listSiteTabURL = 'http://www.processingtimes.com/';
	
	$().SPServices({
		operation: "GetListItems",
		webURL: listSiteTabURL, 
		listName: 'Tabs',
		async: false,
		completefunc: function (xData, Status) {
			$(xData.responseXML).find('[nodeName=z:row]').each(function() { 
				var i = 1; 
				var tabSide = $(this).attr("ows_Location"); 
				var titleTabName = $(this).attr("ows_Title"); 
				var urlTab = $(this).attr("ows_Tab_x0020_Link");
				var tabPullDown = $(this).attr("ows_Pull_x0020_Down");
				var listName = $(this).attr("ows_ListName");
				var listSiteURL = $(this).attr("ows_ListSiteURL");
				var titleTabID = 'zz1_TopNavigationMenun' + titleTabName.replace(/[-' ']/g,'');
				var showTabPD = titleTabID + 'Show';
				var showTabAppend = titleTabID + 'Append';
				
				if (urlTab != null) {
					var urlTabShow = 'href=' + urlTab;
				} else {
					var urlTabShow = '';
				}

				if (tabPullDown == true) {
					var tabImage = '<img style="border-style:none; vertical-align:top;" alt="" src="/_layouts/images/menudark.gif">';
					var pullDown = '<div style="position:absolute;height: 0px;z-index:1;"><div id="' + showTabPD + '" class="zz1_TopNavigationMenu_8" style="display:none;position:relative;top:0px; clip: rect(auto, auto, auto, auto);z-index:1;"><table cellspacing="0" cellpadding="0" border="0" style="top: 0px;" id="' + showTabAppend + '"></table></div></div>';
				} else {
					var tabImage = '';
					var pullDown = '';
				}

				var tableRow = '<td id="' + titleTabID + '" onkeyup="Menu_Key(event)" onmouseout="Menu_Unhover(this)" onmouseover="Menu_HoverRoot(this)"><table  width="100%" cellspacing="0" cellpadding="0" border="0" class="ms-topnav zz1_TopNavigationMenu_4"><tbody><tr id="mouse"><td style="white-space: nowrap;"><a ' + urlTabShow + ' style="border-style: none; font-size: 1em;" class="zz1_TopNavigationMenu_1 ms-topnav zz1_TopNavigationMenu_3">'	+ titleTabName + '</a><td valign="top" style="width:0pt;" >'+ tabImage +'</td></tr></tbody></table>'+ pullDown +'</td>';
				
				if (tabSide == 'Left') {
					$('table#zz1_TopNavigationMenu').children().children().prepend(tableRow);
				} else {
					$('table#zz1_TopNavigationMenu').children().children().append(tableRow);
				}

				$().SPServices({
					operation: "GetListItems",
					webURL: listSiteURL, 
					listName: listName,
					async: false,
					completefunc: function (xData, Status) {
						$(xData.responseXML).find('[nodeName=z:row]').each(function() { 
							var URLdataTN1 = $(this).attr("ows_URL").split(','); 
							var linksTN1 = $(this).attr("ows_LinkType");
							var TabTN1 = $(this).attr("ows_Tab").split('#');
							var TabC = TabTN1[1];
							var notesVar = $(this).attr("ows_Comments");
							
							if (notesVar == null) {
								var notes = '';
							} else {
								var notes = 'title="' + notesVar + '"';
							}

							if (titleTabName == TabC) {
								if (linksTN1 == 'Header') {
									$('#' + showTabAppend).append('<tr id="zz1_TopNavigationMenun' + i + '" onkeyup="Menu_Key(event)" onmouseout="Menu_Unhover(this)" onmouseover="Menu_HoverDynamic(this)"><td><table cellspacing="0" cellpadding="0" border="0" width="100%" class="ms-topNavFlyOuts zz1_TopNavigationMenu_7 ms-topNavFlyOutsHover"><tbody><tr><td style="white-space: nowrap; width: 100%;"><a style="border-style: none; font-size: 1em;" class="zz1_TopNavigationMenu_1 ms-topNavFlyOuts zz1_TopNavigationMenu_6 ms-topNavFlyOutsHover" '+ notes +'><strong>' + URLdataTN1[1] + '</strong></a></td></tr></tbody></table></td></tr>');
									i++;
								} else if (linksTN1 == 'Header Link') {
									$('#' + showTabAppend).append('<tr id="zz1_TopNavigationMenun' + i + '" onkeyup="Menu_Key(event)" onmouseout="Menu_Unhover(this)" onmouseover="Menu_HoverDynamic(this)"><td><table cellspacing="0" cellpadding="0" border="0" width="100%" class="ms-topNavFlyOuts zz1_TopNavigationMenu_7 ms-topNavFlyOutsHover"><tbody><tr><td style="white-space: nowrap; width: 100%;"><a style="border-style: none; font-size: 1em;" href="' + URLdataTN1[0] + '" class="zz1_TopNavigationMenu_1 ms-topNavFlyOuts zz1_TopNavigationMenu_6 ms-topNavFlyOutsHover" '+ notes +'><strong>' + URLdataTN1[1] + '</strong></a></td></tr></tbody></table></td></tr>');
									i++;
								} else {
									$('#' + showTabAppend).append('<tr id="zz1_TopNavigationMenun' + i + '" onkeyup="Menu_Key(event)" onmouseout="Menu_Unhover(this)" onmouseover="Menu_HoverDynamic(this)"><td><table cellspacing="0" cellpadding="0" border="0" width="100%" class="ms-topNavFlyOuts zz1_TopNavigationMenu_7"><tbody><tr><td style="white-space: nowrap; width: 100%;"><a style="border-style: none; font-size: 1em;" href="' + URLdataTN1[0] + '" class="zz1_TopNavigationMenu_1 ms-topNavFlyOuts zz1_TopNavigationMenu_6" '+ notes +'>' + URLdataTN1[1] + '</a></td></tr></tbody></table></td></tr>');
									i++;
								}
							} else {
							}
						});
					}
				});

				$('#' + titleTabID).mouseover(function(){
					$('#' + showTabPD).show();
				});
				$('#' + titleTabID).mouseleave(function(){
					$('#' + showTabPD).hide();
				});
			});
		}
	});

	
});
