//Frame Buster
if (window != window.top)
  top.location.href = location.href;

//On-Click-Popup-Center
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no,,toolbar=no,menubar=no';
win = window.open(mypage, myname, winprops);
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

// Auto-Select Field
function ready(){document.form.field.focus();}

// Form Validation

function validateContact(form) {
	return (
				 checkSelect(form.elements["firstname"],"V","","Please enter your First Name.",false) &&
				 checkSelect(form.elements["lastname"],"V","","Please enter your Last Name.",false) &&
				 checkSelect(form.elements["email"],"V","","Please enter your E-mail.",false) &&
				 checkEmail(form.elements["email"],false) &&
				 checkSelect(form.elements["email"],"V","joe@example.com","Please supply a valid E-mail Address.",false) &&
				 checkSelect(form.elements["message"],"V","","Please provide us with your Message.",false));
}

function validateEmailSignup(form) {
	return (
				 checkSelect(form.elements["firstname"],"V","","Please enter your First Name.",false) &&
				 checkSelect(form.elements["firstname"],"V","First Name","Please enter your real First Name.",false) &&
				 checkSelect(form.elements["lastname"],"V","","Please enter your Last Name.",false) &&
				 checkSelect(form.elements["lastname"],"V","First Name","Please enter your real Last Name.",false) &&
				 checkSelect(form.elements["email"],"V","","Please enter your E-mail.",false) &&
				 checkEmail(form.elements["email"],false) &&
				 checkSelect(form.elements["email"],"V","joe@example.com","Please supply a valid E-mail Address.",false));
}

function validateUnsub(form) {
	return (
				 checkSelect(form.elements["email"],"V","","Please enter your E-mail.",false) &&
				 checkEmail(form.elements["email"],false) &&
				 checkSelect(form.elements["email"],"V","joe@example.com","Please supply a valid E-mail Address.",false));
}

function validateLogin(form) {
	return (
				 checkSelect(form.elements["email"],"V","","Please enter your E-mail.",false) &&
				 checkEmail(form.elements["email"],false) &&
				 checkSelect(form.elements["email"],"V","joe@example.com","Please supply a valid E-mail Address.",false) &&
				 checkSelect(form.elements["password"],"V","","Please enter your Password.",false));
}

function validateNewLogin(form) {
	return (
				
				 checkSelect(form.elements["fullname"],"V","","Please enter your full name.",false) &&
				 checkSelect(form.elements["email"],"V","","Please enter your E-mail.",false) &&
				 checkEmail(form.elements["email"],false) &&
				 checkSelect(form.elements["email"],"V","joe@example.com","Please supply a valid E-mail Address.",false) &&
				 checkSelect(form.elements["password1"],"V","","Please create a Password.",false) &&
				 checkSelect(form.elements["password2"],"V","","Please confirm your Password.",false));
}

function validatePay(form) {
	return (
				validateBillingAddress(form) &&
				 checkSelect(form.elements["cc_num"],"V","","You have chosen to pay by Credit Card. Please enter your Credit Card Number before continuing.",false) &&
				 checkSelect(form.elements["cc_expires_month"],"V","00","Please select the Month this credit card expires.",false) &&
				 checkSelect(form.elements["cc_expires_year"],"V","00","Please select the Year this credit card expires.",false) &&
				 checkSelect(form.elements["cc_sid"],"V","","Please enter your credit card's 3-digit Identification Number.",false));
}

function validateSignin(form) {
	return (
				 checkSelect(form.elements["loginemail"],"V","","Please enter your E-mail.",false) &&
				 checkEmail(form.elements["loginemail"],false) &&
				 checkSelect(form.elements["loginemail"],"V","joe@example.com","Please supply valid E-mail Address.",false) &&				 
				 checkSelect(form.elements["password"],"V","","Please enter your Password.",false));
}

function validatePO(form)
{
	return checkSelect(form.elements["po_number"],"V","","Please enter the PO Number.",false);
	
}//end validatePO

function validateBillingAddress(form)
{
	// This fixes the state / province box nature of the country form
	// 213 == United States
	// 28 == Canada
	var stateField = "billing_state";
	if ( form.elements["billing_country"].value != 213 && form.elements["billing_country"].value != 38 ) {
		stateField = "billing_province";
	}
	
	return ( 
		checkSelect(form.elements["billing_fullname"],"V","","Please enter the Billing Full Name.",false) &&
		checkSelect(form.elements["billing_country"],"V","","Please enter the Billing Country.",false) &&
		checkSelect(form.elements["billing_address"],"V","","Please enter the Billing Address.",false) &&
		checkSelect(form.elements["billing_city"],"V","","Please enter the Billing City.",false) && 
		checkSelect(form.elements[stateField],"V","","Please enter the Billing State/Prov.",false) && 
		checkSelect(form.elements["billing_zip"],"V","","Please enter the Billing Zip/Postal Code.",false) && 
		checkSelect(form.elements["billing_phone"],"V","","Please enter the Billing Phone.",false)
	);


}//end validateBillingAddress

function checkPasswords(form) {
	
	if ( form.elements["password1"].value != form.elements["password1"].value ) {
		alert("Your passwords does not match.  Please enter re-enter your passwords");
		return false;
	} else {
		return true;
	}
	
}

function validateExpressPurchase(form)
{
	if ( 
		
		checkSelect(form.elements["email_address"],"V","","Please enter your E-mail.",false) &&
		checkEmail(form.elements["email_address"],false) &&
		checkSelect(form.elements["email_address"],"V","joe@example.com","Please supply valid E-mail Address.",false) &&		
		checkSelect(form.elements["billing_fullname"],"V","","Please enter the billing Full Name.",false) &&
		checkSelect(form.elements["billing_address"],"V","","Please enter the billing Address.",false) &&
		checkSelect(form.elements["billing_address"],"V","","Please enter the billing Address.",false) &&
		checkSelect(form.elements["billing_city"],"V","","Please enter the billing City.",false) && 
		checkSelect(form.elements["billing_state"],"V","","Please enter the billing State/Prov.",false) && 
		checkSelect(form.elements["billing_zip"],"V","","Please enter the billing ZIP.",false) && 
		checkSelect(form.elements["billing_phone"],"V","","Please enter the billing Phone.",false)) 
	
	{
		//All billing was ok - check shipping and return it
		return validateShippingAddress(form);
		
	} else {
		//something was false
		return false;	
	}

}//end validateBillingAddress

function validateBillingAddress1(form)
{
	if (
		//checkSelect(form.elements["billing_fullname"],"V","","Please enter the billing First Name.",false) &&
		//checkSelect(form.elements["billing_lastname"],"V","","Please enter the billing Last Name.",false) &&
		checkSelect(form.elements["billing_fullname"],"V","","Please enter the billing Full Name.",false) &&
		checkSelect(form.elements["billing_address"],"V","","Please enter the billing Address.",false) &&
		checkSelect(form.elements["billing_city"],"V","","Please enter the billing City.",false) && 
		checkSelect(form.elements["billing_state"],"V","","Please enter the billing State/Prov.",false) && 
		checkSelect(form.elements["billing_zip"],"V","","Please enter the billing ZIP.",false) && 
		checkSelect(form.elements["billing_phone"],"V","","Please enter the billing Phone.",false) 
		//checkSelect(form.elements["billing_country"],"V","","Please enter the billing Country.",false)
	) {
		//All billing was ok - check shipping and return it
		return validateShippingAddress(form);
		
	} else {
		//something was false
		return false;	
	}

}//end validateBillingAddress

