// JavaScript Document

function chngPic(target) {
	document.getElementById('defPicture').style.backgroundImage = "url('images/girls/"+target+"')";	
}
	
function restoreDefPic(target) {
	document.getElementById('defPicture').style.backgroundImage = "url('images/girls/"+target+"')";	
}

function showVote(target){
	
	var showForm;
	showForm = '<div style="height:44px;margin:10px 0px 0px 0px;"><form action="girl-details.php?gid='+target+'" name="voteForm"';
	showForm = showForm + '><strong>Please Enter Your Email Address:</strong><br\><input name="emailAdd" type="text" size="25" maxlength="50" style="font-size:11px;" /><input name="go" type="button" value="Vote" style="font-size:11px;" onclick="placeVote('+target+')" /></form></div>';
	
	document.getElementById("clicktovote").innerHTML = showForm;
	
}

// ***************** PLACE VOTES **************** //
function placeVote(target){
	
	var userEmail = document.voteForm.emailAdd.value;
	var userEmail = (userEmail.replace(/^\W+/,'')).replace(/\W+$/,'');
	
	if(!userEmail){
		alert('Please enter your email address!');
		document.voteForm.emailAdd.focus();
		return false;
	}
	
	if ((userEmail.indexOf('@') == -1) || (userEmail.indexOf('.') == -1))
	{
		alert("Please Enter A Valid Email Address!");
		document.voteForm.emailAdd.focus();
		return false;
	}
	
	// Define Variables //
	var searchTarget = target;
	var fromthescript = 1;
	var serverFileName = "do-vote.php";
	var variableNames = "target,isgood,usermail";
	var variableValues = searchTarget+","+fromthescript+","+userEmail;
	objectId = "clicktovote";
	
	// Send request to server //
	sendReq(serverFileName, variableNames, variableValues);

}

function refreshAfterVote(target)
{
	
	var url = "girl-details.php?gid="+target+"&yy=200920010";
	window.location = url;

}
function placeDirectVote(target)
{
	// Define Variables //
	var searchTarget = target;
	var fromthescript = 1;
	var serverFileName = "do-vote.php";
	var variableNames = "target,isgood,usermail";
	var variableValues = searchTarget+","+fromthescript+","+"dummy@mansionminds.com";
	
	objectId = "clicktovote"; // tells which HTML container to populate the response with to page variable objectId in sayjax.js
	
	// Send request to server //
	sendReq(serverFileName, variableNames, variableValues);

}


function placeVoteST(target,targetid){
	
	alert('Thank You For Your Vote!');
	
	// Define Variables //
	var searchTarget = target;
	var fromthescript = 1;
	var serverFileName = "place-vote-state.php";
	var variableNames = "target,isgood";
	var variableValues = searchTarget+","+fromthescript;
	objectId = "clicktovote" + targetid;
	
	// Send request to server //
	sendReq(serverFileName, variableNames, variableValues)
}

function showPromoCode(){
		
	document.getElementById('promoStart').style.display = "none";
	document.getElementById('pcodedisplay').style.display = "block";
	document.getElementById('promocode').select();

}

function copyToBoard() 
{
	promocode.select();
	promocode.innerText = promocode.innerText;
	Copied = promocode.createTextRange();
	Copied.execCommand("Copy");
	alert("The code has been successfully copied to your clipboard!");
}