function searchFocus() 	{ document.getElementById('top_search_txt').style.backgroundPosition = "0 -22px"; }
function searchBlur() 	{ document.getElementById('top_search_txt').style.backgroundPosition = "0 0"; }
function cropText(id, limit) {if (document.getElementById(id).innerHTML.length >= limit) {document.getElementById(id).innerHTML = document.getElementById(id).innerHTML.substring(0,limit) + '&hellip;';}}
function checkErrorDiv() {if (document.getElementById('error_div_inner')) { if (document.getElementById('error_div_inner').innerHTML.length > 0) {document.getElementById('error_div').style.display = "block";}}}
function validate_submit(formName) {if (validate_this(formName)) { document.forms[formName].submit(); }}
function hideshow(id,hideshow) {document.getElementById(id).style.display = hideshow;}
function hideshowsmart(id) {
	if (document.getElementById(id).style.display == 'block')	document.getElementById(id).style.display = 'none';
	else 														document.getElementById(id).style.display = 'block';
}
function textClear (input) { if ( input.value == input.defaultValue ) { input.value = "";}}
function textRestore (input) {if ( input.value == "" ) {input.value = input.defaultValue;}}

function setTheme(themeName) {
	if (themeName == 'Tuffpak') {
		document.getElementById('header_logo').innerHTML = '<img src="/nalpak/content/templates/common/images/tuffpak_logo.png" usemap="#TuffpakMap">';
		document.getElementById('header_logo').style.marginTop = '8px';
		document.getElementById('header_logo').style.marginLeft = '18px';
		document.getElementById('header_logo').style.width = '281px';
		document.getElementById('header_logo').style.height = '72px';
	}
	else if (themeName == 'TuffpakPro') {
		document.getElementById('header_logo').innerHTML = '<img src="/nalpak/content/templates/common/images/tuffpak_logo.png" usemap="#TuffpakMap">';
		document.getElementById('header_logo').style.marginTop = '8px';
		document.getElementById('header_logo').style.marginLeft = '18px';
		document.getElementById('header_logo').style.width = '281px';
		document.getElementById('header_logo').style.height = '72px';
		document.getElementById('header_c2').innerHTML = '<div id="hc3a_w" class="hc2 themeTuffpakIPS hc2_br"><a href="/satisfaction-guarantee">NALPAK\'S SATISFACTION GUARANTEE</a></div><div id="hc3b_w" class="hc2 themeTuffpakIPS hc2_br"><a href="/warranty">LIFETIME WARRANTY</a></div><div id="hc3c_w" class="hc2 themeTuffpakIPS hc2_br"><a href="/join-our-email-list">JOIN OUR EMAIL LIST</a></div><div id="hc3d_w" class="hc2 themeTuffpakIPS"><a href="/news">NEWS</a></div>';
	}
	else if (themeName == 'TuffpakSport') {
		document.getElementById('header_logo').innerHTML = '<img src="/nalpak/content/templates/common/images/tuffpak_sport_logo.png" usemap="#TuffpakSportMap">';
		document.getElementById('header_logo').style.marginTop = '3px';
		document.getElementById('header_logo').style.marginLeft = '18px';
		document.getElementById('header_logo').style.width = '281px';
		document.getElementById('header_logo').style.height = '72px';
		document.getElementById('header_c2').innerHTML = '<div id="hc2TPSa_w" class="hc2 themeTuffpakIPS hc2_br"><a href="/satisfaction-guarantee">NALPAK\'S SATISFACTION GUARANTEE</a></div><div id="hc2TPSb_w" class="hc2 themeTuffpakIPS hc2_br"><a href="/warranty">LIFETIME WARRANTY</a></div><div id="hc2TPSc_w" class="hc2 themeTuffpakIPS hc2_br"><a href="/join-our-email-list">JOIN OUR EMAIL LIST</a></div><div id="hc2TPSd_w" class="hc2 themeTuffpakIPS hc2_br"><a href="/news">NEWS</a></div><div id="hc2TPSe_w" class="hc2 themeTuffpakIPS hc2_br"><a href="/sci-chapters">SCI CHAPTERS</a></div><div id="hc2TPSf_w" class="hc2 themeTuffpakIPS"><a href="/catalog">CATALOG</a></div>';
	}
	else if (themeName == 'TuffpakIndustrial') {
		document.getElementById('header_logo').innerHTML = '<img src="/nalpak/content/templates/common/images/tuffpak_logo.png" usemap="#TuffpakMap">';
		document.getElementById('header_logo').style.marginTop = '8px';
		document.getElementById('header_logo').style.marginLeft = '18px';
		document.getElementById('header_logo').style.width = '281px';
		document.getElementById('header_logo').style.height = '72px';
		document.getElementById('header_c2').innerHTML = '<div id="hc2TPa_w" class="hc2 themeTuffpakIPS hc2_br"><a href="/satisfaction-guarantee">NALPAK\'S SATISFACTION GUARANTEE</a></div><div id="hc2TPb_w" class="hc2 themeTuffpakIPS hc2_br"><a href="/warranty">LIFETIME WARRANTY</a></div><div id="hc2TPc_w" class="hc2 themeTuffpakIPS hc2_br"><a href="/join-our-email-list">JOIN OUR EMAIL LIST</a></div><div id="hc2TPd_w" class="hc2 themeTuffpakIPS hc2_br"><a href="/news">NEWS</a></div><div id="hc2TPe_w" class="hc2 themeTuffpakIPS"><a href="/government-military">GOVERNMENT & MILITARY</a></div>';
	}
}

function loadjscssfile(filename, filetype){
	if (filetype=="js"){ //if filename is a external JavaScript file
		var fileref=document.createElement('script')
		fileref.setAttribute("type","text/javascript")
		fileref.setAttribute("src", filename)
	} else if (filetype=="css"){ //if filename is an external CSS file
		var fileref=document.createElement("link")
		fileref.setAttribute("rel", "stylesheet")
		fileref.setAttribute("type", "text/css")
		fileref.setAttribute("href", filename)
	}
	if (typeof fileref!="undefined")
		document.getElementsByTagName("head")[0].appendChild(fileref)
}

function addslashes (str) {
    return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
}
function stripslashes (str) {
    return (str + '').replace(/\\(.?)/g, function (s, n1) {
        switch (n1) {
        case '\\':
            return '\\';
        case '0':
            return '\u0000';
        case '':
            return '';
        default:
            return n1;
        }
    });
}

/** ONLOAD FUNCTIONS **/
$(document).ready(function() {
	checkErrorDiv();
	if (document.getElementById('prdd_accessories_content')) {if (document.getElementById('prdd_accessories_content').innerHTML.length > 0) { hideshow('prdd_accessories','block'); }}
	if (document.getElementById('prdd_recommender_content')) { if (document.getElementById('prdd_recommender_content').innerHTML.length > 31) { hideshow('prdd_recommender','block'); }}
	if (document.getElementById('shopcart_recommender_content')) { if (document.getElementById('shopcart_recommender_content').innerHTML.length > 50) { hideshow('shopcart_recommender','block'); }}	
	if (document.getElementById('errorDivInner')) { if (document.getElementById('errorDivInner').innerHTML.length > 0) { hideshow('errorDiv','block'); }}
});