function validateBillingAddress2(form)
{
	if (
		//checkSelect(form.elements["billing_fullname"],"V","","Please enter the billing First Name.",false) &&
		//checkSelect(form.elements["billing_lastname"],"V","","Please enter the billing Last Name.",false) &&
		checkSelect(form.elements["billing_fullname"],"V","","Please enter the billing Full Name.",false) &&
		checkSelect(form.elements["billing_address"],"V","","Please enter the billing Address.",false) &&
		checkSelect(form.elements["billing_city"],"V","","Please enter the billing City.",false) && 
		checkSelect(form.elements["billing_state"],"V","","Please enter the billing State/Prov.",false) && 
		checkSelect(form.elements["billing_zip"],"V","","Please enter the billing ZIP.",false) && 
		checkSelect(form.elements["billing_phone"],"V","","Please enter the billing Phone.",false) 
		//checkSelect(form.elements["billing_country"],"V","","Please enter the billing Country.",false)
	) {
		//All billing was ok - check shipping and return it
		return true;
		
	} else {
		//something was false
		return false;	
	}

}//end validateBillingAddress

function validateShippingAddress(form)
{
	// This fixes the state / province box nature of the country form
	// 213 == United States
	// 28 == Canada
	var stateField = "ship_state";
	if ( form.elements["ship_country"].value != 213 && form.elements["ship_country"].value != 38 ) {
		stateField = "ship_province";
	}	
	
	return (
		checkSelect(form.elements["ship_fullname"],"V","","Please enter the shipping full name.",false) &&
		checkSelect(form.elements["ship_country"],"V","","Please enter the shipping country.",false) &&
		checkSelect(form.elements["ship_phone"],"V","","Please enter the shipping Phone.",false) &&
		checkSelect(form.elements["ship_address"],"V","","Please enter the shipping Address.",false) &&
		checkSelect(form.elements["ship_city"],"V","","Please enter the shipping City.",false) && 
		checkSelect(form.elements[stateField],"V","","Please enter the shipping State/Prov.",false) && 
		checkSelect(form.elements["ship_zip"],"V","","Please enter the shipping ZIP.",false) 
	);
}//end validateShippingAddress

function validateExpressPurchase(form)
{
	return (
		checkSelect(form.elements["email_address"],"V","","Please enter your email address.",false) &&
		checkSelect(form.elements["ship_fullname"],"V","","Please enter the shipping full name.",false) &&
		checkSelect(form.elements["ship_phone"],"V","","Please enter the shipping Phone.",false) &&
		checkSelect(form.elements["ship_address"],"V","","Please enter the shipping Address.",false) &&
		checkSelect(form.elements["ship_city"],"V","","Please enter the shipping City.",false) && 
		checkSelect(form.elements["ship_state"],"V","","Please enter the shipping State/Prov.",false) && 
		checkSelect(form.elements["ship_zip"],"V","","Please enter the shipping ZIP.",false) 
	);
}//end validateShippingAddress

function validatePaypalForm()
{	
	if (document.getElementById('billing_state').value.length == 0) {
		alert ("Please enter the billing state.");
		return false;
	} else {
		return true;
	}
}//end validateShippingAddress

function checkProfile(form)
{
	var arrElements = new Array("fullname","address", "city", "state", "zip");
	var len = arrElements.length;
	var i = 0;
	
	for ( i=0; i<len; i++ ) {
		if ( form.elements['billing_'+arrElements[i]].value != form.elements['hidden_billing_'+arrElements[i]].value ) {
			form.elements['profilecontrol'].value = 'change';	
		}
		
	}//for
	
	//alert(form.elements['profilecontrol'].value);
	
	//and one by hand
	if ( form.elements['cc_type'].value != form.elements['hidden_cc_type'].value ) {
		form.elements['profilecontrol'].value = 'change';
	}
	
	return validateBillingAddress(form);
	
}//end checkProfile


// disabling and enabling shipping info fields

function toggleFields(form)
{
	var toggle = form.elements['same_as_billing'];
	
	var arrShipFields = new Array('ship_fullname', 'ship_address', 'ship_city', 'ship_state', 'ship_zip', 'ship_phone');
	var fieldShipCount = arrShipFields.length;
	
	var arrBillFields = new Array('billing_fullname', 'billing_address', 'billing_city', 'billing_state', 'billing_zip', 'billing_phone');
	var fieldBillCount = arrBillFields.length;
	
	var i = 0;
	
	if (toggle.checked == false) {
		//Already checked, unset everything
		for ( i=0; i<fieldShipCount; i++) {
			form.elements[arrShipFields[i]].value = "";
		}//for	
	
	} else {
		//Not yet checked, copy the values from billing
		for ( i=0; i<fieldShipCount; i++) {
			form.elements[arrShipFields[i]].value = form.elements[arrBillFields[i]].value;
		}//for	
	}
	
}//end toggleFields

function toggleSaveProfile(elem) {
	var form = elem.form;
	
	//valid values are insert, donotupdate, and update
	if (elem.checked == true) {
		form.elements['profilecontrol'].value = 'insert';
				
	} else {
		form.elements['profilecontrol'].value = 'donotupdate';
		
	}
	
	//alert(form.elements['profilecontrol'].value);
	
}//end toggleSaveProfile

function checkField() {
	var frm = document.search_store;
	
	if ( (frm.p_keyword.value == "" ) || (frm.p_keyword.value == " " ) ) {
		
		alert("A Keyword is required to search");
		return false;			
	}
	
}


function checkEmailSignup() {

	var frm = document.emailSignup;
	
	if ( (frm.firstname.value == "" ) || (frm.firstname.value == " " ) ) {
		
		alert("First name is required");
		return false;			
	}
	
	if ( (frm.lastname.value == "" ) || (frm.lastname.value == " " ) ) {
		alert("Last name is required");
		return false;	
	}	
	
	if ( (frm.email.value == "") || (frm.email.value == " ") ) {
		
		alert("E-mail is required");
		return false;	
	}
	
	return true;
	
}
function LoginOptionCheck(myself) {
	frm = document.forms['new_login'];
	// if the new Customer item is checked
	var elem_pass_new = document.getElementById('newcustomerpassword');
	var elem_pass_old = document.getElementById('returningcustomerpassword');
	
	if ( myself.value == "new" ) {
		elem_pass_old.disabled = true;
		elem_pass_old.style.display = "none";
		elem_pass_new.disabled = true;
		elem_pass_new.style.display = "";
		frm.elements['action'].value = "account_new";
		frm.action = "new_listing.php";
		
	} else {
	
		elem_pass_old.disabled = false;
		elem_pass_old.style.display = "";
		elem_pass_new.disabled = true;
		elem_pass_new.style.display = "none";
        frm.elements['loginemail'].focus();
		frm.elements['action'].value = "account";
		frm.action = "login.php";
	}
	
	frm.elements['loginemail'].focus();
}

/* This is used to grab the value of the checked radio button. */
function get_radio_value( element )
{
	for (var i=0; i < element.length; i++) {
		if (element[i].checked) {
			var rad_val = element[i].value;
		}
	}
	return rad_val;
}

function focusLoginField() {
	if ( typeof(document.new_login) != "undefined" ) {
		document.new_login.loginemail.focus();
	}
}

