function whodeenee(thing, hidfeild, hidobj)
	{
	var d=document.getElementById(hidfeild);
	if(thing.value.indexOf("Other")!=-1)
		{
		d.className=null;
		document.getElementById(hidobj).focus();
		}
	else
		{
		d.className="nosho";
		document.getElementById(hidobj).value="";
		}
	}

function check()
	{
	var c=checker('phone','pl');
	var b=checker('email','el');
	var a=checker('name','nl');	
	if(a&&b&&c)
		{
		// submit by default (arg length is 0), only don't submit if optional argument is passed in and is false
		var do_submit = (arguments.length == 0 || arguments[0]);
		if(emVal(document.getElementById("email").value))
			{
				if (do_submit) document.forms[0].submit();
			}
		else
			{
			document.getElementById('el').style.color="red";
			document.getElementById('email').focus();
			alert('Please enter a valid Email address');
			return(false);
			}
		}
	else 
		{
		alert("Please fill out the required feilds.");
		return(false);
		}
		return true;
	}

function checker(formId, label)
	{
	if(!document.getElementById(formId).value)
		{
		document.getElementById(label).style.color="red";
		document.getElementById(formId).focus();
		return(false);
		}
	else
		{
		document.getElementById(label).style.color="black";
		return(true);
		}
	}
	
function emVal(email)
	{
	if(email.indexOf('@')<1 || email.indexOf('.')<1)
		{
		return false;
    	}
    else
    	{
    	return true;
    	}
	}

function get_radio_value(elem)
{
	for (var i = 0; i < elem.length; ++i)
	{
		if (elem[i].checked) return elem[i].value;
	}
	return null;
}

function get_radio_elem(elem)
{
	var i, radio_elem;
	for (i = 0; i < elem.length; ++i)
	{
		radio_elem = elem[i];
		if (radio_elem.checked) return radio_elem;
	}
	return null;
}

function set_radio(elem, index)
{
	if (!elem) return;
	for (var i = 0; i < elem.length; ++i)
		elem[i].checked = (i == index);
}

function show_newsletter_form()
{
	var container, parent, the_form, form_container;
	
	the_form = document.getElementById("nl_form");
	form_container = document.getElementById("newsletter_form");
	
	// already open, nothing to do
	if (form_container.className == "") return;
	
	container = document.getElementById("newsletter");
	for (parent = container.parentNode; parent.tagName != "LI"; parent = parent.parentNode);
	
	form_container.className = "";
	container.style.height = "245px";
	parent.className = "newsletter_open";
	the_form.email_address.focus();
}

function hide_newsletter_form(the_event)
{
	var container, parent, form_container;
	
	form_container = document.getElementById("newsletter_form");
	container = document.getElementById("newsletter");
	for (parent = container.parentNode; parent.tagName != "LI"; parent = parent.parentNode);
	
	parent.className = "";
	container.style.height = "80px";
	form_container.className = "nosho";
	
	if (!the_event) the_event = window.event;
	if (the_event)
	{
		the_event.cancelBubble = true;
		if (the_event.stopPropagation) the_event.stopPropagation();
	}
}

function check_newsletter_form()
{
	var the_form, data;
	
	the_form = document.getElementById("nl_form");
	if (!emVal(the_form.email_address.value))
	{
		alert("Please enter a valid email address.");
		the_form.email_address.focus();
		return;
	}
	if (the_form.first_name.value == "")
	{
		alert("Please enter a name.");
		the_form.first_name.focus();
		return;
	}
	
	//data = {
		//act:"add_newsletter_user",
		//name:the_form.fields_fname.value,
		//email:the_form.fields_email.value
	//};
	//document.getElementById("newsletter_processing").className = "";
	//ajax_send(data, "include/media/newsletter.php", process_newsletter_add);
	the_form.submit();
	process_newsletter_add();
}

function process_newsletter_add()
{
	document.getElementById("newsletter_buttons").className = "nosho";
	document.getElementById("newsletter_processing").className = "nosho";
	document.getElementById("newsletter_done").className = "";
	setTimeout(hide_newsletter_form, 1500);
}

