// JavaScript Document
var choiceA=new Array();
choiceA[1] = "At the biggest fault line where all the action is";
choiceA[2] = "With my loved ones at home";
choiceA[3] = "At a disaster preparedness workshop";

var choiceB=new Array();
choiceB[1] = "a Tsunami";
choiceB[2] = "an Earthquake";
choiceB[3] = "a Fire";

var choiceC=new Array();
choiceC[1] = "Life vest";
choiceC[2] = "Prayer book";
choiceC[3] = "Waterproof camera"

var widgettxt = "  Grab the widget and take the poll at www.whowillsurvive2012.com";

function template0(choice) {
	choicetxt = choiceA[choice];
	return "I want to be " + choicetxt  +  " when the Big One hits in 2012." + widgettxt;
}

function template1(choice) {
	choicetxt = choiceB[choice];
	return "I think the world might end with " + choicetxt  +  " in 2012." + widgettxt;
}

function template2(choice) {
	choicetxt = choiceC[choice];
	return "I would grab a " + choicetxt  +  " first in a flood." + widgettxt;
}


function sharePoll(q,r) {

	if(q == 0){
		description = template0(r);
	} else if (q == 1){
		description =  template1(r);
	} else if (q == 2){
		description =  template2(r);
	}
	
	sendShare(description);
} 


function sendShare($description) {
	$title = '2012 Poll';
	$image_src = 'http://flash.sonypictures.com/shared/homevideo/2012/widget/facebookshare.jpg';
	$appurl = 'http://www.whowillsurvive2012.com';               
	$sharePath = 'http://www.sonypictures.com/homevideo/2012/widget/share.php';
	$shareURL = encodeURIComponent($sharePath + '?url=' + $appurl + '?' + '&title=' + $title + '&description=' + $description + '&image_src=' + $image_src);
	window.open('http://www.facebook.com/sharer.php?u=' + $shareURL + '&t=' + escape($title));
}
