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 object_to_str(o, separator)
{
	var str, i;
	
	str = "";
	for (i in o)
	{
		if (!empty(str)) str += separator;
		str += i+"="+o[i];
	}
	return str;
}


function get_event_src(event)
{
	var src_elem;
	
	if (!event) event = window.event;
	src_elem = (event.currentTarget) ? event.currentTarget : event.srcElement;
	if (src_elem.nodeType == 3) src_elem = src_elem.parentNode;
	
	return src_elem;
}

// defaults to window.location
function parse_url()
{
	var url, i, protocol, domain, path, path_info, url_base;
	
	url = (arguments.length > 0) ? arguments[0] : String(window.location)
	
	matches = url.match(/^(.*):\/\/(.*?)(\/.*)$/);
	
	protocol = matches[1];
	domain = matches[2];
	path = matches[3];
	
	// remove url base (usually just in local installs)
	url_base = doc_elem("url_base").value;
	if (!empty(url_base) && (i = path.indexOf(url_base)) != -1) path = path.substr(i + url_base.length);
	
	path_info = path.split("/");
	
	return {
		"protocol":protocol,
		"domain":domain,
		"path":path,
		"path_info":path_info
	};
}

function add_hidden_field(field_name, field_value)
{
	var input;
	
	if (empty(field_name)) return false;
	input = document.createElement("INPUT");
	input.type = "hidden";
	input.name = field_name;
	input.value = (empty(field_value)) ? "true" : field_value;
	f.appendChild(input);
	return true;
}


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);
}


function dbg(text)
{
	var elem, text_node;
	
	elem = document.createElement("P");
	text_node = document.createTextNode(text);
	elem.appendChild(text_node);
	
	document.body.appendChild(elem);
}

function doc_elem(id)
{
	return (document.getElementById(id));
}

function doc_create(elem_type)
{
	return document.createElement(elem_type);
}

function get_event_src(event)
{
	var src_elem;
	
	if (!event) event = window.event;
	src_elem = (event.currentTarget) ? event.currentTarget : event.srcElement;
	if (src_elem.nodeType == 3) src_elem = src_elem.parentNode;
	
	return src_elem;
}

function event_stop(event)
{
	if (event) event.stopPropagation();
}


function get_absolute_pos(elem)
{
	return get_absolute_pos_go(elem.offsetParent, new Point(elem.offsetLeft, elem.offsetTop));
}

function get_absolute_pos_go(ancestor, pos)
{
	if (!ancestor || isNaN(ancestor.offsetLeft)) return pos;
	pos.x += ancestor.offsetLeft;
	pos.y += ancestor.offsetTop;
	return get_absolute_pos_go(ancestor.offsetParent, pos);
}

function Point(_x, _y)
{
	if (arguments.length > 2)
	{
		this[arguments[2]] = _x;
		this[arguments[3]] = _y;
	}
	else
	{
		this.x = _x;
		this.y = _y;
	}
}

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 format(n, decimals)
{
	var i, d;
	
	n = String(Math.round(n*Math.pow(10,decimals))*Math.pow(10,-decimals));
	
	d = n.indexOf(".");
	
	if (d == -1)
	{
		n += ".";
		for(i = 0; i < decimals; i++) n += "0";
		return n;
	}
	
	if (d == 0)
	{
		n = "0" + n;
		d++;
	}
	
	if (d == 1 && n.substring(0, 1) == "-")
	{
		n = "-0" + n.substring(1, n.length);
		d++;
	}
	
	n = n.substring(0, d + decimals + 1);
	
	while (n.length <= d + decimals) n += "0";
	return n;
}

function print_dollars(n)
{
	var i, lang, thousands_separator, decimal_symbol, currency_symbol;
	
	if (isNaN(n)) return n;
	n = format(n, 2);
	
	// check for language so we can format currency
	lang = doc_elem("lang");
	if (lang && lang.value) lang = lang.value;
	switch (lang)
	{
		case ("de"):
			thousands_separator = ".";
			decimal_symbol = ",";
			currency_symbol = "&euro;";
			break;
			
		default:
			thousands_separator = ",";
			decimal_symbol = ".";
			currency_symbol = "$";
			break;
	}
	
	n = n.replace(/\./, decimal_symbol);
	for (i = n.indexOf(decimal_symbol) - 3; i > 0; i -= 3)
	{
		n = n.substring(0, i) + thousands_separator + n.substr(i);
	}
	return currency_symbol + n;
}