var ajax_req, php_js_str;

function ajax_is_available()
{
	var tmp = null;
	
	if (window.XMLHttpRequest)     tmp = new XMLHttpRequest();
	else if (window.ActiveXObject) tmp = new ActiveXObject("Microsoft.XMLHTTP");
	return (typeof(tmp.open) == "object" || typeof(tmp.open) == "function");
}

function ajax_send(request, target, call_back_func)
{
	ajax_req = null;
	
	if (window.XMLHttpRequest)     ajax_req = new XMLHttpRequest();
	else if (window.ActiveXObject) ajax_req = new ActiveXObject("Microsoft.XMLHTTP");
	if (typeof(ajax_req.open) != "object" && typeof(ajax_req.open) != "function") ajax_req = new SimpleAJAX(); // ie6 fail
	
	if (ajax_req)
	{
		ajax_req.request = request;
		ajax_req.onreadystatechange = function() { ajax_receive(request, call_back_func); }
		ajax_req.open("POST", target, true);
		ajax_req.send(to_server(request));
	}
}

function SimpleAJAX()
{
	this.readyState = 0;
	this.status_check_wait = 256;
	
	this.open = function(method, url, is_asynchronous)
	{
		this.method = method;
		this.url = url;
		this.is_asynchronous = is_asynchronous;
	}
	
	this.send = function(request)
	{
		var elem, tmp_url, _this;
		
		_this = this;
		elem = doc_elem("simple_ajax_loc");
		if (empty(elem))
		{
			elem = document.createElement("iframe");
			elem.setAttribute("id", "simple_ajax_loc");
			elem.style.border = "0";
			elem.style.width = "0";
			elem.style.height = "0";        
			document.body.appendChild(elem);
		}
		
		elem.src = this.url + "?POST="+escape(request);
		setTimeout(function() { _this.check_status(); }, this.status_check_wait);
	}
	
	this.check_status = function()
	{
		var elem, _this;
		
		_this = this;
		elem = doc_elem("simple_ajax_loc");
		if (elem.getAttribute("readyState") == "complete")
		{
			this.responseText = window["simple_ajax_loc"].document.body.innerHTML;
			this.readyState = 4;
			this.onreadystatechange();
			window["simple_ajax_loc"].document.body.innerHTML = "";
		}
		else
		{
			this.status_check_wait += 256;
			setTimeout(function() { _this.check_status(); }, this.status_check_wait);
		}
	}
}

function ajax_receive(request, call_back_func)
{
	if (ajax_req.readyState == 4)
	{
		if (call_back_func) call_back_func(request, ajax_req.responseText);
	}
}

function empty(v)
{
	var i, type;
	
	type = typeof(v);
	switch (type)
	{
		case ("string"): return (v.match(/^\s*$/gi) != null);
		case ("number"): return (v == 0);
		case ("boolean"): return !v;
		case ("undefined"): return true;
		case ("object"):
			for (i in v) return false;
			return true;
	}
	
	// some unknown type, return false
	return false;
}

function is_int(x)
{
  return (!empty(x) && x.toString().indexOf(".") == -1 && !isNaN(x));
}

function from_server(x)
{
	php_js_str = x;
	return from_server_go();
}

function from_server_go()
{
	var o, type, len, data, i, index;
	
	type = php_js_str.charAt(0);
	php_js_str = php_js_str.substr(2);
	// string
	if (type == "s")
	{
		index = php_js_str.indexOf(":");
		len = Number(php_js_str.substr(0,index));
		php_js_str = php_js_str.substr(index+2);
		o = php_js_str.substr(0,len);
		php_js_str = php_js_str.substr(len+2);
		return o;
	}
	
	// array
	else if (type == "a")
	{
		index = php_js_str.indexOf(":");
		len = Number(php_js_str.substr(0,index));
		
		o = new Array();
		php_js_str = php_js_str.substr(index+2);
		for (i = 0; i < len; ++i)
		{
			index = from_server_go();
			data = from_server_go();
			o[index] = data;
		}
		php_js_str = php_js_str.substr(1);
		return o;
	}
	
	// integer, double
	else if (type == "i" || type == "d")
	{
		index = php_js_str.indexOf(";");
		o = Number(php_js_str.substr(0,index));
		php_js_str = php_js_str.substr(index+1);
		return o;
	}
	
	// boolean
	else if (type == "b")
	{
		index = php_js_str.indexOf(";");
		if (php_js_str.substr(0,index)) o = true;
		else o = false;
		php_js_str = php_js_str.substr(index+1);
		return o;
	}
	return null;
}

