function showSubs(subNavigation, objTrigger)
{
	var $ul = $('ul[id="' + subNavigation + '"]');
	var $trigger = objTrigger;
	
	if ($ul.length < 1) 
	{
		getPage(subNavigation.substr(4));
		return false;
	}

	var coords = $trigger.offset();
	var top = parseInt(coords.top) + 17;
	var left = parseInt(coords.left) + 275;
	
	$ul.css({
		top: top,
		left: left
	});
	
	$ul.slideToggle();
}

function getPage(navigationId)
{
	resetPageContainer();
	
	$.ajax({
		url: siteUrl + '/content/get_page/',
		type: 'POST',
		data: {
			field: 'navigation_id',
			value: navigationId
		},
		dataType: 'json',
		success: function(response) {
			$('#page-content .img').css({
				background: 'url(' + baseUrl + 'uploads/pages/' + response.image + ') no-repeat top center'
			});
			
			$('#page-content .title').html(response.title);
			
			$('#page-content .content').html(response.content);
			
			showPageContent();
		}
	});
}

function getPage2(navigationId, index) 
{ 
    index = index || 0; 
     
    resetPageContainer(); 
     
    $.ajax({ 
        url: siteUrl + '/content/get_page2/', 
        type: 'POST', 
        data: { 
            field: 'navigation_id', 
            value: navigationId, 
            index: index 
        }, 
        dataType: 'json', 
        success: function(response) { 
            $('#page-content .img').css({ 
                background: 'url(' + baseUrl + 'uploads/pages/' + response.image + ') no-repeat top center' 
            }); 
             
            $('#page-content .title').html(response.title); 
             
            $('#page-content .content').html(response.content); 
             
            code = ''; 
             
            // No need for "pagination" if single page only 
            if (response.total_pages > 1) 
            { 	
				code += '<div style="padding-left: 110px; float: left; width: 20px; height: 27px;">&nbsp;'
				
				if (index != 0)
				{
					code += '<a class="browse left" href="javascript:getPage(' + navigationId + ',' + (index - 1) + ')" style="top: -25px; height: 27px;"></a>'; 
				}
				else
				{	
					
				}
				
				code += '</div><div style="text-align: center; float: left; width: 90px;">'
				
                for(var i = 0; i < response.total_pages; i++) 
                { 
                    if (i != response.current_page) 
                    { 
                        code += '<a href="javascript:getPage(' + navigationId + ',' + i + ')" style="padding-top: 5px;">' + '&nbsp;&nbsp;' + (i + 1) + '&nbsp;&nbsp;' + '</a>'; 
                    } 
                    else  
                    { 
                        code += '&nbsp;&nbsp;' + (i + 1) + '&nbsp;&nbsp;'; 
                    } 
                }
                
                code += '</div><div style="float: left; width: 20px; height: 27px;">'
                
                if ((index + 2) <= i)
				{
					code += '<a class="browse right" href="javascript:getPage(' + navigationId + ',' + (index + 1) + ')" style="top: -10px; height: 27px; right: 1px;"></a>'; 
				}
				else
				{	
					
				} 
				
				code += '</div>'
            } 
             
            $('#page-content .pagination2').html(code); 
            
            showPageContent();
        } 
    }); 
}


function resetPageContainer()
{
	$('#page-content-wrapper').removeClass('contact-us');
	$('#page-content').html('<div class="img"></div><div class="title"></div><div style="overflow: hidden" class="content"></div><div class="pagination2" style="padding-top: 5px; background-color: #E7E8E9; height: 25px;"></div>');
}

function getNews(newsId)
{
	$(this).children('.news-title').addClass('news-title-hover');
	
	$.ajax({
		url: siteUrl + '/content/get_news/' + newsId,
		type: 'GET',
		dataType: 'json',
		success: function(response) {
			$('#news-content .title2').html(response.title);
			
			$('#news-content .content').html(response.content);
									
			$('#news-content').slideDown('normal');
		
			var newHref = "mailto:?subject=" + escape(strip_tags(response.title.replace('&amp;', 'and'))) + "&body=" + escape(strip_tags(response.content.replace('&amp;', 'and')));
			
			$('#share-mail').attr('href', (newHref).substr(newHref, '2020'));
			
			var fbHref = "http://www.facebook.com/sharer/sharer.php?u=" + siteUrl + '/content/load/' + newsId + "&t=" + escape(strip_tags(response.title.replace('&amp;', 'and')));
			
			$('#share-fb').attr('href', fbHref);
		}
	});
}

function hideNewsContent()
{
	/*$('#news-content').hide();*/
	$('#news-content').slideUp('fast');
	$('.news-title').removeClass('news-title-active');
}

function showPageContent()
{
	$('#page-content-wrapper').animate({
		'top': '50px'
	}, 500);
}

function hidePageContent()
{
	$('#page-content-wrapper').animate({
		'top': '-600px'
	}, 500);
}

function hideSubNav()
{
	$('ul[id^="sub-"]').hide();
	$('#navigation').children('a(:not(this)).nav-active').animate({
		width: '212px'
	}).removeClass('nav-active');
}

function getLandingContent(navigationId)
{
	var $obj = $('#sub-' + navigationId);
	
	$('a[id^="sub-"][id!="#sub-' + navigationId + '"]').removeClass('nav-active').css({	
		backgroundColor: 'transparent',
		color: '#0066b1'
	});
	
	$obj.addClass('nav-active').animate({
		backgroundColor: '#0066b1',
		color: '#fff'
	});
	
	var url = siteUrl + '/content/get_page';
	var dataType = 'json';
	
	
	switch (navigationId)
	{
		
		case '48':
			// history
			url = siteUrl + '/content/history';
			dataType = 'html'
			break;
		// Added by Revor Quebec
		
		
		case '77':
			// news
			url = siteUrl + '/content/news';
			dataType = 'html'
			break;
		// Added by Edjie Santos
		
		
		case '78':
			// speech
			url = siteUrl + '/content/speech';
			dataType = 'html'
			break;
		// Added by Edjie Santos

	}
		
	$('#content').css('margin-top', '0px');
	
	$.ajax({
		url: url,
		type: 'POST',
		data: {
			field: 'navigation_id',
			value: navigationId
		},
		dataType: dataType,
		success: function(response) {
			if (response.content) $('#content').html(response.content);
			else $('#content').html(response);
		}
	});
}
// Added by Revor Quebec

/*
function getBoard(boardId)
{
	$.ajax({
		url: siteUrl + '/content/get_board/' + boardId,
		type: 'GET',
		dataType: 'json',
		success: function(response) {
			$('#board_pic').attr('src', baseUrl + 'images/board/' + response.image);
			$('#board_content').html(response.content);
			$('#board_name').text(response.first_name + ' ' + response.middle_name + ' ' + response.last_name);
			$('#board_position').html(response.position + '<br />' + response.company);
		}
	});
}
// Added by Revor Quebec

function getManagement(managementId)
{
	$.ajax({
		url: siteUrl + '/content/get_management/' + managementId,
		type: 'GET',
		dataType: 'json',
		success: function(response) {
			$('#management_pic').attr('src', baseUrl + 'images/management/' + response.image);
			$('#management_content').html(response.content);
			$('#management_name').text(response.first_name + ' ' + response.middle_name + ' ' + response.last_name);
			$('#management_position').html(response.position + '<br />' + response.company);
		}
	});
}
*/

function getContactUs()
{
	hideSubNav();
	hidePageContent();
	
	setTimeout(function() {
		$('#page-content').html($('#contact_us').html());
		$('#page-content-wrapper').addClass('contact-us');
		showPageContent();
	}, 800);
	
}

