// JavaScript Document
 
 window.onload = function()
{
	fixFlash();
}
function fixFlash()
{
	objects = document.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++)
	{
		objects[i].outerHTML = objects[i].outerHTML;
	}

	embed = document.getElementsByTagName("embed");
	for (var i = 0; i < embed.length; i++)
	{
		embed[i].outerHTML = embed[i].outerHTML;
	}
}



function validateSubmit(){
	if(f = document.getElementById("form_submit")){
		var suc = 1;
		
		if(checkEmpty(f.elements['firstname'].value)){
			alert('Please enter your First Name');
			suc = 0;
		}
		
		else if(checkEmpty(f.elements['lastname'].value)){
			alert('Please enter your Last Name');
			suc = 0;
		}
		
	 
		
		else if(checkEmpty(f.elements['email'].value)){
			alert('Please enter your Email Address');
			suc = 0;
		}
		
		else if(checkEmpty(f.elements['email2'].value)){
			alert('Please verify your Email Address');
			suc = 0;
		}
		
		else if( f.elements['email'].value != f.elements['email2'].value){
			alert('Email addresses do not match, please re-enter');
			suc = 0;
		}
		
		
		else if(checkEmpty(f.elements['address1'].value)){
			alert('Please enter your Address');
			suc = 0;
		}
		
		else if(checkEmpty(f.elements['city'].value)){
			alert('Please enter your City');
			suc = 0;
		}
		
		else if(checkEmpty(f.elements['state'].value)){
			alert('Please se;ect your State');
			suc = 0;
		}
		
		else if(checkEmpty(f.elements['zip'].value)){
			alert('Please enter your Zip Code');
			suc = 0;
		}
		
		else if(checkEmpty(f.elements['dayphone'].value)){
			alert('Please enter your Day Phone');
			suc = 0;
		}
		else if(checkEmpty(f.elements['eveningphone'].value)){
			alert('Please enter your Evening Phone');
			suc = 0;
		}
		
		
		
		
		if(suc == 1)
			return true;
	}
	
	return false;
	


	
}



function validateContact(){
	if(f = document.getElementById("form_submit")){
		var suc = 1;
		
		if(checkEmpty(f.elements['firstname'].value)){
			alert('Please enter your First Name');
			suc = 0;
		}
		
		else if(checkEmpty(f.elements['lastname'].value)){
			alert('Please enter your Last Name');
			suc = 0;
		}
		
	 
		
		else if(checkEmpty(f.elements['email'].value)){
			alert('Please enter your Email Address');
			suc = 0;
		}
		
		else if(checkEmpty(f.elements['email2'].value)){
			alert('Please verify your Email Address');
			suc = 0;
		}
		
		else if( f.elements['email'].value != f.elements['email2'].value){
			alert('Email addresses do not match, please re-enter');
			suc = 0;
		}
		
		 
		
		
		if(suc == 1)
			return true;
	}
	
	return false;
	


	
}

function initScrollLayers() {
	var wndo1 = new dw_scrollObj('wn_side', 'lyr_side', null);
	wndo1.setUpScrollbar("dragBar_side", "track1", "v", 1, 1);
	
	obj = document.getElementById('lyr_side');
	//if( obj.offsetHeight > 2 )
		dw_showLayers("scrollbar_side"); 
}

function dw_showLayers() {
  if ( document.getElementById ) {
    var lyr, i;
    for (i=0; arguments[i]; i++) {
      lyr = document.getElementById( arguments[i] );
      lyr.style.visibility = "visible";
    }
  }
}
 
 
function ft(w,h,f,l,t){
	var uri = '/swf/title.swf?mw='+w+'&mh='+h+'&fs='+f+'&l='+l+'&tx='+escape(t);
	output = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+w+'" height="'+h+'">'+
	  '<param name="movie" value="'+uri+'" />'+
	  '<param name="quality" value="high" />'+
	  '<param name="wmode" value="transparent" />'+
	  '<embed src="'+uri+'" width="'+w+'" height='+h+'" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"></embed>'+
	'</object>';
	
	return output;
}
 