function to_server(x)
{
	php_js_str = "";
	to_server_go(x);
	return php_js_str;
}

function to_server_go(x)
{
	var o, type, len, data, i, index;
	
	type = typeof(x);
	
	if (x == null || type == "undefined")
	{
		php_js_str += "N;"
	}
	else if (type == "object")
	{
		len = 0;
		for (i in x) len++;
		php_js_str += "a:"+len+":{";
		for (i in x)
		{
			to_server_go(i);
			to_server_go(x[i]);
		}
		php_js_str += "}";
	}
	else if (type == "boolean")
	{
		php_js_str += "b:"+((x) ? 1 : 0)+";";
	}
	else if (x == "")
	{
		php_js_str += "s:0:\"\";";
	}
	else if (type == "string")
	{
		php_js_str += "s:"+x.length+":\""+x+"\";";
	}
	else if (!isNaN(x))
	{
		php_js_str += ((is_int(x)) ? "i" : "d") + ":"+x+";";
	}
	else if (empty(x))
	{
		php_js_str += "s:0:\"\";";
	}
	else
	{
		php_js_str += "N;"
	}
}




function open_window(url, title, params)
{
	var win = window.open(url, title, params);
	win.focus();
}

function open_chat()
{
	var win = window.open(document.location.protocol+"//messenger.providesupport.com/messenger/wpromote.html", "Wpromote Live Chat", "width=750,height=600,top=12,left=12,location=no,menubar=no,status=no,toolbar=no,scrollbars=no,resizable=yes");
	win.focus();
}

function open_intro()
{
	var w, h, sw, sh, left, top, new_win;
	
	w = 600;
	h = 400;
	
	sw = (window.screen.availWidth)  ? window.screen.availWidth  : window.screen.width;
	sh = (window.screen.availHeight) ? window.screen.availHeight : window.screen.height;
	
	left = (sw - w) / 2;
	top  = (sh - h) / 2;
	
	if (left < 0) left = 0;
	if (top < 0) top = 0;
	new_win = window.open("http://www.wpromote.com/intro/", "Wpromote Intro", "width="+w+",height="+h+",left="+left+",top="+top+",location=no,menubar=no,status=no,toolbar=no,scrollbars=no,resizable=yes");
	new_win.focus();
}

function ie_input_hack()
{
	var inputs, i, elem, elem_type;
	
	inputs = document.getElementsByTagName("input");
	for (i = 0; i < inputs.length; ++i)
	{
		elem = inputs[i];
		elem_type = elem.type;
		if (elem.type == "checkbox" || elem.type == "radio")
		{
			elem.style.border = "0";
			elem.style.width = "13px";
		}
	}
}

function preload_buttons()
{
	var i1, i2, i3, i4;
	
	i1 = new Image();
	i1.src = "include/modules/frames/tcg/images/btn_consultation_over.jpg";
	
	i2 = new Image();
	i2.src = "include/modules/frames/tcg/images/btn_continue_over.jpg";
	
	i3 = new Image();
	i3.src = "include/modules/frames/tcg/images/btn_get_started_over.jpg";
	
	i4 = new Image();
	i4.src = "include/modules/frames/tcg/images/btn_learn_more_over.jpg";
}

function wp_init()
{
	ie_input_hack();
	preload_buttons();
}

window.onload = wp_init;
