function sendSignup()
{
	var email = document.getElementById('email').value;

	if(!email.match(/^[a-zA-Z\._\-0-9]{1,}@[a-zA-Z0-9\-_\.]{1,}\.[a-zA-Z]{2,}$/))
	{
		alert('Invalid Email Address');
		return;
	}

	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		alert("Your browser does not support XMLHTTP!");
	}


	var link = 'http://' + location.host + '/site/Promotions/wow/0/' + email + '/';

	document.getElementById('result').innerHTML = 'Please wait...';

	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			document.getElementById('reg_area').innerHTML = xmlhttp.responseText;
		}
	}
	
	xmlhttp.open("GET",link,true);
	xmlhttp.send(null);
}



function getCurrentTopTen()
{
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
    	// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
    	// code for IE6, IE5
    	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
    	alert("Your browser does not support XMLHTTP!");
    }

    var link = 'http://' + location.host + '/site/Promotions/bitChampionsTop/5/0/1/';    
    xmlhttp.onreadystatechange=function()
    {
    	if(xmlhttp.readyState==4)
    	{
	    document.getElementById('current_top_ten').innerHTML = xmlhttp.responseText;
	    document.getElementById('more_link').style.display = 'block';
	}
    }
	
    xmlhttp.open("GET",link,true);
    xmlhttp.send(null);
}


function getBigTop(offset)
{
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
    	// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
    	// code for IE6, IE5
    	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
    	alert("Your browser does not support XMLHTTP!");
    }

    var link = 'http://' + location.host + '/site/Promotions/bitChampionsTop/10/' + offset + '/2/';    
    xmlhttp.onreadystatechange=function()
    {
    	if(xmlhttp.readyState==4)
    	{
	    document.getElementById('big_top_area').innerHTML = xmlhttp.responseText;
	}
    }
	
    xmlhttp.open("GET",link,true);
    xmlhttp.send(null);
}


function getLastWeekTop(offset)
{
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
    	// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
    	// code for IE6, IE5
    	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
    	alert("Your browser does not support XMLHTTP!");
    }

    var link = 'http://' + location.host + '/site/Promotions/bitChampionsTop/10/' + offset + '/3/';    
    xmlhttp.onreadystatechange=function()
    {
    	if(xmlhttp.readyState==4)
    	{
	    document.getElementById('last_week_top').innerHTML = xmlhttp.responseText;
	}
    }
	
    xmlhttp.open("GET",link,true);
    xmlhttp.send(null);
}

function resetSearch()
{
    document.getElementById('search_results').innerHTML = '';
}

var my_time_value = 0;
var search_active = 0;

function searchChar(name)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
	    xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
    	    // code for IE6, IE5
    	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
    	    alert("Your browser does not support XMLHTTP!");
	}
	
	
	
	

	var link = 'http://' + location.host + '/site/Promotions/bitChampionsTop/0/0/4/' + escape(name);    
	xmlhttp.onreadystatechange=function()
	{
    	    if(xmlhttp.readyState==4)
    	    {
		document.getElementById('search_results').innerHTML = xmlhttp.responseText;
		document.getElementById("searching").innerHTML = '';

	    }
	}
	
	xmlhttp.open("GET",link,true);
	if(escape(name).length > 1)
	    xmlhttp.send(null);
	else
	    document.getElementById("searching").innerHTML = '';
		
	my_time_value = 0;
	search_active = 0;
}



function startSearch(name)
{
    
    if(search_active == 0)
    {
	document.getElementById("searching").innerHTML = 'Searching...';
	if(my_time_value >= 1)
	{
    	    if(document.getElementById('search_results').innerHTML == '')
		document.getElementById('search_results').innerHTML = 'Searching...';
	
	    if(name == '')
	    {
		document.getElementById('search_results').innerHTML = '';
		return;
	    }

	    searchChar(name);
	}
	else
	{
	    my_time_value = 0;
	    search_active = 1;
	    increaseCounter();
	}
    }
}


function increaseCounter()
{
    my_time_value = my_time_value + 1;
    if(my_time_value >= 5)
	searchChar(document.getElementById('search_field').value);
    else
	setTimeout('increaseCounter()', 1000);
}




function resetZones()
{
    document.getElementById('buttons').style.display = 'block';
    document.getElementById('play_code').style.display = 'none';
    document.getElementById('share_code').style.display = 'none';
}


function switchTab(trigger)
{	
    $(".tabs a").removeClass();
    trigger.className = "sel";
    trigger.blur();
}


function showZone(value)
{
    
    if(value == 'play_code')
    {
	document.getElementById('buttons').style.display = 'none';
	document.getElementById('play_code').style.display = 'block';
	document.getElementById('share_code').style.display = 'none';
	
    }
    
    if(value == 'share_code')
    {
	document.getElementById('buttons').style.display = 'none';
	document.getElementById('play_code').style.display = 'none';
	document.getElementById('share_code').style.display = 'block';
    }
    
    
    if(value == 'big_top_area')
    {
	document.getElementById('big_top_area').style.display = 'block';
	document.getElementById('last_week_top').style.display = 'none';
	document.getElementById('search_char').style.display = 'none';
    }

    if(value == 'last_week_top')
    {
	document.getElementById('big_top_area').style.display = 'none';
	document.getElementById('last_week_top').style.display = 'block';
	document.getElementById('search_char').style.display = 'none';
    }

    if(value == 'search_char')
    {
	document.getElementById('big_top_area').style.display = 'none';
	document.getElementById('last_week_top').style.display = 'none';
	document.getElementById('search_char').style.display = 'block';
    }
    
    
}
