
function setNav(activeElm) {
	
	if( activeElm != '' ) {
		var targetElm = $('li.' + activeElm);
		targetElm.each( function(i) {
			var currentItem = $(targetElm[i]);
			currentItem.addClass('active');
			currentItem.find('> a').addClass('active').end().parents('li').addClass('active').find('> a').addClass('active');
			
			if (currentItem.is('li.l1')){
				$('> ul', this).show();
			} else if (currentItem.is('li.l2')) {
				$(this).parent('ul').show();
			} else if (currentItem.is('li.l3')) {
				$(this).parent().parents('ul').show();
			}
			
			}
		)
		
		$('a.' + activeElm).addClass('active');
	}
	
	$('.AS_nav_default_menu li')
		.hover(
			function(){ $(this).addClass("over").find('> a').addClass("over"); },
			function(){ $(this).removeClass("over").find('> a').removeClass("over"); }
		);

}

function clear_form_elements(ele){
    $(ele).find(':input').each(function(){
        switch(this.type){
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'textarea':
                $(this).val('');
                break;
            case 'checkbox':
            case 'radio':
                this.checked = false;
        }
    });
}

$(document).ready(function(){
	$('.AS_app_latest_news li:first div.fold').show().parent().addClass('active');
	$('.AS_app_latest_news li:not(.open) div.title, ul.AS_app_faq_answers li:not(.open) div.title').click(function(){ $(this).next('div.fold').slideDown(750,"easeOutElastic").end().parent().addClass('active').siblings().not('.open').removeClass('active').find('div.fold:visible').slideUp(200,"easeOutSine")});
	$(".scrollable").scrollable({ circular: true, easing: "easeOutQuad", speed: 350 });
	$("#footerStrip img").each( function(){ $(this).tooltip({ effect: 'slide', tip: $(this).next('div'), position: 'top center', offset: [25, 0], predelay: 100, delay: 500, relative: true }) });
    
    $("#inputTerms").focus(function(){
        if ($(this).val() == "Enter keyword/s") $(this).val("");
    }).blur(function() {
        if ($(this).val() == "") $(this).val("Enter keyword/s");
    });
    $("#formSearch form").submit(function(){
        alert('Searching...');
        var i = $(this).find("input:eq(0)");
        if (i.val() == "Enter keyword/s") i.val("");
    });
    
    $("#login_email").focus(function(){
        if ($(this).val() == "Email Address") $(this).val("");
    }).blur(function() {
        if ($(this).val() == "") $(this).val("Email Address");
    });
    
    $("#id_user_id").focus(function(){
        if ($(this).val() == "User ID") $(this).val("");
    }).blur(function() {
        if ($(this).val() == "") $(this).val("User ID");
    });
    
    $("#id_password").focus(function(){
        if ($(this).val() == "Password") $(this).val("");
    }).blur(function() {
        if ($(this).val() == "") $(this).val("Password");
    });
    
    $("#formLogin form").submit(function(){
        if($("#id_user_id").val() == "User ID") $("#id_user_id").val("");
        if($("#id_password").val() == "Password") $("#id_password").val("");
    });
    
    $("#waybill_number").focus(function(){
        if($(this).val() == "Waybill Number") $(this).val("");
    }).blur(function() {
        if($(this).val() == "") $(this).val("Waybill Number");
    });
    
    $("#ref_number").focus(function(){
        if($(this).val() == "Reference Number") $(this).val("");
    }).blur(function() {
        if($(this).val() == "") $(this).val("Reference Number");
    });
    
    $("#parcel_number").focus(function(){
        if($(this).val() == "Parcel Number") $(this).val("");
    }).blur(function() {
        if($(this).val() == "") $(this).val("Parcel Number");
    });
    
    $("#track_block_form").submit(function(){
        if($("#waybill_number").val() == "Waybill Number") $("#waybill_number").val("");
        if($("#ref_number").val() == "Reference Number") $("#ref_number").val("");
        if($("#parcel_number").val() == "Parcel Number") $("#parcel_number").val("");
    });

});