function loadPreview() {

	var caption_value = window.opener.document.getElementById("caption").value;
	var headline_obj = window.opener.document.getElementById("headline");
	var body_obj = window.opener.document.getElementById("body");
	var child_head = document.getElementById("headline");
	var child_body = document.getElementById("body");
	var child_caption = document.getElementById("img_caption");
	
	if ( caption_value != '' && child_caption != null ) {
		
		child_caption.innerHTML = caption_value;
	}
	child_head.innerHTML = headline_obj.value;
	child_body.innerHTML = body_obj.value;
	
}

function doProfileChange() {
	document.getElementById('update_profile').style.display = "inline";
}

function fadeout() {
	for (var iterator = 0; iterator < arguments.length; iterator++) {
		arguments[iterator].value = '';
		arguments[iterator].disabled = true;
	}
}

function fadein() {
	for (var iterator = 0; iterator < arguments.length; iterator++) {
		arguments[iterator].disabled = false;
	}
	arguments[1].focus();
	arguments[1].select();
}

function quantity_check(frm)
{
	if ( frm.elements['qty'].value < 1 || !validateInteger(frm.elements['qty'].value) ) {
		alert("Quantity must be an integer greater than 0");
		return false;
	}
}

function multiple_quantity_check(frm)
{
	for ( var i=0; i<arr_content_index.length; i++ ) {
		if ( !validateInteger(frm.elements['update[' + arr_content_index[i] + ']'].value) ) {
 			alert("Quantity must be an integer greater than 0");
			return false;
		}
	}
}

function validateInteger( strValue ) {
	
  var objRegExp  = /(^-?\d\d*$)/;

  return objRegExp.test(strValue);
}

function changeState(state, target)
{
	length = document.getElementById(target).length;
	for ( x=0; x < length; x++ ) {
		document.getElementById(target).remove(0);
	}
	var uri = "LiveUpdater.php";
	var data = "";
	
	data = nh.compressData("action", "changeState");
	data += nh.compressData("state", state);
	data += nh.compressData("target", target);
	
	LiveUpdater(uri, data);
}

function ad_updateClicks ( event )
{
	var uri = "LiveUpdater.php";
	var data = "";
	data += nh.compressData("action", "updateClicks");
	var isIE = document.childNodes[0].nodeName == "html" ? false : true;
    if(!isIE) {
		data += nh.compressData("id", event.currentTarget.name);
    } else {
    	if ( event.srcElement.name != '' ) {
    		data += nh.compressData("id", event.srcElement.name);
    	} else {
    		data += nh.compressData("id", event.srcElement.parentNode.name);
    	}
    }
	LiveUpdater(uri, data);

}

function flash_ad_clicks ( id, href ) {
	var uri = "LiveUpdater.php";
	var data = "";
	data += nh.compressData("action", "updateClicks");
	data += nh.compressData("id", id);
	LiveUpdater(uri, data);
	window.open(href, '_blank', 'toolbar=yes,location=yes,directories=yes,resizable=yes,scrollbars=yes'); 
}

/*start login*/
function toggle_login ( over_ride  )
{
	if (over_ride = undefined ) {
		var type = over_ride;
	} else {
		if ($('login_type_radio_old').checked == true) {
			type = 'old';
		} else {
			type = 'new';
		}
	}
	switch ( type ) {
		case 'new':
			$('new_user_fields').style.display = 'inline';
			$('new_user_challenge_response').style.display = 'inline';
			$('new_user_lost_pass').style.display = 'none';
			$('o_submit').value = 'Get Started';
			$('login_type_radio_new').checked = true;
			break;
		case 'old':
			$('new_user_fields').style.display = 'none';
			$('new_user_challenge_response').style.display = 'none';
			$('new_user_lost_pass').style.display = 'inline';
			$('o_submit').value = 'Sign In';
			$('login_type_radio_old').checked = true;
			break;
	}
	
	$('i_login').focus(); // SINGLE Select Email Field
	
	return true;
}
function login_validate ()
{
	var type = get_radio_value( document.forms[0].radiobutton );
	var uri = "LiveUpdater.php";
	var data = "";
	
	$('invalid_login').style.display = 'none';
	$('already_exists').style.display = 'none';
	
	switch ( type ) {
		case 'new':
			if ( _login_verify( 'new' ) === true ) {
				if ( login_password_verify() === true ) {

					var email 			= $F( 'i_login' );
					var password 		= $F( 'i_password' );
					var password2 	= $F( 'i_password2' );
					var fullname 		= $F( 'i_fullname' );
					var companyname	= $F( 'i_companyname' );
					var stateProv 	= $F( 'i_stateProv' );
					var zip 				= $F( 'i_zip' );

					data += nh.compressData("email", email);
					data += nh.compressData("password", password);
					data += nh.compressData("password2", password2);
					data += nh.compressData("fullname", fullname);
					data += nh.compressData("company", companyname);
					data += nh.compressData("stateProv", stateProv);
					data += nh.compressData("zip", zip);
					data += nh.compressData("screenx", screen.width);
					data += nh.compressData("screeny", screen.height);
					data += nh.compressData("action", "login_newUser");
					LiveUpdater(uri, data);
				}
			}
			break;
		case 'old':
			if ( _login_verify( 'old' ) === true ) {

				var login = $F( 'i_login' );
				var password = $F( 'i_password' );
				
				data += nh.compressData("login", login);
				data += nh.compressData("password", password);
				data += nh.compressData("redirect", $F( 'i_redirect' ) );
				data += nh.compressData("action", "login_validate");
				LiveUpdater(uri, data);
			}
			break;
	}
	return false;
	
}
/* This will check to see if the user has checked the box saying he or she has read the service agreement. */
function _login_agreement_verify ()
{
	if ( $('i_agree').checked ) {
		$('i_serviceAgreement').style.border = null;
		return true;
	} else {
		$('i_serviceAgreement').style.border = "1px solid #f00";
		new Effect.Shake_MacStyle('login');
		$('message_box').style.color = "#f00";
		$('message_box').innerHTML = "You must read and agree to the service agreement";
		return false;
	}
}

/* This will check to see if the passwords match each other. */
function login_password_verify ()
{
	
	if ( $('i_password').value === $('i_password2').value || $('i_password2').value.length == 0) {
		$('password_message_box').style.display = 'none';
		return true;
	} else {
		$('password_message_box').style.display = '';
		return false;
	}
}


function _login_verify ( type )
{
	var missing = false;
	var message = '';
	switch ( type ) {
	
		case 'new':
			if ($('i_login').value == "" || $('i_login').value == " " || $('i_login').value == false) {
				missing = true;
				message = "Please enter your Email Address (this is your User ID).";
			} 
			if ($('i_password').value == "" || $('i_password').value == " " || $('i_password').value == false) {
				missing = true;
				message = "Please enter a Password.";
			} 
			if ($('i_password2').value == "" || $('i_password2').value == " " || $('i_password2').value == false) {
				missing = true;
				message = "Please re-enter your Password.";
			}
			if ($('i_fullname').value == "" || $('i_fullname').value == " " || $('i_fullname').value == false) {
				missing = true;
				message = "Please enter your Name.";
			} 
			if ($('i_companyname').value == "" || $('i_companyname').value == " " || $('i_companyname').value == false) {
				missing = true;
				message = "Please enter your Company's Name";
			} 
			if ($('i_stateProv').value == "" || $('i_stateProv').value == " " || $('i_stateProv').value == false) {
				missing = true;
				message = "Please select your State (or Province).";
			}
			if ($('i_zip').value == "" || $('i_zip').value == " " || $('i_zip').value == false) {
				missing = true;
				message = "Please enter your Zip/Postal Code";
			}
			if ( missing ) {
				alert(message);
			}
			break;
			
		case 'old':
			if ($('i_login').value == "" || $('i_login').value == " " || $('i_login').value == false) {
				missing = true;
			}
			if ($('i_password').value == "" || $('i_password').value == " " || $('i_password').value == false) {
				missing = true;
			}
			break;
	}
	if (missing == true) {
		new Effect.Shake_MacStyle('login');
		

		$('invalid_login').style.display = "";
		return false;
	} else {
		return true;
	}
}



