

$(document).ready(function(){

	/* --- LANGUAGE --- */
	$('#language_selectors span').each(function() { $(this).removeClass('selected') });
	$('#lang_link_'+ActiveLanguage+' span').addClass('selected');



	/* --- SIDE MENU --- */
	if (PageMenuID != '') {
		
		// Reset all classes:
		$('.current').each(function(){$(this).removeClass('current')});
		$('.path_to').each(function(){$(this).removeClass('path_to')});
		$('.related').each(function(){$(this).removeClass('path_to')});
		
		// Make current page 'current':
		$('#'+PageMenuID).addClass('current');
		
		// Parse the path of ids:
		var Levels = PageMenuID.split('-');

		// Open parent menues, if any:
		if (Levels.length > 1) {
		
			var theIDPath = Levels[0];
		
			$('#'+theIDPath+'_ul').show();
			$('#'+theIDPath).addClass('path_to');
			
			for (i=1; i<Levels.length-1; i++) {
				theIDPath += '-' + Levels[i];
				
				$('#'+theIDPath+'_ul').slideDown('slow');
				$('#'+theIDPath).addClass('path_to');
				
			}
		}

		// Open this page's submenue, if any:
		$('#'+PageMenuID+'_ul').slideDown();


		// if its products.html, show all products:
		if (PageMenuID == 'products') {
			$('#products-homeoffice_ul').slideDown('slow');
			$('#products-industrial_ul').slideDown('slow');
		
		}


		
		// Make 'the others' (homeoffice vs. industrial) a 'ghost'
		if ( Levels[1] != '' && Levels[1] != undefined) {
			var theOthers = Levels[1] == 'homeoffice' ? 'industrial' : 'homeoffice';
			$('[id*='+theOthers+']').each(function(){ $(this).addClass('ghost') });
		}		

	}

	
	/* --- TRITON MOBILE TABS --- */
	$('#triton_mobile_mods_ul li').each(function(){
		
		$(this).click(function(evt){
			
			// Make all tabs unselected:
			$('#triton_mobile_mods_ul li').each(function(){$(this).removeClass('selected')});
	
			// Parse the div id:
			var theDivId = $(this).html().replace(/1\-A2WT /,'') + '_div';
			
			// Hide all divs:
			$('.triton_mobile_model_specs').each(function(){$(this).hide()});
			
			// Show the one we need:
			$('#' + theDivId).show();
			
			// Make this tab selected:
			$(this).addClass('selected');
								
		});
	
	});

	
	/* --- Dealer Locator New Search Link --- */
	$('#dealer_locator_new_search_link').live('click',function(){
		$('#dealer_locator_search_form_div').slideDown('fast',function(){
			$('#dealer_locator_search_link_div').hide();
		});
	});
	
	
	
	// Buttons:
	$('.make_me_button').button();
	
	
	
	
}); // eo document.ready()






// Sets a cookie of the chosen language and reloads:
function change_language(lang) {
	document.cookie = "pref_lang="+lang+";expires=+10y";
	window.location.reload();
}

function go(where) {
	document.location = where;
}


// Shows the info when a region of a Flash Dealer Map is clicked:
function set_text(div_name) {
	if (document.getElementById(div_name).innerHTML != '') {
		document.getElementById('main_text').innerHTML=document.getElementById(div_name).innerHTML;
	} else {
		document.getElementById('main_text').innerHTML=document.getElementById('master_contact_div').innerHTML;
		var theTitle = document.getElementById(div_name).title;
		var H3s = document.getElementById('main_text').getElementsByTagName('h3');
		H3s[0].innerHTML = theTitle;
	}
}


// Open the Request Form Window:
function prod_request_window(query) {
	var theUrl = "/product_quote_request.html";
	if (query) { theUrl += '?'+query; }
	var options = "toolbar=0,status=0,menubar=0,scrollbars=auto,resizable=auto,width=640,height=800";
	var win = window.open(theUrl,"infoRequest", options);
}