function feature(l1,l2,d,p,u){
	var w = 519;
	var h = 337;
	var uri = '/swf/homefeature.swf?l1='+escape(l1)+'&l2='+escape(l2)+'&desc='+escape(d)+'&pr='+escape(p)+'&u='+escape(u);
	output = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+w+'" height="'+h+'">'+
	  '<param name="movie" value="'+uri+'" />'+
	  '<param name="quality" value="high" />'+
	  '<param name="wmode" value="transparent" />'+
	  '<embed src="'+uri+'" width="'+w+'" height='+h+'" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"></embed>'+
	'</object>';
	
	return output;
}


 
function $(v){
	return document.getElementById(v);
}
 
function checkEmpty(p_sVal){
	l_sVal = escape(p_sVal);
	l_sVal = l_sVal.replace(/\s*((\S+\s*)*)/, "$1");
	l_sVal = l_sVal.replace(/((\s*\S+)*)\s*/, "$1");
	return l_sVal.length < 1;
}


function setClientCallback(p_sMsg){
	client = new HttpClient(); client.isAsync = true; client.requestType = 'POST'; client.statusDiv = 'HttpClientStatus_notice';
		client.callback = function(result) {
		l_xStatus.innerHTML = '';l_xStatus.style.display = 'block';
		eval(result); 
	}
	l_xStatus = document.getElementById(client.statusDiv);
	l_xStatus.innerHTML = p_sMsg;
}


function validateAddProduct(){
	if(obj = document.getElementById("form_addproduct")){
		var suc = 1;
		if(checkEmpty(obj.quantity.value)){
			alert('Please enter quantity');
			suc = 0;
		}
		
		else if(!(obj.quantity.value > 0)){
			alert('Please enter a proper quantity amount');
			suc = 0;
		}
		
		if(suc == 1)
			return true;
	}
	
	return false;
}



function getOrder(){
	if( document.getElementById("HttpClientStatus_notice") ){
	setClientCallback('Updating Order...');
	qs = 'a=getOrder';
	client.makeRequest('includes/lib/action.php?',qs);
	}
}


function updateOrder(idtoremove){
	if(f = document.getElementById('form_order')){
		setClientCallback('Updating...');
		 
		qs = 'a=updateOrder';
		
	 	var ids = f.elements['ids'].value;
		qs += '&ids='+ids;
		
		ids = ids.split(",");
		for(i in ids){
			
			if(!( (objval = document.getElementById('quantity_'+ids[i]).value) > 0)){
				alert('Please enter a proper quantity amount');
				return;
			}
			
			qs += '&id_value_'+ids[i]+'='+objval;
				
		}
		qs += '&removeID='+idtoremove;
	
		client.makeRequest('includes/lib/action.php?',qs);
	
	
	}
	



	
}



function sortProducts(){
	
	$("price_desc").style.display = 'none';
	$("price_asc").style.display = 'none';
	$("head_aprice").style.backgroundImage = 'url(/images/head_price_off.jpg)';
	
	if( $("products_desc").style.display == 'block' ){
		$("products_desc").style.display = 'none';
		$("products_asc").style.display = 'block';
		$("head_aproduct").style.backgroundImage = 'url(/images/head_products_asc.jpg)';
	}
	else{
		$("products_desc").style.display = 'block';
		$("products_asc").style.display = 'none';
		$("head_aproduct").style.backgroundImage = 'url(/images/head_products.jpg)';
	}
	
}

function sortPrice(){
	
	
	$("products_desc").style.display = 'none';
	$("products_asc").style.display = 'none';
	$("head_aproduct").style.backgroundImage = 'url(/images/head_products_off.jpg)';
	
	if( $("price_desc").style.display == 'block' ){
		$("price_desc").style.display = 'none';
		$("price_asc").style.display = 'block';
		$("head_aprice").style.backgroundImage = 'url(/images/head_price_asc.jpg)';
	}
	else{
		$("price_desc").style.display = 'block';
		$("price_asc").style.display = 'none';
		$("head_aprice").style.backgroundImage = 'url(/images/head_price.jpg)';
	}
}