function cart_addItem (type, section, position, quantity )
{

	var id_string = type;
	if ( section != undefined)
		id_string += "_" + section;
	if ( position != undefined )
		id_string += "_" + position;
	if ( $( id_string) && quantity == undefined ) {
		cart_removeItem( id_string, type, section, position, quantity);
		return;
	}
	$('status').innerHTML = "Gathering Information";
	var uri = "LiveUpdater.php";
	var data = "";
	
	data += nh.compressData("type", type);
	if(section != undefined)
		data += nh.compressData("section", section);
	if(position != undefined)
		data += nh.compressData("position", position);
	if(quantity != undefined)
		data += nh.compressData("quantity", quantity);
	data += nh.compressData("action", "cart_addItem");
	LiveUpdater(uri, data);
	
}

function cart_insertItem ( id_string, title, price, add_string )
{
	$('status').innerHTML = "&nbsp;";
	var item = "<div id='"+id_string+"' class='cart_item' style='display: none'><span class='price'>$"+price+"</span>"+title+" <a class='remove' onclick=\"cart_addItem ("+add_string+")\">remove</a></div>";
	new Insertion.Bottom( 'items', item );
	new Effect.BlindDown( id_string );

	cart_showExtraFields();
}

function cart_showExtraFields()
{
	$('totals_title').style.display = 'block';
	$('totals').style.display = 'block';
	$('checkout_button').style.display = '';
	$('empty_string').style.display = 'none';
	$('disc_shown_below').style.display = '';
}

function cart_hideExtraFields()
{
	$('totals_title').style.display = 'none';
	$('totals').style.display = 'none';
	$('checkout_button').style.display = 'none';
	$('empty_string').style.display = '';
	$('disc_shown_below').style.display = 'none';
}

function cart_insertItem_quantity ( type_short, type_title, type_price, quantity )
{
	$('status').innerHTML = "&nbsp;";
	var new_type = 0;
	
	if(!$(type_short)){
		new Insertion.Bottom( 'items', "<div id=\""+type_short+"\" style=\"display: none;\"><h4>"+quantity+" "+type_title+" ($"+type_price+") <a class=\"remove\" onclick=\"cart_removeItem_type('"+type_short+"')\">[X]</a></div>" );
		new Effect.BlindDown( type_short/*, { afterFinish: resizeLeftColumn(500) }*/ );
	} else {
		$(type_short).innerHTML = "<h4>"+quantity+" "+type_title+"</h4>";
	}

}

function cart_insertItem_single ( type_short, type_title, type_price )
{
	$('status').innerHTML = "&nbsp;";
	var new_type = 0;
	
	new Insertion.Bottom( 'items', "<div id=\""+type_short+"\" style=\"display: none;\"><h4>"+type_title+" ($"+type_price+") <a class=\"remove\" onclick=\"cart_removeItem_type('"+type_short+"')\">[X]</a</h4></div>" );
	new Effect.BlindDown( type_short/*, { afterFinish: resizeLeftColumn(500) }*/ );

}

function cart_removeItem (  id_string, type, section, position, quantity )
{
	if ( $('check'+id_string) != undefined)
		document.getElementById('check'+id_string).checked = false;

	new Effect.BlindUp( id_string, { afterFinish: cart_deleteItemTag(id_string, 500) } );
		
	
	var uri = "LiveUpdater.php";
	var data = "";
	data += nh.compressData("type", type);
	if(section != undefined)
		data += nh.compressData("section", section);
	if(position != undefined)
		data += nh.compressData("position", position);
	data += nh.compressData("quantity", quantity);
	data += nh.compressData("action", "cart_removeItem");
	LiveUpdater(uri, data);
}

function cart_deleteItemTag ( tag, timeout)
{
	if(timeout == undefined)
		timeout = 0;
	setTimeout("cart_deleteItemTagNow('"+tag+"')", timeout);
}

function cart_deleteItemTagNow( tag )
{
	document.getElementById(tag).parentNode.removeChild(document.getElementById(tag));
	
	var type = tag.slice(0, tag.lastIndexOf('_') );
}


function cart_removeItem_type (  type  )
{
	var tag = type;
	if(type = 'quotesGlobal')
		document.getElementById('check'+type).checked = false;
	else
		document.getElementById('select'+type).value = 0;
	new Effect.BlindUp(  tag, {afterFinish: cart_deleteItemTag(tag, 500) } );
	var uri = "LiveUpdater.php";
	var data = "";
		
	data += nh.compressData("type", type);
	data += nh.compressData("action", "cart_removeItem_type");
	LiveUpdater(uri, data);
}
function cart_update ( total_one_month, total_three_month, total_six_month, total_twelve_month, allqty )
{
	//new Effect.Appear('total');
	$('total_one_month').innerHTML = '$'+total_one_month;
	$('total_three_month').innerHTML = '$'+total_three_month;
	$('total_six_month').innerHTML = '$'+total_six_month;
	$('total_twelve_month').innerHTML = '$'+total_twelve_month;

	if ( allqty == 0 ) {
		cart_hideExtraFields();
	}
}

function discount_update( discount_three_month, discount_six_month, discount_twelve_month )
{
	$('discount_three_month').innerHTML = discount_three_month;
	$('discount_six_month').innerHTML = discount_six_month;
	$('discount_twelve_month').innerHTML = discount_twelve_month;
}

function cart_empty ()
{
	$('items').innerHTML = "";
	var uri = "LiveUpdater.php";
	var data = "";
		
	data += nh.compressData("action", "cart_empty");
	LiveUpdater(uri, data);
	var inputs = document.getElementsByTagName("input");
	for(var x=0; x < inputs.length; x++) {
		inputs[x].checked = false;
	}
	//resizeLeftColumn();
	
	
}

function toggle_form (id)
{
	if ( $(id).disabled == true ) {
		$(id).disabled = false;
		Effect.toggle(id);
	} else {
		Effect.toggle(id);
		$(id).disabled = true;
	}
	return;
}
/* end cart */



/* This checks to see if the user hits enter. */
function hit_enter(e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	if (keycode == 13) {
		return true;
	} else {
		return false;
	}
}


function order_update_status ( id, status ) 
{
	var field = $(id+"_input");
	var process = $(id+"_process");
	switch ( status ) {
		case "done":
			$(id).innerHTML = field.value;
			process.style.display = "none";
			break;
		case "working":
			process.style.display = "inline";
			field.disabled = true;
			break;
	}
}

