
var fmTs = 5;
var menuItems = new Array();
var menuHeight = 29;
menuItems['Boloto Group'] = 'http://bolotogroup.com';
menuItems['The Solution Plan'] = 'http://www.thesolutionplan.com/';
menuItems['10 Cent Ads'] = 'http://tencentads.com/';
menuItems['Invite 5'] = 'http://invite5.com';
menuItems['Just Be Right'] = 'http://justberight.com';
menuItems['The Tuesday Review'] = 'http://thetuesdayreview.com';

var fmInt = null;
var fmExt = null;
var fmDirection = 1;
var fmFade = 0;
var fade_ie  = (document.all && document.getElementById);
var fade_moz = (!document.all && document.getElementById);


var activeDinaContent = 0;

function fmSet()
{
	var _m = gEl('float-menu');
	var _t = '';
	var _i = 0;
	for (var title in menuItems) 
	{
		_i++;
		var _h = (menuItems[title] == '') ? '' : 'href="' + menuItems[title] + '" target="_blank"';
		_t += '<div class="button" onmouseover="fmSetOver('+_i+')" onmouseout="fmSetOut('+_i+')" ><div class="back" id="float_bt'+_i+'"><div class="bullet">&nbsp;</div><a class="text" ' + _h + '>' + title + '</a></div></div>';
	}
	_m.innerHTML = _t;		
	menuHeight = menuHeight * _i;
	gEl('float-menu-in').style.top = '-' + menuHeight + 'px';
	gEl('float-menu-in').style.height = menuHeight + 'px';;
	gEl('float-menu').style.height = menuHeight + 'px';;
	gEl('float-menu').style.top = menuHeight + 'px';
	
	
}

function fmSetOver(id)
{
	if (fmExt != null)
		clearTimeout(fmExt);
	var _e = gEl('float_bt' + id);
	_e.className = 'back-over';
}
function fmSetOut(id)
{
	var _e = gEl('float_bt' + id);
	_e.className = 'back';
}

function fmOpen()
{
	if (fmInt != null)
		clearTimeout(fmInt);
	if (fmExt != null)
		clearTimeout(fmExt);
	fmDirection = 1;
	_fmSet(gEl('float-menu'),"'float-menu',0");
}
function fmClose(t)
{
	if (!t)
		t = 1000;
	if (fmExt != null)
		clearTimeout(fmExt);
	fmExt = setTimeout('_fmUnSet()', t);
}
function _fmUnSet()
{
	if (fmInt != null)
		clearTimeout(fmInt);
	fmDirection = 0;
	_fmSet(gEl('float-menu'), "'float-menu'," + menuHeight);
}

function _fmSet(el,t)
{
	fmInt = setInterval('_fmMove('+t+');',50); 
}

function _fmMove(eId,y) 
{
	var el = gEl(eId);
	var curY = parseInt(el.style.top);
	if (fmDirection == 1)
	{
		ts1 = ((y - curY) < 4) ? 2 : fmTs;
		step = parseInt((curY - y)/ts1);
		fmFade+=25;
	}
	else
	{
		ts1 = ((y - curY) < 4) ? 3 : fmTs;
		step = parseInt((curY - y)/ts1);
	}
	
	if(curY != y) 
	{ 
		el.style.top = curY - step + 'px'; 
		
		if (fmFade >= 0 && fmFade <= 100)
		{
			if(fade_ie) 
			{
				fmFade = (fmDirection == 0) ?  fmFade - 10 : fmFade + 10;
				try {
					el.filters.alpha.opacity = fmFade;
				} catch(e) { }
			}
			if(fade_moz) 
			{
				fmFade = (fmDirection == 0) ?  fmFade - 10 : fmFade + 10;
				el.style.MozOpacity = fmFade / 100;
			}
		}
		fmFade = (fmFade > 100) ? 100 : fmFade;
		fmFade = (fmFade < 0) ? 0: fmFade;
	}
//	gEl('info').innerHTML = eId + ' | ' + y + ' | ' + curY + ' | ' + step + ' = ' + fmFade + ' // ' + fmDirection;
	if(step == curY || (step <= 2 && step > -2)) 
	{ 
		el.style.top = y + 'px';
		clearInterval(fmInt);
		
		if (fmDirection == 0)
		{
			if(fade_ie)
				el.filters.alpha.opacity = 0;
			if(fade_moz) 
				el.style.MozOpacity = 0;
			fmFade = 0;
		}
		else
		{
			if(fade_ie) 
				el.filters.alpha.opacity = 100;
			if(fade_moz) 
				el.style.MozOpacity = 1;
			fmFade = 100;
		}
	}
}

var bRadioGroups = new Array();
bRadioGroups['gender'] = new Array('male', 'female');
bRadioGroups['vote'] = new Array('yes', 'no');

function bRadio(setKey, groupKey)
{
	var group = bRadioGroups[groupKey];
	for (var Key in group) 
	{
		var el = gEl(groupKey + '_' + group[Key]);
		el.checked = (group[Key] == setKey);
	}
}

