// JavaScript Document



function displayTabContents(id, tabId, data, location, pageName) {

		if (pageName == undefined) {

			pageName = "details";

		}

		

		if (data == undefined || data.length == 0) {

			document.getElementById(id + "_TAB_DATA_CONTENTS").className = "visible-component";

			document.getElementById(id + "_TAB_DATA_LOADER").className = "content-loading invisible-component";

		

			return;

		}

		

		var containerBoxId = id;

		var oldTabId = activeTabs[containerBoxId];

		

		document.getElementById(containerBoxId + "_TAB" + oldTabId).className = "not-selected-tab inline-right";

		document.getElementById(containerBoxId + "_TAB" + tabId).className = "selected-tab inline-right";

		

		activeTabs[containerBoxId] = tabId;



		getTabContents(id, data, location, pageName);

	}

	

	function getTabContents(id, data, type, pageName) {

		if (pageName == undefined) {

			pageName = "details";

		}

		

		if (type == 0) {

			fillTabData(id, data);

		} else if (type == 1) {	

			fillListTab(id, data, 0, pageName);

		} else if (type == 2) {

			fillTabContent(id, data);

		}

	}


	function fillTabData(id, details) {

		document.getElementById(id + "_TAB_DATA_IMAGE").src = details[0]['image'];

		document.getElementById(id + "_TAB_DATA_TITLE").innerHTML = details[0]['title'];

		document.getElementById(id + "_TAB_DATA_LINK").href = "details/" +  details[0]['serial'] + "/" +  details[0]['richurl'] + ".htm" ;

		

		document.getElementById(id + "_TAB_DATA_CONTENTS").className = "visible-component";

		document.getElementById(id + "_TAB_DATA_LOADER").className = "content-loading invisible-component";



		fillListTab(id, details, 1);

	}



	function fillListTab(id, details, start, pageName) {

		if (pageName == undefined) {

			pageName = "details";

		}

		

		if (start == undefined) {

			start = 0;

		}

		

		document.getElementById(id + "_TAB_DATA_CONTENTS").className = "visible-component";

		document.getElementById(id + "_TAB_DATA_LOADER").className = "content-loading invisible-component";

		

		var otherDetailsList = document.getElementById(id + "_TAB_DATA_LINKS");

		

		otherDetailsList.innerHTML = "";

		

		for (var i = start; i < details.length; i++) {

		

			var option = document.createElement("LI");

			

			var optionCaption = document.createElement("A");

			optionCaption.innerHTML = details[i]['title'];

			optionCaption.href = pageName + "/" +  details[i]['serial'] + "/" +  details[i]['richurl'] + ".htm" ;

			

			option.appendChild(optionCaption);

			

			otherDetailsList.appendChild(option);

		}

	}

	

	function fillTabContent(id, html) {

		document.getElementById(id + "_TAB_DATA_CONTENTS").innerHTML = html;

		

		document.getElementById(id + "_TAB_DATA_CONTENTS").className = "visible-component";

		document.getElementById(id + "_TAB_DATA_LOADER").className = "content-loading invisible-component";

	}

	

	function fillTabLinks(destination) {

		linkList = document.getElementById(destination.id + "_LIST");

		linkList.innerHTML = "";

		var links3 = new Array();

	

		links3[0] = new Array();

		links3[0][0] = 'ستة خبراء ألمان إلى مصر للمساعدة في منع التهريب';

		

		links3[1] = new Array();

		links3[1][0] = 'أوباما: حان الوقت لاستئناف مفاوضات "السلام"';

		

		links3[2] = new Array();

		links3[2][0] = 'اليمن يقدم رسمياً مبادرته للمصالحة الفلسطينية للجامعة';

		

		links3[3] = new Array();

		links3[3][0] = '"إسرائيل" العالقة في غزة تبحث عن اتفاق دولي يرضيها';

		

		links3[4] = new Array();

		links3[4][0] = 'أوباما: حان الوقت لاستئناف مفاوضات "السلام"';

		

		for (var i = 0; i < links3.length; i++) {

			var option = document.createElement("LI");

				

			var optionCaption = document.createElement("A");

			optionCaption.innerHTML = links3[i][0];

			optionCaption.href = "details/" +  links3[i]['serial'] + "/" +  links3[i]['richurl'] + ".htm" ;

				

			option.appendChild(optionCaption);

			

			linkList.appendChild(option);

		}

		

		document.getElementById(destination.id + "_CONTENTS").className = "visible-component";

		document.getElementById(destination.id + "_LOADER").className = "content-loading invisible-component";

	}