// this is to toggle the shopping cart options on new_listing.php
/*function open_close ( section )
{
	if ( section.indexOf('_') == -1 ) {
		var topLevel = new Array(1, 5, 18, 3, 7, 19, 16, 17);
		for ( x = 0; x < topLevel.length; x++ ) {
			if ( $('purchaseForm_'+topLevel[x]).style.display != 'none')
				new Effect.BlindUp('purchaseForm_'+topLevel[x]);
		}
		new Effect.toggle(
		'purchaseForm_'+section, 
		'blind');
		
	} else {
		new Effect.toggle(
			'purchaseForm_'+section, 
			'blind', 
			{ 
				afterFinish: 
					function () {
						Element.toggle('imageOpen_'+section);
						Element.toggle('imageClosed_'+section);
					}
			}
			
		); 
			
	}
	
}*/

function open_close( section )
{
	if ( section.indexOf('_') == -1 ) {
		var topLevel = [1, 5, 18, 3, 7, 19, 16, 17];
		for ( x = 0; x < topLevel.length; x++ ) {
			if ( $('purchaseForm_' + topLevel[x]).style.display != 'none' && section != topLevel[x] ) {
				$('purchaseForm_' + topLevel[x]).style.display = 'none';
			}
		}
		Element.toggle('purchaseForm_' + section);
	} else {
		Element.toggle('purchaseForm_' + section);
		Element.toggle('imageOpen_' + section);
		Element.toggle('imageClosed_' + section);
	}
}

//this is to limit an inputs length
function check_limit (element, length)
{
	if(length == 0)
		return true;
	if (document.getElementById('field'+element).value.length > length ) {
		document.getElementById('span'+element).style.display = 'block';
		return false;
	}
	else
		document.getElementById('span'+element).style.display = 'none';
	return true;
		
}

function check_all_limits ()
{
	var inputs = document.getElementsByTagName("input");
	for(i=0;i<inputs.length;i++) {
		if(inputs[i].getAttribute('allowedLength') != "" && inputs[i].getAttribute('allowedLength') != null) {
			if(inputs[i].value.length > inputs[i].getAttribute('allowedLength')) {
				alert("You have exceeded the maximum number of allowed characters in a field.");
				return false;
			}
		}
	}
	return true;
}

//START Shopping Cart Scroll
function shopping_scroll()
{
	var cw = document.getElementById('cart_wrap');
	var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;

	if ( document.documentElement.clientHeight <= cw.clientHeight ) {
		cw.style.top = "0px";
	} else if ( cw.offsetHeight + scrollTop >= document.getElementById('footer_top').offsetTop ) {
		cw.style.top = (document.getElementById('column_left').offsetHeight - cw.offsetHeight) + 'px';
	} else if ( scrollTop > 135 ) {
		cw.style.top = (scrollTop - 135) + "px";
	} else {
		cw.style.top = "0px";
	}
}

function setup_scroll()
{
	 if(document.addEventListener) {
     	document.addEventListener('scroll', shopping_scroll, false);
     } else {
     	window.attachEvent('onscroll', shopping_scroll, false);
     }
}
//END Shopping Cart Scroll

function disable_item(id)
{
	
	$('purchaseLink_'+id).oldhref = $('purchaseLink_'+id).href;
	$('purchaseLink_'+id).href = "javascript: ;";

	$('purchaseLink_'+id).className = 'button3';
	$('purchaseLink_'+id).innerHTML = 'Sold Out';
	
}

function disable_all_items(type, except)
{
	var pos = 1;
	//console.log(type+'_'+pos);
	while(document.getElementById(type+'_'+pos) ) {
		if ( pos != except ) {
			document.getElementById(type+'_'+pos).disabled = true;
		}
		pos++
		if ( !document.getElementById(type+'_'+pos) ) {
			pos++
		}
	}
}

function enable_all_items(type)
{
	var pos = 1;
	//console.log(type+'_'+pos);
	while(document.getElementById(type+'_'+pos) ) {
		document.getElementById(type+'_'+pos).disabled = false;
		pos++
		if ( !document.getElementById(type+'_'+pos) ) {
			pos++
		}
	}
}



function enable_item(id)
{
	if( $('purchaseLink_'+id).oldhref != undefined ) {
		$('purchaseLink_'+id).href = $('purchaseLink_'+id).oldhref;
	} else {
		$('purchaseLink_'+id).href = $('purchaseLink_'+id).getAttribute('oldhref');
	}
	$('purchaseLink_'+id).className = 'button';
	$('purchaseLink_'+id).innerHTML = 'See Selections / Add to Cart';

}

//this is the firebug alerter
function printfire()
{
    if (document.createEvent)
    {
        printfire.args = arguments;
        var ev = document.createEvent("Events");
        ev.initEvent("printfire", false, true);
        dispatchEvent(ev);
    }
}

function enable_image(id)
{
	if ( $('img'+id).disabled == true ) {
		$('img'+id).disabled = false;
	} else {
		$('img'+id).disabled = true;
	}
}

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
     anchor.target = "_blank";
     var isIE = anchor.attachEvent;
     if(!isIE) {
     	anchor.addEventListener('click', ad_updateClicks, false);
     	anchor.addEventListener('click', function(e) {if ( e.target.getAttribute('href') ) { var targ = e.target; } else { var targ = e.target.parentNode; } window.open(targ.getAttribute('href'), '_blank', 'toolbar=yes,location=yes,directories=yes,resizable=yes,scrollbars=yes'); e.preventDefault(); }, false);
     	
     } else {
     	anchor.attachEvent('onclick', ad_updateClicks, false);
     }
   }
   	
 }
 try {
 	build_sample_ads();
 } catch(e) {
 	//SINGLE catch error, since this function is only sometimes defined	
 }
}


function show_ad_details(id) {
	
}