function toggle(id)
{
	if(doc_elem(id).className=="checked"){
		doc_elem(id).className = '';
	}
	else{
		doc_elem(id).className = 'checked';
	}
}

function get_parent(elem, tag_name)
{
	var parent;
	
	for (parent = elem.parentNode; typeof(parent.tagName) != "undefined" && parent.tagName != tag_name; parent = parent.parentNode);
	return parent;
}

function get_child(parent, attribute, val)
{
	var i, child;
	
	for (i = 0; child = parent.childNodes[i]; ++i)
	{
		if (child && child[attribute] == val) return child;
	}
	return null;
}

function add_onload_func(new_func)
{
	var cur_func;
	
	cur_func = window.onload;
	window.onload = function() {
		if (cur_func) cur_func();
		new_func();
	}
}

var php_js_str;

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")
	{
		len = x.length;
		for (i = 0; i < x.length; ++i)
		{
			if (x.charCodeAt(i) > 128) ++len;
		}
		php_js_str += "s:"+len+":\""+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 url, win;
	
	url = (arguments.length > 0) ? arguments[0].href : "http://messenger.providesupport.com/messenger/wpromote.html";
	url = url.replace(/http(s|):/, document.location.protocol);
	
	win = window.open(url, "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 check_flash(){
	
	//if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]){
	if (FlashDetect.installed){
		//alert('flash detected');
	} else {
		var flash_div = document.getElementById("flash_banner");
		if (!flash_div) return;
		var header_div = flash_div.parentNode;
		header_div.className = 'header hdr-earth';
		header_div.removeChild(flash_div);
		var signup = document.createElement('a');
		signup.setAttribute('href','https://www2.gotomeeting.com/register/237719786');
		signup.setAttribute('target','_blank');
		signup.innerHTML='<div id="header_signup"></div>';
		header_div.appendChild(signup);
	}

}

/*
Copyright (c) Copyright (c) 2007, Carl S. Yestrau All rights reserved.
Code licensed under the BSD License: http://www.featureblend.com/license.txt
Version: 1.0.4
*/
var FlashDetect = new function(){
    var self = this;
    self.installed = false;
    self.raw = "";
    self.major = -1;
    self.minor = -1;
    self.revision = -1;
    self.revisionStr = "";
    var activeXDetectRules = [
        {
            "name":"ShockwaveFlash.ShockwaveFlash.7",
            "version":function(obj){
                return getActiveXVersion(obj);
            }
        },
        {
            "name":"ShockwaveFlash.ShockwaveFlash.6",
            "version":function(obj){
                var version = "6,0,21";
                try{
                    obj.AllowScriptAccess = "always";
                    version = getActiveXVersion(obj);
                }catch(err){}
                return version;
            }
        },
        {
            "name":"ShockwaveFlash.ShockwaveFlash",
            "version":function(obj){
                return getActiveXVersion(obj);
            }
        }
    ];
    /**
     * Extract the ActiveX version of the plugin.
     * 
     * @param {Object} The flash ActiveX object.
     * @type String
     */
    var getActiveXVersion = function(activeXObj){
        var version = -1;
        try{
            version = activeXObj.GetVariable("$version");
        }catch(err){}
        return version;
    };
    /**
     * Try and retrieve an ActiveX object having a specified name.
     * 
     * @param {String} name The ActiveX object name lookup.
     * @return One of ActiveX object or a simple object having an attribute of activeXError with a value of true.
     * @type Object
     */
    var getActiveXObject = function(name){
        var obj = -1;
        try{
            obj = new ActiveXObject(name);
        }catch(err){
            obj = {activeXError:true};
        }
        return obj;
    };
    /**
     * Parse an ActiveX $version string into an object.
     * 
     * @param {String} str The ActiveX Object GetVariable($version) return value. 
     * @return An object having raw, major, minor, revision and revisionStr attributes.
     * @type Object
     */
    var parseActiveXVersion = function(str){
        var versionArray = str.split(",");//replace with regex
        return {
            "raw":str,
            "major":parseInt(versionArray[0].split(" ")[1], 10),
            "minor":parseInt(versionArray[1], 10),
            "revision":parseInt(versionArray[2], 10),
            "revisionStr":versionArray[2]
        };
    };
    /**
     * Parse a standard enabledPlugin.description into an object.
     * 
     * @param {String} str The enabledPlugin.description value.
     * @return An object having raw, major, minor, revision and revisionStr attributes.
     * @type Object
     */
    var parseStandardVersion = function(str){
        var descParts = str.split(/ +/);
        var majorMinor = descParts[2].split(/\./);
        var revisionStr = descParts[3];
        return {
            "raw":str,
            "major":parseInt(majorMinor[0], 10),
            "minor":parseInt(majorMinor[1], 10), 
            "revisionStr":revisionStr,
            "revision":parseRevisionStrToInt(revisionStr)
        };
    };
    /**
     * Parse the plugin revision string into an integer.
     * 
     * @param {String} The revision in string format.
     * @type Number
     */
    var parseRevisionStrToInt = function(str){
        return parseInt(str.replace(/[a-zA-Z]/g, ""), 10) || self.revision;
    };
    /**
     * Is the major version greater than or equal to a specified version.
     * 
     * @param {Number} version The minimum required major version.
     * @type Boolean
     */
    self.majorAtLeast = function(version){
        return self.major >= version;
    };
    /**
     * Is the minor version greater than or equal to a specified version.
     * 
     * @param {Number} version The minimum required minor version.
     * @type Boolean
     */
    self.minorAtLeast = function(version){
        return self.minor >= version;
    };
    /**
     * Is the revision version greater than or equal to a specified version.
     * 
     * @param {Number} version The minimum required revision version.
     * @type Boolean
     */
    self.revisionAtLeast = function(version){
        return self.revision >= version;
    };
    /**
     * Is the version greater than or equal to a specified major, minor and revision.
     * 
     * @param {Number} major The minimum required major version.
     * @param {Number} (Optional) minor The minimum required minor version.
     * @param {Number} (Optional) revision The minimum required revision version.
     * @type Boolean
     */
    self.versionAtLeast = function(major){
        var properties = [self.major, self.minor, self.revision];
        var len = Math.min(properties.length, arguments.length);
        for(i=0; i<len; i++){
            if(properties[i]>=arguments[i]){
                if(i+1<len && properties[i]==arguments[i]){
                    continue;
                }else{
                    return true;
                }
            }else{
                return false;
            }
        }
    };
    /**
     * Constructor, sets raw, major, minor, revisionStr, revision and installed public properties.
     */
    self.FlashDetect = function(){
        if(navigator.plugins && navigator.plugins.length>0){
            var type = 'application/x-shockwave-flash';
            var mimeTypes = navigator.mimeTypes;
            if(mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && mimeTypes[type].enabledPlugin.description){
                var version = mimeTypes[type].enabledPlugin.description;
                var versionObj = parseStandardVersion(version);
                self.raw = versionObj.raw;
                self.major = versionObj.major;
                self.minor = versionObj.minor; 
                self.revisionStr = versionObj.revisionStr;
                self.revision = versionObj.revision;
                self.installed = true;
            }
        }else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript){
            var version = -1;
            for(var i=0; i<activeXDetectRules.length && version==-1; i++){
                var obj = getActiveXObject(activeXDetectRules[i].name);
                if(!obj.activeXError){
                    self.installed = true;
                    version = activeXDetectRules[i].version(obj);
                    if(version!=-1){
                        var versionObj = parseActiveXVersion(version);
                        self.raw = versionObj.raw;
                        self.major = versionObj.major;
                        self.minor = versionObj.minor; 
                        self.revision = versionObj.revision;
                        self.revisionStr = versionObj.revisionStr;
                    }
                }
            }
        }
    }();
};
FlashDetect.JS_RELEASE = "1.0.4";

function wp_init()
{
	ie_input_hack();
	preload_buttons();
	
	check_flash();
}

add_onload_func(wp_init);
