﻿/**************************  function lists *************************
*   Search box
*       --reset field               resetfield(element, "text");
*       --clear field               clearfield(element);
*
*
*
*
*
*
*********************************************************************/

//var $ = jQuery.noConflict();

// clear search box text
function clearfield(element) {
    $(element).attr("value", "");
}

// reset search box text
function resetfield(element, text) {
    //$(element).attr("value", text);
}

// add to favorite
function addToFavorite(url, title) {

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"false");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); 
	} else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	} else {
	    alert("Sorry, we could not detect your web browser.");
	}
}

// back button handler
// todo: ajax jquery history plugin, hmm....
function back(identifier) {
    switch (identifier) {
        case 'newsarchive':
            {
                if (history.length > 0) {
                    if (document.referrer.indexOf("News.aspx") != -1) {
                        history.go(-1);
                    }
                    else {
                        window.location = "http://www.automotivelogisticsmagazine.com/News.aspx?#news-search";
                    }
                } else {
                    window.location = "http://www.automotivelogisticsmagazine.com/News.aspx?#news-search";
                }
                break;
            }
        default:
            history.go(-1);
            break;
    }
}

// on_document_ready
$(document).ready(function() {
    $('#mainnavi ol li').hover(
        function() {
            $(this).children("ol").fadeIn();
        },
        function() {
            $(this).children("ol").fadeOut();
        }
    );

    // toggle new archive
    $('#NewsArchiveTitle').addClass('js-pointer');
    if (!$('#ctl00_cph_MainCont_newsArchiveList').hasClass('show'))
        $('#NewsArchiveTitle').next('div').hide();
    
    $('#NewsArchiveTitle').click(
        function() {
            $(this).next('div').toggle(100);
            return false;
        }
    );
	if ( $("#loginpage").length > 0 ) {
		$.scrollTo( '#loginpage', 0, 'x');
	}
});