// FitnessBlowout.com
function page_init(path){
	MM_preloadImages(path+'images/nb02b.jpg',path+'images/nb03b.jpg',path+'images/nb04b.jpg',path+'images/nb05b.jpg',path+'images/nb06b.jpg',path+'images/nb07b.jpg',path+'images/nt02b.jpg',path+'images/nt03b.jpg',path+'images/nt04b.jpg',path+'images/nt05b.jpg',path+'images/nt06b.jpg',path+'images/nt07b.jpg',path+'images/nt08b.jpg',path+'images/nt09b.jpg');
	setupZoom();
}
function tgl_vis(a,div){
	document.getElementById(div).className = (document.getElementById(div).className == 'desc_hide') ? 'desc_show' : 'desc_hide';
	a.appendChild(document.createTextNode('Hide'));
}
function start_clock(now,target){
	setTimeout("increment("+now+","+target+")",1000);
}
function increment(now,target){
	now++;
	target = (now >= target) ? target + 86400 : target;
	var time = target - now;
	document.getElementById('countdown').innerHTML = "Today's Sale Ends in "+get_clock(time)+", Order Now!";
	setTimeout("increment("+now+","+target+")",1000);
}
function get_clock(time){
	var sec = time % 60;
	var tmin = (time - sec) / 60; 
	var mns = tmin % 60;
	var hrs = (tmin - mns) / 60;
	sec = (sec > 0) ? sec : 0;
	mns = (mns > 0) ? mns : 0;
	hrs = (hrs > 0) ? hrs : 0;
	var out = hrs+" hours, "+mns+" minutes, "+sec+" seconds";
	return out;
}
function submit_sort_form(pos){
	//var page_field = 'page_'+pos;
	var results_select = 'results_'+pos;
	var order_select = 'order_'+pos;
	var sub_category = 'sc_'+pos;
	//document.sort_form.page.value = document.getElementById(page_field).value;
	document.sort_form.results.value = document.getElementById(results_select).value;
	document.sort_form.order.value = document.getElementById(order_select).value;
	document.sort_form.sc.value = document.getElementById(sub_category) ? document.getElementById(sub_category).value : 0;
	document.sort_form.submit();
}
function go_to_page(num){
	document.sort_form.page.value = num;
	document.sort_form.submit();
}
function submit_manufacturer_form(){
	document.manufacturer_form.manufacturer.value = document.getElementById('manufacturer').value;
	document.manufacturer_form.submit();
}
function view_manufacturer(){
	window.location = "http://www.fitnessblowout.com/brand/"+document.getElementById('manufacturer').value;
}
function brand_subcategory(sel){
	if(sel.value){ window.location = "http://www.fitnessblowout.com/brand/"+document.getElementById('brand').value+"/"+sel.value; }
	else{ window.location = "http://www.fitnessblowout.com/brand/"+document.getElementById('brand').value; }
}
function commercial_subcategory(sel){
	window.location = "http://www.fitnessblowout.com/commercial/"+sel.value;
}
function submit_search_form(){
	document.search_form.q.value = document.getElementById('search_text').value;
	document.search_form.submit();
}
function submit_mailing_list_form(){
	document.getElementById('Email Address').value = document.getElementById('email').value;
	document.mailing_list_form.submit();
}
function add_to_cart(pid){
	document.cart_form.add.value = pid;
	document.cart_form.submit();
}
function switch_img(pnl,enlarge){
	container = document.getElementById('pri');
	container.innerHTML = '';
	var alt_img = '../../images/products/large/'+pnl+'.jpg';
	var lrg_img = '../../images/products/enlarge/'+pnl+'.jpg';
	if(enlarge == 1){
		enlnk = container.appendChild(document.createElement("a"));
		enlnk.href = lrg_img;
		image = enlnk.appendChild(document.createElement("img"));
		image.src = alt_img;
		image.border = 0;
		setupZoom();
	}
	else{
		image = container.appendChild(document.createElement("img"));
		image.src = alt_img;
		image.border = 0;
	}
}
var comp = new Array();
function comp_select(pid){
	if(document.getElementById(pid).checked ==  true){
		comp.unshift(pid);
	}
	//comp = comp.filter(is_checked);
}
function index_to_video(){
	window.location = window.location+"#tabs";	
	document.getElementById('tab_container').innerHTML = document.getElementById('Demo Video').innerHTML;
}
function is_checked(element,index,array){
	return document.getElementById(element).checked;
}
var compare = new Array();
function viewComparison(cid){
	var prm = cid;
	var cp = document.getElementsByName("compare");
	var cc = 0;
	for(i = 0; i < cp.length; i++){
		if(cp[i].checked == true && cc < 5){
			prm += "-"+cp[i].value;
			cc++;
		}
	}
	if(cc > 1){
		//window.location = "http://www.fitnessblowout.com/products/compare.php?prm="+prm;
		window.open("http://www.fitnessblowout.com/compare-units/"+prm,"comparison","width=800,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes");
	}
	else{ alert("You must select at least two units to compare"); }
}
function open_new_window(new_url,width,height){
	var window_attributes = 'width='+width+',height='+height+',scrollbars=yes';
	window.open(new_url,'help_window',window_attributes);
}
var title = new Array();
function init_tabs(){
	container = document.getElementById('container_cel');
	header = container.appendChild(document.createElement("div"));
	header.className = 'tab_head';
	d = 0;
	for(t = 0; t < init_tabs.arguments.length; t++){
		if(document.getElementById(init_tabs.arguments[t])){
			title[d] = init_tabs.arguments[t];
			tab = header.appendChild(document.createElement("div"));
			tab.className = (d > 0) ? 'tab' : 'tab_up';
			tab.id = 'tab_'+d;
			tab_left = tab.appendChild(document.createElement("div"));
			tab_left.className = 'tab_left';
			tab_title = tab.appendChild(document.createElement("div"));
			tab_title.className = 'tab_title';
			tab_title.appendChild(document.createTextNode(title[d]));
			tab_right = tab.appendChild(document.createElement("div"));
			tab_right.className = 'tab_right';
			tab.onmouseover = function(){
				this.className = (this.className == 'tab') ? 'tab_over' : this.className;
			}
			tab.onmouseout = function(){
				this.className = (this.className == 'tab_over') ? 'tab' : this.className;
			}
			tab.onmousedown = function(){
				if(this.className != 'tab_up'){
					pt = this.id.split('_');
					index = pt[1];
					content.innerHTML = document.getElementById(title[index]).innerHTML;
					this.className = 'tab_up';
					for(c = 0; c < title.length; c++){
						tab_id = 'tab_'+c;
						document.getElementById(tab_id).className = (tab_id != this.id) ? 'tab' : document.getElementById(tab_id).className;
					}
				}
			}
			d++;
		}
	}
	content = container.appendChild(document.createElement("div"));
	content.id = 'tab_container';
	content.className = 'tab_container';
	content.innerHTML = document.getElementById(title[0]).innerHTML;
}
function init_tabs_new(){
	container = document.getElementById('container_cel');
	header = container.appendChild(document.createElement("div"));
	header.className = 'tab_head_new';
	d = 0;
	for(t = 0; t < init_tabs_new.arguments.length; t++){
		if(document.getElementById(init_tabs_new.arguments[t])){
			title[d] = init_tabs_new.arguments[t];
			tab = header.appendChild(document.createElement("div"));
			tab.className = (d > 0) ? 'tab' : 'tab_up';
			tab.id = 'tab_'+d;
			tab_left = tab.appendChild(document.createElement("div"));
			tab_left.className = 'tab_left';
			tab_title = tab.appendChild(document.createElement("div"));
			tab_title.className = 'tab_title';
			tab_title.appendChild(document.createTextNode(title[d]));
			tab_right = tab.appendChild(document.createElement("div"));
			tab_right.className = 'tab_right';
			tab.onmouseover = function(){
				this.className = (this.className == 'tab') ? 'tab_over' : this.className;
			}
			tab.onmouseout = function(){
				this.className = (this.className == 'tab_over') ? 'tab' : this.className;
			}
			tab.onmousedown = function(){
				if(this.className != 'tab_up'){
					pt = this.id.split('_');
					index = pt[1];
					content.innerHTML = document.getElementById(title[index]).innerHTML;
					this.className = 'tab_up';
					for(c = 0; c < title.length; c++){
						tab_id = 'tab_'+c;
						document.getElementById(tab_id).className = (tab_id != this.id) ? 'tab' : document.getElementById(tab_id).className;
					}
				}
			}
			d++;
		}
	}
	content = container.appendChild(document.createElement("div"));
	content.id = 'tab_container';
	content.className = 'tab_container_new';
	content.innerHTML = document.getElementById(title[0]).innerHTML;
}
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_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_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 toggleLayer( whichLayer )
{
var elem, vis;
if( document.getElementById )
elem = document.getElementById( whichLayer );
else if( document.all )
elem = document.all[whichLayer];
else if( document.layers )
elem = document.layers[whichLayer];
vis = elem.style;
vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}