function update_sample(id) {
	if ( $(id+'_link_text') )
		if( $(id+'_form_Link_Text').value != '' ) {
			$(id+'_link_text').innerHTML = $(id+'_form_Link_Text').value;
			$(id+'_count_Link_Text').innerHTML = $(id+'_form_Link_Text').value.length;
		} else {
			$(id+'_link_text').innerHTML = "Link Text";
			$(id+'_count_Link_Text').innerHTML = "0";
		}
	if ( $(id+'_company_name') )
		if( $(id+'_form_Company_Name').value != '' ) {
			$(id+'_company_name').innerHTML = $(id+'_form_Company_Name').value;
			$(id+'_count_Company_Name').innerHTML = $(id+'_form_Company_Name').value.length;
		} else {
			$(id+'_company_name').innerHTML = "Company Name";
			$(id+'_count_Company_Name').innerHTML = "0";
		}
	if ( $(id+'_phone') ) 
		if( $(id+'_form_Phone').value != '' ) {
			$(id+'_phone').innerHTML = $(id+'_form_Phone').value;
			$(id+'_count_Phone').innerHTML = $(id+'_form_Phone').value.length;
		} else {
			$(id+'_phone').innerHTML = "Phone Number";
			$(id+'_count_Phone').innerHTML = "0";
		}
	if ( $(id+'_website_address') && $(id+'_form_Website_Address') ) {

		website_address = $(id+'_form_Website_Address').value.replace(/^((http:\/\/)|(https:\/\/))/i, '');
		if( website_address != '' ) 
			$(id+'_website_address').innerHTML = website_address;
		else
			$(id+'_website_address').innerHTML = "Website Address";
		$(id+'_count_Website_Address').innerHTML = $(id+'_form_Website_Address').value.length;
	} else if ( $(id+'_form_Website_Address') ) {
		$(id+'_count_Website_Address').innerHTML = $(id+'_form_Website_Address').value.length;
	}

	if ( $(id+'_website_address') && $(id+'_form_Homepage_URL') ) {

		website_address = $(id+'_form_Homepage_URL').value.replace(/^((http:\/\/)|(https:\/\/))/i, '');
		if( website_address != '' ) 
			$(id+'_website_address').innerHTML = website_address;
		else
			$(id+'_website_address').innerHTML = "Website Address";
		$(id+'_count_Homepage_URL').innerHTML = $(id+'_form_Homepage_URL').value.length;
	} else if ( $(id+'_form_Homepage_URL') ) {
		$(id+'_count_Homepage_URL').innerHTML = $(id+'_form_Homepage_URL').value.length;
	}
	
	if ( $(id+'_form_Link_URL') ) {
		$(id+'_count_Link_URL').innerHTML = $(id+'_form_Link_URL').value.length;
	}
	
	if ( $(id+'_form_Alt_Tag') ) {
		$(id+'_count_Alt_Tag').innerHTML = $(id+'_form_Alt_Tag').value.length;
	}
	
	
	if ( $(id+'_description') ) {
		if( $(id+'_form_Description').value != '' ) {
			if( $(id+'_form_Description').value.length > $(id+'_form_Description').getAttribute('maxlength') && $(id+'_form_Description').getAttribute('maxlength') != 0) {
				$(id+'_form_Description').value = $(id+'_form_Description').value.substring(0, $(id+'_form_Description').getAttribute('maxlength'));
			}
			$(id+'_description').innerHTML = $(id+'_form_Description').value;
		} else
			$(id+'_description').innerHTML = "Description";
		$(id+'_count_Description').innerHTML = $(id+'_form_Description').value.length;
	}
	
	if ( $(id+'_form_Company_Info') ) {
		if( $(id+'_form_Company_Info').value.length > $(id+'_form_Company_Info').getAttribute('maxlength') && $(id+'_form_Company_Info').getAttribute('maxlength') != 0) {
			$(id+'_form_Company_Info').value = $(id+'_form_Company_Info').value.substring(0, $(id+'_form_Company_Info').getAttribute('maxlength'));
		}
		$(id+'_count_Company_Info').innerHTML = $(id+'_form_Company_Info').value.length;
	}
}

function check_quote_form() {
	if (
		checkSelect(document.forms[0].elements['quote[company]'],"V","","Please enter your Company Name.",false) &&
		checkSelect(document.forms[0].elements['quote[fullname]'],"V","","Please enter your Name.",false) &&
		checkSelect(document.forms[0].elements['quote[phone]'],"V","","Please enter your Phone Number.",false) &&
		checkSelect(document.forms[0].elements['quote[phonetype]'],"V","","Please enter your Phone Type.",false) &&
		checkSelect(document.forms[0].elements["quote[email]"],"V","","Please enter your E-mail Address.",false) &&
		checkEmail(document.forms[0].elements["quote[email]"],false) &&
		checkSelect(document.forms[0].elements["quote[email]"],"V","joe@example.com","Please supply a valid E-mail Address.",false)
		) {
			
		} else {
			return false;
		}
	
	

	if( !checkSelect(document.forms[0].elements['quote[stateProv]'], 'V', '',  "You must select your state/province") )
		return false;
	if( !checkSelect(document.forms[0].elements['quote[country]'], 'V', '',  "You must select your country") )
		return false;
	
	//SINGLE Apparently, there are still some countries without a postal code systems?
	if( document.forms[0].elements['quote[country]'].value == 'us') {
		if( !checkZIPCode(document.forms[0].elements['quote[zip]']) )
			return false;
	}
	
	if( !checkSelect(document.forms[0].elements['quote[interest]'], 'V', '',  "You must select your Primary Interest") )
		return false;
	
	if( !checkString(document.forms[0].elements['quote[message]'], "Project Description") )
		return false;
		
	//if( !checkString(document.forms[0].elements['captcha'], "Captcha") )
	//	return false;

	return true;
}

function check_account_limit() {
	if ( $('i_bio').value.length > 300 ) {
		$('i_bio').value = $('i_bio').value.substring(0, 300);
	}
	$('bio_count').innerHTML = $('i_bio').value.length;
	$('linktext_count').innerHTML = $('i_linktext').value.length;
	$('linkurl_count').innerHTML = $('i_linkurl').value.length;
}

function remove_rebuy(id) {
	
	
	var uri = "LiveUpdater.php";
	var data = "";
	
	data += nh.compressData("id", id);		
	data += nh.compressData("action", "remove_rebuy");
	LiveUpdater(uri, data);
	new Effect.BlindUp("rebuy_"+id);
	
	$('renew_link_'+id).style.display = '';
}

function cal_update(cal)
{
	id = cal.params.id;
	var uri = "LiveUpdater.php";
	var data = "";
	
	data += nh.compressData("id", id);		
	data += nh.compressData("start", $(id+'_start_click_date').value);
	data += nh.compressData("stop", $(id+'_stop_click_date').value);		
	data += nh.compressData("action", "update_click_count");
	LiveUpdater(uri, data);
	//alert(id);
}
/*
function popupAmazon( asin, key )
{
	theURL = 'http://buybox.amazon.com/exec/obidos/redirect?tag'+key+'&link_code=qcb&creative=23424&camp=2025&path=/dt/assoc/tg/aa/xml/assoc/-/' + asin + '/'+key+'/ref%3Dac_bb3_';
	winName = "_amazon";
	amznwin = window.open(theURL,winName,'menubar=yes,location=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes,width=380,height=525,screenX=10,screenY=10,top=10,left=10');
	amznwin.focus();
}
*/

function clear_stars( element )
{
	if ( element.value.indexOf('*') != -1)
		element.value = '';
}

function start_recur( id )
{
	var uri = "LiveUpdater.php";
	var data = "";
	
	data += nh.compressData("id", id);		
	data += nh.compressData("action", "update_recurring");
	LiveUpdater(uri, data);
}

function update_recurring_status ( id ) 
{
	$('expiration_link_'+id).parentNode.className = 'recur';
	$('expiration_link_'+id).parentNode.getElementsByTagName('h4').item(0).style.display = 'none';
	$('expiration_link_'+id).innerHTML = '(turn off auto-renew) ';
	$('expiration_link_'+id).className = 'turnoff';
	$('expiration_link_'+id).href = 'recur_edit.php?id='+id;
	$('expire_text_span_'+id).innerHTML = "Your listing will automatically renew on "
	
}

function renew_ad (id)
{
	var uri = "LiveUpdater.php";
	var data = '';
	
	data += nh.compressData("id", id);
	data += nh.compressData("action", "renew_ad");
	LiveUpdater(uri, data);
	
}

function renew_added (id, price, title, sub)
{
	$('renew_link_'+id).style.display = 'none';
	
	if ( sub == undefined ) {
		sub = '';
	}
	var item = "<div id='rebuy_"+id+"' style='display: none'><span class='price'>"+price+"</span><h2>"+title+"</h2>"+sub+"<span>Renewal</span><a onclick='remove_rebuy("+id+")'>remove</a></div>";
	new Insertion.Bottom( 'items', item );
	new Effect.BlindDown( 'rebuy_'+id );
	
	$('totals_title').style.display = 'block';
	$('totals').style.display = 'block';
	$('empty_string').style.display = 'none';
	$('totals_title').style.display = 'block';
	$('totals').style.display = 'block';
	$('empty_string').style.display = 'none';
	$('checkout_button').innerHTML = "Checkout & Activate";
	$('checkout_button').href = "checkout.php";
}

