﻿
//************* Helper Functions *************
function isFireFox() {
    if (getExplorerVersion().indexOf('firefox', 0) >= 0)
        return true;

    return false;
}

function isIE() {

    if (getExplorerVersion().indexOf('msie', 0) >= 0)
        return true;

    return false;

}

function isOpera() {

    if (getExplorerVersion().indexOf('opera', 0) >= 0)
        return true;

    return false;

}

function isApple() {

    if (getExplorerVersion().indexOf('safari', 0) >= 0)
        return true;

    return false;
}

function getExplorerVersion() {

    return window.navigator.userAgent.toLowerCase();

}

var currentCategoryName = '';
var currentTab = null;
function SwitchTab(catName, divContentTab, link, versionNo) {

	if (currentCategoryName == catName)
		return;
    
    var div = document.getElementById('divContentTab');
    var img = '<div style="text-align:center;color:Green;"><br />جاري التحميل ... يرجى الانتظار<br /><br /></div>';
    div.innerHTML = img;

    // get the new content based on new category
    var req = new XMLHttpRequest();
    req.open('GET', '/_layouts/prison/GetTabsContent.aspx?cn=' + catName + '&version=' + versionNo, false);
    req.send(null);
    if (req.status == 200) {
        div.innerHTML = req.responseText;
        div.innerHTML += '<div class="more_div">&nbsp;</div>';
        currentCategoryName = catName;
    }

	if (isIE())
	{
		if (currentTab != null)
    		currentTab.parentElement.className = '';

    	link.parentElement.className = 'active';
    	currentTab = link;
	}    
	else
	{
		if (currentTab != null)
    		currentTab.parentNode.className = '';

    	link.parentNode.className = 'active';
    	currentTab = link;
	}    
    
}


$(document).ready(function() {
	<!-- FIX THE Right Menu Style Issue -->
	if ($(".leftMenuTd > table").length != 0 || $(".leftMenuTd > div").length != 0) {
		$(".leftMenuTd").css("width", "210px");
	
		if ($("#printContent").length != 0) {
			if ($("#printContent")[0].offsetWidth > 764)
				$("#printContent").addClass("printContent");
		}
	}
	else {
		if ($("#printContent").length != 0) {
			if ($("#printContent")[0].offsetWidth > 974)
				$("#printContent").addClass("printContent");
		}
	}

	<!-- FIX THE Top Menu Hover Style Issue -->
	$("div.zz1_TopNavigationMenu_0").hover(function() {
		$("#" + $(this).attr("id").substring(23, 0)).addClass("topNavHover");
		$("#" + $(this).attr("id").substring(23, 0)).find("a").addClass("topNavSelected");
	}, function() {
		$("#" + $(this).attr("id").substring(23, 0)).removeClass("topNavHover");
		$("#" + $(this).attr("id").substring(23, 0)).find("a").removeClass("topNavSelected");
	});
});