function dealer_request_window(query) {
	var theUrl = "/dealer_info_request.html";
	if (query) { theUrl += '?'+query; }
	var options = "toolbar=0,status=0,menubar=0,scrollbars=auto,resizable=auto,width=640,height=800";
	var win = window.open(theUrl,"dealerInfoRequest", options);
}






/* ---------------- CHECK IF ANYTHING BELOW THIS IS BEING USED ---------------- */


// function MM_preloadImages() { //v3.0
//   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
//     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
//     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
// }
// 
// function MM_swapImgRestore() { //v3.0
//   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
// }
// 
// function MM_findObj(n, d) { //v4.01
//   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
//     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
//   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
//   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
//   if(!x && d.getElementById) x=d.getElementById(n); return x;
// }
// 
// function MM_swapImage() { //v3.0
//   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
//    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
// }
// 
// function PreLoadImages() {
//     MM_preloadImages('/images/home/Home-Office_itn_btn_a.jpg','/images/home/Corporate_itn_btn_a.jpg','/images/home/Bottling Plants_itn_btn_a.jpg', '/images/home/Industrial_itn_btn_a.jpg','/images/inner/home_a.png', '/images/inner/links_a.png', '/images/inner/sitemap_a.png', '/images/inner/legal_a.png', '/images/inner/glossary_a.png','/images/inner/contacts_a.png', '/images/inner/m_01_a.png', '/images/inner/m_02_a.png', '/images/inner/m_03_a.png','/images/inner/m_04_a.png','/images/inner/m_05_a.png','/images/inner/m_06_a.png', '/images/inner/m_08_a.png','/images/inner/m_07_a.png','/images/inner/m_09_a.png','/images/inner/m_11_a.png','/images/home/Home-Office_itn_btn_n.jpg','/images/home/Industrial_itn_btn_n.jpg','/images/home/Corporate_itn_btn_n.jpg','/images/inner/m_10_a.png');
// }
// 

    
// function UpdateSelectedDomain(domain_field) {
//     // Altered this on 2009-12-22 by Sterling's order to
//     // remove the list of available domains. --alexb
//     
// //    var domain_field = UTIL.GetElement('available_domain');
// //    var val = domain_field.options[domain_field.selectedIndex].value;
//     var current = '';
// //    if (val == 'custom') {
// //        UTIL.Show('custom_domain_div');
//         current = 'Air2Water' + UTIL.GetElement('custom_domain').value + '.com';
// //    }else {
// //        UTIL.Hide('custom_domain_div');
// //        current = val.replace(/^http:\/\/www\./,'');
// //    }
//     UTIL.GetElement('selected_domain').innerHTML = current;
//}

// 
// function check_string(str) {
//     var good_string = false;
//     if (str.length > 0) {
//         good_string = true;
//     }
//     return good_string;
// }
// 
// function check_email(email) {
//     var email_good = true;
//         
//     var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
//     email_good = reg.test(email);
//     
//     return email_good;
// }
// 
// function CheckRegistrationForm() {
//     var form_status = true;
//     
//     form_status = check_string(UTIL.GetElement('name').value);
//     if (!form_status) {
//         alert('You must provide a company name');
//     }else {
//         var street_status = check_string(UTIL.GetElement('address').value);
//         var po_status = check_string(UTIL.GetElement('po').value);
//         if (!po_status && !street_status) {
//             form_status = false;
//             alert('You must provide a Street Address or PO');
//         }else {
//             form_status = check_string(UTIL.GetElement('city').value);
//             if (!form_status) {
//                 alert('You must provide a City');
//             }else {
//                 form_status = check_string(UTIL.GetElement('zip').value);
//                 if (!form_status) {
//                     alert('You must provide a Zip/Postal Code');
//                 }else {
//                     form_status = check_string(UTIL.GetElement('contact').value);
//                     if (!form_status) {
//                         alert('You must provide a company contact');
//                     }else {
//                         form_status = check_email(UTIL.GetElement('email').value);
//                         if (!form_status) {
//                             alert('You must provide a valid email address');
//                         }
//                     }
//                 }
//             }
//         }
//     }
//     
//     return form_status;
// }