function check_terms ()
{
	if ( $('i_agree') ) {
		if ( $('i_agree').checked == false ) {
			alert("You must read and agree to the service terms before continuuing");
			return false;
		}
	}
	if ( !paypal_paid ) {
		if ( check_radio() ) {
			$('checkout_submit_btn').value = 'Processing Order... Please Wait';
			$('checkout_submit_btn').disabled = true;
			return true;
		}
		return false;
	}
	return true;
}

function check_radio ()
{
	var term_selected = false;
	var group = document.getElementsByName('length');
	
	for ( x=0; x <= 3; x++)
	{
		
		if ( group[x].checked ) {
			term_selected = true;
		}
	}
	if ( !term_selected ) {
		alert("You must select a subscription length before continuuing");
	}
	return term_selected;
}

function overlay_site ()
{
	overlay = document.createElement('div');
	overlay.id = 'overlay';

	overlay.style.height = document.body.clientHeight;
	overlay.style.width = document.body.clientWidth;

	document.body.appendChild(overlay);
	

	document.getElementById('state').style.display = 'none';//Crasy IE Hack
	document.getElementsByName('cc[type]').item(0).style.display = 'none';//Crasy IE Hack
	document.getElementsByName('cc[type]').item(0).style.display = 'none';//Crasy IE Hack
	document.getElementsByName('cc[expire_month]').item(0).style.display = 'none';//Crasy IE Hack
	document.getElementsByName('cc[expire_year]').item(0).style.display = 'none';//Crasy IE Hack
	
	var warn = document.getElementById('paypal_warn');
	var top_warn = warn.cloneNode(true);
	warn.parentNode.removeChild(warn);
	
	document.body.appendChild(top_warn);
	
	document.getElementById('paypal_warn').style.display = '';
	
	
}

function paypal_warn_confirm ()
{
	$('credit_card_block').style.display='none';
	document.getElementById('overlay').parentNode.removeChild(document.getElementById('overlay'));
	document.getElementById('paypal_warn').style.display = 'none';
	document.getElementById('state').style.display = '';//Crasy IE Hack
	document.getElementsByName('cc[type]').item(0).style.display = '';//Crasy IE Hack
	document.getElementsByName('cc[type]').item(0).style.display = '';//Crasy IE Hack
	document.getElementsByName('cc[expire_month]').item(0).style.display = '';//Crasy IE Hack
	document.getElementsByName('cc[expire_year]').item(0).style.display = '';//Crasy IE Hack
	if ( $('checkout_submit_btn') ) {
		document.getElementById('checkout_submit_btn').value="Login To Paypal";
		document.forms[0].action = 'paypal_login.php';
		document.getElementById('checkout_form').setAttribute('onsubmit', '');
		document.getElementById('service_agreement').style.display = 'none';
	}

}

function paypal_warn_reject ()
{
	document.getElementsByName('is_cc').item(0).checked = true;
	document.getElementById('overlay').parentNode.removeChild(document.getElementById('overlay'));
	document.getElementById('paypal_warn').style.display = 'none';
	document.getElementById('state').style.display = '';//Crasy IE Hack
	document.getElementsByName('cc[type]').item(0).style.display = '';//Crasy IE Hack
	document.getElementsByName('cc[type]').item(0).style.display = '';//Crasy IE Hack
	document.getElementsByName('cc[expire_month]').item(0).style.display = '';//Crasy IE Hack
	document.getElementsByName('cc[expire_year]').item(0).style.display = '';//Crasy IE Hack
}

function check_partner_form() {
	if (
		checkSelect(document.forms[0].elements['partner[company]'],"V","","Please enter your Company Name.",false) &&
		checkSelect(document.forms[0].elements['partner[fullname]'],"V","","Please enter your Name.",false) &&
		checkSelect(document.forms[0].elements['captcha'],"V","","Please enter the Verification Code.",false) &&
		checkSelect(document.forms[0].elements['partner[detail]'],"V","","Please enter detailed information.",false) &&
		checkSelect(document.forms[0].elements['partner[phone]'],"V","","Please enter your Phone Number.",false) &&
		checkSelect(document.forms[0].elements['partner[phonetype]'],"V","","Please enter your Phone Type.",false) &&
		checkSelect(document.forms[0].elements["partner[email]"],"V","","Please enter your E-mail Address.",false) &&
		checkSelect(document.forms[0].elements['partner[type]'],"V","","Please enter your partnership Type.",false) &&
		checkEmail(document.forms[0].elements["partner[email]"],false) &&
		checkSelect(document.forms[0].elements["partner[email]"],"V","joe@example.com","Please supply a valid E-mail Address.",false)
		) {
			
		} else {
			return false;
		}
		document.forms[0].elements['screenx'].value = screen.width;
		document.forms[0].elements['screeny'].value = screen.height;

	return true;
}

function check_faq_ask() {
	if (
		checkSelect(document.forms[0].elements['faq[fullname]'],"V","","Please enter your Name.",false) &&
		checkSelect(document.forms[0].elements["faq[email]"],"V","","Please enter your E-mail Address.",false) &&
		checkSelect(document.forms[0].elements['faq[question]'],"V","","Please enter your Name.",false)
		) {
			
		} else {
			return false;
		}
		document.forms[0].elements['screenx'].value = screen.width;
		document.forms[0].elements['screeny'].value = screen.height;


	return true;
}

function check_customer_help() {
	if (
		checkSelect(document.forms[0].elements['custhelp[message]'],"V","","Please enter your Message.",false)
		) {
			
		} else {
			return false;
		}

	document.forms[0].elements['screenx'].value = screen.width;
		document.forms[0].elements['screeny'].value = screen.height;
	return true;
}

function check_contact_form() {
	if (
		checkSelect(document.forms[0].elements['contact[company]'],"V","","Please enter your Company Name.",false) &&
		checkSelect(document.forms[0].elements['contact[fullname]'],"V","","Please enter your Name.",false) &&
		//checkSelect(document.forms[0].elements['captcha'],"V","","Please enter the Verification Code.",false) &&
		checkSelect(document.forms[0].elements['contact[message]'],"V","","Please enter detailed information.",false) &&
		checkSelect(document.forms[0].elements['contact[phone]'],"V","","Please enter your Phone Number.",false) &&
		checkSelect(document.forms[0].elements['contact[phonetype]'],"V","","Please enter your Phone Type.",false) &&
		checkSelect(document.forms[0].elements["contact[email]"],"V","","Please enter your E-mail Address.",false) &&
		checkEmail(document.forms[0].elements["contact[email]"],false) &&
		checkSelect(document.forms[0].elements["contact[email]"],"V","joe@example.com","Please supply a valid E-mail Address.",false)
		) {
			
		} else {
			return false;
		}
		document.forms[0].elements['screenx'].value = screen.width;
		document.forms[0].elements['screeny'].value = screen.height;

		


	return true;
}


