function getElementsByClassName(classname, node) 
{

if(!node) node = document.getElementsByTagName("body")[0];

var a = [];

var re = new RegExp('\\b' + classname + '\\b');

var els = node.getElementsByTagName("*");

for(var i=0,j=els.length; i<j; i++)

if(re.test(els[i].className))a.push(els[i]);

return a;

}

//Used by lolparade.cfc and enjoyLOL.cfc
function getComputerItem(type,PYLID)
{
	
	if (type=='wallpaper')
	{
		
		
		var width = screen.width;
		var height = screen.height;
		
		document.getElementById('confirm-div').innerHTML="img src='images/loaders/bigrotation2.gif'>Generating a wall paper to your resolution!";
		document.getElementById('confirm-div').style.display="block";
		
		DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null,'createWallpaper',PYLID,width,height,displayComputerItem);
		
	}
	
	
	else if (type=='display')
	{
		
		
		document.getElementById('confirm-div').innerHTML="<img src='../The%20LOL%20Family%20Animated%203D%20LOL,%20Emoticons,%20Avatars%20for%20IM%20&%20Mobile_files/images/loaders/bigrotation2.gif'>Retrieving image.";
		document.getElementById('confirm-div').style.display="block";
		
		DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null,'getDisplay',PYLID,displayComputerItem);		
	}
	
	else if (type=='emoticon')
	{
		

		
		document.getElementById('confirm-div').innerHTML="<img src='../The%20LOL%20Family%20Animated%203D%20LOL,%20Emoticons,%20Avatars%20for%20IM%20&%20Mobile_files/images/loaders/bigrotation2.gif'>Retrieving emoticon.";
		document.getElementById('confirm-div').style.display="block";
		
		DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null,'getEmoticon',PYLID,displayComputerItem);		
	}
	
	else
	{
		document.getElementById('confirm-div').innerHTML="Coming soon!";
		document.getElementById('confirm-div').style.display="block";
	}
}



//-----------------------------------------------------//END Timer Code -------------------------------------

function alreadyVoted()
{
	alert("testing, you can only vote for a lol once");
}

function ratePYL(PYLID,votee,voter,rating)
{
	DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null, 'ratePYL',PYLID,votee,voter,rating,returnVote);
}

function returnVote(container)
{
	//alert(container);
	getTop7PYL();
}

function highlightBorder(selected,highlight)
{
	if(highlight == true)
	{
		document.getElementById(selected).style.border = '1px solid #FFEF00';
	}
	else if (highlight == false)
	{
		document.getElementById(selected).style.border = '1px solid #888888';
	}
}

function highlightRatme(div,type)
{
	if(type==true)
	{
		document.getElementById(div).style.color = "#FFEF00";
	}
	
	if(type==false)
	{
		document.getElementById(div).style.color = "#515151";
	}
}



function loadMultiForm(type)
{
	DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null, 'loadMultiForm',type,returnMultiForm);
}


function returnMultiForm(container)
{
	document.getElementById('multi-form-holder').innerHTML = container ; 
}

function getTop7PYL(amount,picType,infoLocation)
{
	DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null, 'getTop7PYL',amount,picType,infoLocation,returnTop7PYL);
}

function returnTop7PYL(container)
{
	document.getElementById('top-seven-PYL').innerHTML = container;
}


function sendMSG(Test)
{
	//Vars
	var Email = document.getElementById('emailInquire').value;
	var Subject = document.getElementById('subjectInquire').value;
	var Message = document.getElementById('messageInquire').value;

	//Check to see if the form is filled out properly
	if (Email == '' || Subject == '' || Message == '')
	{
		formError("Please, fill out the form completely.","error-multi-form");
	}
	else if (checkMail(Email))
	{
		
		//If they all match then Check to see if the email is used
		DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null, 'sendMSG',Email,Subject,Message,MsgSent);
	}
	else
	{
		formError("Please, verify that you have entered a valid email address.","error-multi-form");
	}
}

function MsgSent(Container)
{
	formConfirmMulti("Your message has been sent, and the LOL family will respond to you shortly!","confirmation-holder");
}

function addShareLOL(PYLID,B_UID)
{
	
	DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null, 'addShareLOL',PYLID,B_UID,runJS);
}




function invitePeople(sendTo,PYLID)
{
	if(PYLID=='')
	{
		DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null, 'invitePeople',sendTo,displayInvite);
	}
	else
	{
		DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null, 'invitePeople',sendTo,PYLID,displayInvite);
	}
		

}


function displayInvite(container)
{
	document.getElementById('invite-form-holder').innerHTML = container;
}

function sendInvite(sendTo,PYLID,form,LOLID,MatchID)
{
	
	var myAddressbook = document.getElementById('recipient_list').value;
	
	
	if(myAddressbook == '')
	{
		formError('Please, add an email to continue');
	}
	
	else
	{
		
		
		if(PYLID=='' && LOLID =='' && MatchID =='')
		{
			DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null, 'sendInvite',myAddressbook,sendTo,thanksInvite);
		}
		else
		{
			
			if(PYLID != '')
			{
				if(form=='close')
				{
					DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null, 'sendInvite',myAddressbook,sendTo,PYLID,form,thanksInvite);
				}
				else
				{
					formProccess('Sending Invites!');
					DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null, 'sendInvite',myAddressbook,sendTo,PYLID,thanksInvite);
				}
			}
			else
			{
				
				
				if(form=='close')
				{
					DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null, 'sendInvite',myAddressbook,sendTo,'noPYL',form,LOLID,MatchID,thanksInvite);
				}
				else
				{
					formProccess('Sending Invites!');
					DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null, 'sendInvite',myAddressbook,sendTo,'noPYL',LOLID,MatchID,thanksInvite);
				}
			}
			
		}
	}
	
	
}


function thanksInvite(container)
{
	
	
	
	if(container=='true')
	{
		hideForm();
	}
	else
	{
		tempHide();
	}
	
}




function addInivte()
{
	

	//getEmail
	var inviteEmail = document.getElementById('recipient_list_single').value;
	
	
	//Check if its a valid email
	if(checkMail(inviteEmail))
	{
		var myAddressbook = document.getElementById('recipient_list').value;
		if(myAddressbook != '')
		{
			document.getElementById('recipient_list').value = inviteEmail+', '+myAddressbook;			
		}
		else
		{
			document.getElementById('recipient_list').value = inviteEmail+', ';
		}
		document.getElementById('recipient_list_single').value = '';
		document.getElementById('recipient_list_single').focus();
		
	}
	
	else
	{
		formError('Please, verify the email address you are attempting to add.');
	}
}



function thankInvite(container)
{
	hideProcError();
	loadForm(container,'inviteThank');
}



function submitSearch(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
	searchBox();
	
   return false;
   }
else
   return true;
}


function searchBox()
{
	var searchFor = document.getElementById('searchFor').value;
	if(searchFor == 'LOL Space search')
	{
		searchFor = '';
	}
	self.location='index.cfm?p=search&searchFor='+searchFor;
}


function sendMail(toEmail,fromEmail,subject,content)
{
	DWREngine._execute(_ajaxConfigIND._cfscriptLocation, null, 'sendMail',toEmail,fromEmail,subject,content,returnSendMail);
}


function returnSendMail(container)
{
	alert(container);
}






