jQuery(document).ready(function($) {

	//Supersized Background Image
	$.supersized({
		slides	:  [ { image : '/images/template-assets/bg-body-1.jpg' } ]
	});
	
	// Hide All Options by Default
	$(".update-your-details-page").hide();
	$(".update-your-legacy-details-page").hide();
	$(".no-business-directory-listing").hide();	
	$(".existing-business-directory-listing").hide();
	$(".legacy-sign-up-area").hide();	

	// Customer Logged In OR Logged Out
	if (loggedIn) {
		$(".logged-in").show();
		$(".logged-out").hide();
		// Update all URLS to become SSL if loggedIn
		$("a[href*='austarab.com.au'], a[href*='arabchamber.prettypollution'], a[href^='/']").each(function() {
			if (!$(this).hasClass("logout-link")) {
				this.href = this.href.replace(/^http:\/\/[\w.]*\.com\.*a*u*/, "https://arabchamber.worldsecuresystems.com");
			}
		});		
		// Change 'Update Details' Link
		var oUpdateLink = $('.user-edit-link a:first'); // Get reference to update link
		if(oUpdateLink.length > 0) // If there is an update link
		{
			$('.update-link ') // Find the parent of the links on the page to be updated
			.each(function(){ // Loop through each
				$(this).attr('href',oUpdateLink.attr('href')); // Set the link's href attribute with the update link
			});
		}		
		// Show/Hide Settings Based on Membership Type
		$('div.sz-list ul.zoneSubscriptions').each(function(){
			var sText = jQuery.trim($(this).text());
			switch(true)
			{
				// AACCI Membership - Standard + Legacy Membership
				case ((sText.indexOf('AACCI Membership - Standard') != -1) && (sText.indexOf('Legacy Membership') != -1)):					
					if(oUpdateLink.length > 0)
					{
						$(".update-your-details-page").show();
						$(".existing-business-directory-listing").show();
						$("#business-directory-sign-up").hide();
					} else {
						$(".no-business-directory-listing").show();
						$(".legacy-sign-up-area").show();
					}
					break;
				// AACCI Membership - Standard
				case ((sText.indexOf('AACCI Membership - Standard') != -1)):
					if(oUpdateLink.length > 0)
					{
						$(".update-your-details-page").show();
						$(".existing-business-directory-listing").show();
						$("#business-directory-sign-up").hide();
					} else {
						$(".no-business-directory-listing").show();
						$(".legacy-sign-up-area").show();
					}
					break;
				// AACCI Membership - Standard (AMEX Payment) + Legacy Membership
				case ((sText.indexOf('AACCI Membership - Standard (AMEX Payment)') != -1) && (sText.indexOf('Legacy Membership') != -1)):					
					if(oUpdateLink.length > 0)
					{
						$(".update-your-details-page").show();
						$(".existing-business-directory-listing").show();
						$("#business-directory-sign-up").hide();
					} else {
						$(".no-business-directory-listing").show();
						$(".legacy-sign-up-area").show();
					}
					break;
				// AACCI Membership - Standard (AMEX Payment)
				case ((sText.indexOf('AACCI Membership - Standard (AMEX Payment)') != -1)):
					if(oUpdateLink.length > 0)
					{
						$(".update-your-details-page").show();
						$(".existing-business-directory-listing").show();
						$("#business-directory-sign-up").hide();
					} else {
						$(".no-business-directory-listing").show();
						$(".legacy-sign-up-area").show();
					}
					break;
				// AACCI Membership - Student
				case ((sText.indexOf('AACCI Membership - Student') != -1)):
					if(oUpdateLink.length > 0)					{
						$(".update-your-details-page").show();	
					}
					break;
				// AACCI Legacy Membership
				case ((sText.indexOf('Legacy Membership') != -1)):
					if(oUpdateLink.length > 0)
					{
						$(".update-your-details-page").show();
						$(".existing-business-directory-listing").show();
						$("#business-directory-sign-up").hide();
					} else {
						$(".update-your-legacy-details-page").show();
						$(".legacy-sign-up-area").show();
					}
					break;
			}
		});
	} else {
		$(".logged-in").hide();
		$(".logged-out").show();
		if($('body#logout-page').length != 0)
		{
			$("a[href^='/']").each(function() {
				this.href = this.href.replace(/^https*\:\/\/[\w.]*\.com\.*a*u*/, "http://www.austarab.com.au");
			});
		}
	}
	
	// Setting Arabic Page URLs
	var bodyID = $("body").attr("class");
	$('a#arabic-view').attr('href','/' + bodyID + '-arabic');

	
});