function check_survey_form(form) {
	var checked = false;
	for ( var i = 0; i < form.elements['most_important'].length; i++ ) {
		if ( form.elements['most_important'][i].checked ) {
			checked = true;
		}
	}
	if ( !checked ) {
		warnSelectInvalid(form.elements['most_important'], "Please select which is most important to you.");
		return false;
	}
	
	var checked = false;
	for ( var i = 0; i < form.elements['get_from_wdl'].length; i++ ) {
		if ( form.elements['get_from_wdl'][i].checked ) {
			checked = true;
		}
	}
	if ( !checked ) {
		warnSelectInvalid(form.elements['get_from_wdl'], "Please select the most important thing that you look to get out of WDL.");
		return false;
	}
	
	var checked = false;
	for ( var i = 0; i < form.elements['ad_most_valuable'].length; i++ ) {
		if ( form.elements['ad_most_valuable'][i].checked ) {
			checked = true;
		}
	}
	if ( !checked ) {
		warnSelectInvalid(form.elements['ad_most_valuable'], "Please select which ad/listing selections you find most valuable.");
		return false;
	}
		
	if (
		checkSelect(form.elements['changeadd'],"V","","Please enter the first thing that you would change or add.",false) &&
		checkSelect(form.elements['likes'],"V","","Please enter what you like most about the current WDL website.",false) &&
		checkSelect(form.elements['dislikes'],"V","","Please enter what you like least about the current WDL website.",false) &&
		checkSelect(form.elements['lessons'],"V","","Please enter which websites you think we could learn some lessons from.",false) &&
		checkSelect(form.elements['comments'],"V","","Please enter your general comments and suggestions.",false)
		) {
			
		} else {
			return false;
		}
	return true;
}

function check_article_post() {
	if (
		checkSelect(document.forms[0].elements['article[body]'],"V","","Please enter your Body.",false)
		) {
			
		} else {
			return false;
		}

	document.forms[1].elements['screenx'].value = screen.width;
	document.forms[1].elements['screeny'].value = screen.height;
	printfire(document.forms[1]);
	
	return false;
	//return true;
}

function flash_write(file, width, height, adid, adurl) {
	if ( width == 468 ) {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'" id="movie" ><param name="FlashVars" value="adloc='+file+'&adid='+adid+'&adhref='+adurl+'" /><param name="movie" value="images/banner.swf" /><param name="menu" value="false" /><!--[if !IE]> <--> <object type="application/x-shockwave-flash" data="images/banner.swf"  width="'+width+'" height="'+height+'" FlashVars="adloc='+file+'&adid='+adid+'&adhref='+adurl+'"></object><!--> <![endif]--></object>');
	} else if ( width == 120 ) {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'" id="movie" ><param name="FlashVars" value="adloc='+file+'&adid='+adid+'&adhref='+adurl+'" /><param name="movie" value="images/home.swf" /><param name="menu" value="false" /><!--[if !IE]> <--> <object type="application/x-shockwave-flash" data="images/home.swf"  width="'+width+'" height="'+height+'" FlashVars="adloc='+file+'&adid='+adid+'&adhref='+adurl+'"></object><!--> <![endif]--></object>');
	} else {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'" id="movie" ><param name="movie" value="'+file+'" /><param name="menu" value="false" /><!--[if !IE]> <--> <object type="application/x-shockwave-flash" data="'+file+'"  width="'+width+'" height="'+height+'" ></object><!--> <![endif]--></object>');
	}
}

function updateMetros(field_id) {
	var uri = "LiveUpdater.php";
	var data = '';
	if ( document.getElementById('link_html_'+field_id) ) {
		document.getElementById('link_html_'+field_id).style.display = 'none';
		document.getElementById('link_filler_'+field_id).style.display = '';	
	}
	
	data += nh.compressData("id", field_id);
	data += nh.compressData("state_id", document.getElementById('subtypes['+field_id+']').value);
	data += nh.compressData("action", "updateMetros");
	LiveUpdater(uri, data);
}

function metro_change(field_id) {
	if ( !document.getElementById('link_html_'+field_id) ) {
		return;
	}
	if ( document.getElementById('subtypes['+field_id+']').value == '' ) {
		document.getElementById('link_html_'+field_id).style.display = 'none';
		document.getElementById('link_filler_'+field_id).style.display = '';
		return;
	}
	document.getElementById('link_html_'+field_id).style.display = '';
	document.getElementById('link_filler_'+field_id).style.display = 'none';
	
	var statename = document.getElementById('subtypes['+field_id+']').options[document.getElementById('subtypes['+field_id+']').selectedIndex].text;
	/*
	for ( x in document.getElementById('subtypes['+field_id+']').childNodes ) {
		if ( document.getElementById('subtypes['+field_id+']').childNodes[x]) {
			
			if ( document.getElementById('subtypes['+field_id+']').childNodes[x].tagName == 'OPTION' || document.getElementById('subtypes['+field_id+']').childNodes[x].tagName == 'option' ) {
				
				if ( document.getElementById('subtypes['+field_id+']').childNodes[x].selected ) {
					
					statename = document.getElementById('subtypes['+field_id+']').childNodes[x].innerHTML;
				}
			}
		}
	}*/
	var metroname = document.getElementById('ads_'+field_id+'_metros').options[document.getElementById('ads_'+field_id+'_metros').selectedIndex].text;
	/*for ( x in document.getElementById('ads_'+field_id+'_metros').childNodes ) {
		if ( document.getElementById('ads_'+field_id+'_metros').childNodes[x]) {
			if ( document.getElementById('ads_'+field_id+'_metros').childNodes[x].tagName == 'OPTION' || document.getElementById('ads_'+field_id+'_metros').childNodes[x].tagName == 'option') {
				if ( document.getElementById('ads_'+field_id+'_metros').childNodes[x].selected ) {
					metroname = document.getElementById('ads_'+field_id+'_metros').childNodes[x].innerHTML;
				}
			}
		}
	}*/
	
	var text = "Preferred ";
	text += '<a href="http://www.websitedesignerslist.com/';
	text += statename.replace(' ', '+');
	text += '+';
	text += metroname.replace(' ', '+');
	text += '+Website+Designers/';
	text += '3_';
	text += document.getElementById('ads_'+field_id+'_metros').value;
	text += '.html">';
	text += metroname;
	text += ', ';
	text += statename;
	text += ' Website Designer</a> at WebsiteDesignersList.com';
	document.getElementById('link_html_'+field_id).value = text;
}

function categoryChange(field_id) {
	if ( !document.getElementById('link_html_'+field_id) ) {
		return;
	}
	var text = 'Preferred firm in the ';
	text += '<a href="http://www.websitedesignerslist.com/';
	text += document.getElementById('subtypes['+field_id+']').options[document.getElementById('subtypes['+field_id+']').selectedIndex].text.replace(' ', '+');
	text += '/1_';
	text += document.getElementById('subtypes['+field_id+']').value;
	text += '.html';
	text += '">'
	text += document.getElementById('subtypes['+field_id+']').options[document.getElementById('subtypes['+field_id+']').selectedIndex].text;
	text += '</a> category at WebsiteDesignersList.com';
	document.getElementById('link_html_'+field_id).value = text;
}

function reloadCaptcha()
{
	var date = new Date();
	time = date.getTime();
	
	document.getElementById('captcha').src = "captcha.png?time="+time;
	
	return false;
}

function cc_us_check() {
	if ( !document.getElementById('state') ) {
		return;
	}
	if ( document.getElementById('state').value == 'XX' ) {
		document.getElementById('cc_pp').checked = true;
		document.getElementById('cc_cc').disabled = true;
		$('credit_card_block').style.display='none';
	} else {
		document.getElementById('cc_cc').disabled = false;
	}
	
}