function doVote()
{
	var vote_zip = gEl('vote_zip').value;
	var gender = 0;
	var vote = 0;
	var us_zip_pattern = /^\d{5}$/;
	var group = bRadioGroups['gender'];
	for (var Key in group) 
	{
		var el = gEl('gender' + '_' + group[Key]);
		if (el.checked)
		{
			gender = el.value;
			break;
		}
	}
	
	var group = bRadioGroups['vote'];
	for (var Key in group) 
	{
		var el = gEl('vote' + '_' + group[Key]);
		if (el.checked)
		{
			vote = el.value;
			break;
		}
	}
	
	if (vote_zip == '' || gender == 0 || vote == 0 )
	{
		alert('Please Complete all fields');
		return;
	}
	else if (!us_zip_pattern.test(vote_zip))
	{
		alert('Please Enter Valid Zip Code');
		return;
	}
	
	var action = '/post_get_info/';
	var request = 'isAjax=1&action=add_vote&PostCode=' + vote_zip + '&GenderId=' + gender + '&VoteId=' + vote;
	
	AjaxAfterLoadCall = 'ThanksForVote';
	AjaxRequestPost(action, request, 'null');
	
}
var thnksFade = 100;
function ThanksForVote()
{
	var el = gEl('thank-for-vote')
	el.style.display='block';
	if(fade_ie) 
		el.filters.alpha.opacity = 100;
	if(fade_moz) 
		el.style.MozOpacity = 1;
	thnksFade = 100;
		
	bRadio('off', 'gender')
	bRadio('off', 'vote')
	gEl('vote_zip').value = '';
	
	window.setTimeout("fadeOut('thank-for-vote')", 3000);
}

function fadeOut(elId)
{
	var el = gEl(elId)
	thnksFade -= 5;
	if (thnksFade < 0)
	{
		el.style.display='none';
		return;
	}
	if(fade_ie) 
		el.filters.alpha.opacity = thnksFade;
	if(fade_moz) 
		el.style.MozOpacity = thnksFade / 100;
		
	window.setTimeout("fadeOut('" + elId + "')", 50);
}
		

var StateId = 0;
function LoadReps(Id)
{
	StateId = Id;
	var action = '/post_get_info/';
	var request = 'isAjax=1&action=get_reps&StateId=' + StateId;
	
	AjaxAfterLoadCall = 'LoadNewsPapers';
	AjaxRequestPost(action, request, 'reps');
	
}

function LoadNewsContact(NewsId)
{
	var action = '/post_get_info/';
	var request = 'isAjax=1&action=get_news_contact&NewsId=' + NewsId;
	AjaxRequestPost(action, request, 'news-contact-info');
}


function LoadNewsPapers()
{
	//clear cities
	var _select = gEl('NewspaperId');
	for(var k = _select.options.length-1; k >= 0; k--)
		_select.options[k] = null;
	_select.options[0] = new Option("...loading...");
	
	var action = '/post_get_info/';
	var request = 'isAjax=1&action=get_newspapers&StateId=' + StateId;
	AjaxAfterLoadCall = 'NewsPapersPopulate';
	AjaxRequestType = 'xml';
	
	AjaxRequestPost(action, request, 'null');
}

function NewsPapersPopulate()
{
	XMLData = AjaxRequestResult;
	
	var Items = XMLData.getElementsByTagName('item');
	var _select = gEl('NewspaperId');
	var NewsId = 0;
	
	for(var i = 0; i < Items.length; i++)
	{
	    	var ItemID = Items[i].firstChild.firstChild.nodeValue;
	    	var ItemName = Items[i].firstChild.nextSibling.firstChild.nodeValue;
		_select.options[i] = new Option(ItemName,ItemID);
		
		NewsId = (NewsId == 0) ? ItemID : NewsId;
    	}
    	LoadNewsContact(NewsId)
}

var siteName = 'The Solution Plan - ';
var dcTitles = new Array();
dcTitles[1] = 'The Plan';
dcTitles[2] = 'White Paper';
dcTitles[3] = 'Inform The Masses';
dcTitles[4] = 'Vote Today!';

function setDinaContent(clickEl, navId)
{
	baseLink = clickEl.href;
	clickEl.blur();
	if (activeDinaContent == navId)
		return false;
	if (gEl('dina-content') == null)
		return true;
	
	document.title = dcTitles[navId];
	var action = baseLink;
	var request = 'isAjax=1';
	
	AjaxRequestPost(action, request, 'dina-content');
	for (var i = 1; i <= 4; i++)
	{
		var el = gEl('dina-nav' + i);
		var  src = el.src.replace('_on.', '.');
		
		if (i == navId)
		{
			src = src.replace('.gif', '_on.gif');
		}
		
		el.setAttribute("src",src);
		el.setAttribute("oldsrc",src);
		
		var el2 = gEl('dina-top' + i);
		if (el2 != null)
		{
			var  src2 = el2.src.replace('_on.', '.');
			if (i == navId)
			{
				src2 = src2.replace('.png', '_on.png');
			}
			el2.setAttribute("src",src2);
		}
	}
	
	activeDinaContent = navId;
	return false;
}

function printIt(pageName)
{
	popWin = window.open(pageName,'popWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=560,left=100,top=100');
	popWin.location.href = pageName;
	window.popWin.focus();
	window.popWin.print();
}