var Mod_pop_up = {
	
	bullet1:null,
	bullet2:null,
	bullet3:null,
	score1:null,
	score2:null,
    score3:null,
    score4:null,
    score5:null,
    scoreTotal:null,
    projectTitle:null,

	message:null,
    surveyId: null,
    loggedIn: null,
    market: null,
    referer: null,
    section: null,
    odds: 20, // 20% chance

    handleButton: function (v, m) {
        if (v == true) {
            var val = m.children('#DRI_SurveyEmail').val();
            $.get(
                '/json/dri_survey.html',
                { 
                    id: Mod_pop_up.surveyId, 
                    status: Mod_pop_up.loggedIn, 
                    email: val, 
                    market: Mod_pop_up.market, 
                    referer: Mod_pop_up.referer, 
                    section: Mod_pop_up.section 
                }, 
                Mod_pop_up.parseResponse,
                "json"
            );
            return true;
        }
        return false;
    },
    handleSubmit: function (v, m) {
        var em = m.children('#DRI_SurveyEmail');
        if (v == true && em.val() == '') {
            em.css('border', 'solid #ff4444 2px');
            return false;
        }
        return true;
    },


    run: function() {
            // Only display the window to 20% of the visitors.
            var chance = Math.floor(Math.random() * 101);
           // if (chance <= this.odds) 
			{
				var baseFromLeft = 15;
				var block ='"block"';
                var message = '<div class="popUpAllContent"><div class="leftColumPopUp"><IMG SRC="/green/img/buttons/leaf.png" NAME="but" WIDTH="50"  BORDER="0" ALT="leaf" align="right"><h3>GlobalGiving Green Leaf</h3><p>We have evaluated <br><b>"'+this.projectTitle +'"</b><br> and given it the GlobalGiving Green Leaf because it addresses climate change sustainably and<ul><li>'+this.bullet1+'</li> <li>'+this.bullet2+'</li><li>'+this.bullet3+'</li></ul> Want to see more details: '+
'<a href="javascript:void(0);" onclick="showScore();">click here</a>.</p><p>Learn more about the Green Leaf <a href="/green/about.html#how">here</a>.</p></div>'+
		 ' 	<div id="scoreContainer" >                                                                                                                          '+
		 ' 				<div class="scoreBoxWithNote" id="scoreBoxWithNote"><div class="outsideBoxAll" id="outsideBoxAllproj">                                '+
		 ' 					<div class="graph1bar1 number" id="graph1bar1proj" style="width:'+baseFromLeft*this.score1+ 'px">'+this.score1+ '   	&nbsp;</div>         '+
		 ' 					<div class="graph1bar2 number" id="graph1bar2proj" style="width:'+baseFromLeft*this.score2+ 'px">'+this.score2+ '   	&nbsp;</div>         '+
		 ' 					<div class="graph1bar3 number" id="graph1bar3proj" style="width:'+baseFromLeft*this.score3+ 'px">'+this.score3+ '   	&nbsp;</div>         '+
		 ' 					<div class="graph1bar4 number" id="graph1bar4proj" style="width:'+baseFromLeft*this.score4+ 'px">'+this.score4+ '   	&nbsp;</div>         '+
		 ' 					<div class="graph1bar5 number" id="graph1bar5proj" style="width:'+baseFromLeft*this.score5+ 'px">'+this.score5+ '   	&nbsp;</div>         '+
		 ' 					<div class="graph1bar6 number" id="graph1bar6proj" style="width:'+baseFromLeft*this.scoreTotal+'px">'+this.scoreTotal+'		&nbsp;</div> '+
		 ' 				</div> <p><i>Note:</i> Climate Impact is weighted heavily in the formula determining Total Score.</p> </div>                                                                                                                             '+
		 ' 				<div class="leafBox" id="leafBox">&nbsp;</div>'+
		 ' 		</div></div>';


				$.prompt(message,{ 
				      buttons:{ Close:1 },
						promptspeed: 'fast', 
                      overlayspeed: 'fast',
				      prefix:'drisurvey',
				      show:'fadeIn'
				});
                /*$.prompt(
                    message, 
                    { 
                        buttons: { 
                            'Close Window': true, 
                        }, 
                        promptspeed: 'fast', 
                        overlayspeed: 'fast', 
                        show: 'fadeIn',
                        prefix: 'drisurvey'
                    }
                );*/
            }

    },

    trim: function(str) {
        var str = str.replace(/^\s\s*/, ''), ws = /\s/, i = str.length;
        while (ws.test(str.charAt(--i)));
        return str.slice(0, i + 1);
    }
};
function showScoreDetails(bullet1, bullet2, bullet3, score1,score2,score4,score3,score5,scoreTotal,projectTitle){ 
	var dri = Mod_pop_up;                                
	dri.bullet1 = unescape(bullet1);                               
	dri.bullet2 = unescape(bullet2);                               
	dri.bullet3 = unescape(bullet3);                               
	dri.score1 = score1;
	dri.score2 = score2;
	dri.score3 = score3;
	dri.score4 = score4;
	dri.score5 = score5;
	dri.scoreTotal = scoreTotal;
	dri.projectTitle = projectTitle;
	dri.run(); 
} 
function showScoreDetailsPending(projectTitle){ 
	var baseFromLeft = 15;
	var block ='"block"';
    var message = '<div class="popUpAllContent"><div class="leftColumPopUp"><IMG SRC="/green/img/buttons/leaf.png" NAME="but" WIDTH="50"  BORDER="0" ALT="leaf" align="right"><h3>The Green Leaf</h3><p>We are currently evaluating the project  <br><br><b>"'+projectTitle +'"</b><br><br><br>It is being considered for the GlobalGiving Green &#8220;Leaf&#8221; for its ability to create sustainable development with minimal climate impact.</ul>'+
'</p><p><br/><br/>Learn more about the Green Leaf <a href="/green/about.html#how">here</a>.</p></div>'+
' 	<div id="scoreContainer" >                                                                                                                          '+
' 				<div class="scoreBoxWithNote" id="scoreBoxWithNote"><div class="outsideBoxAll" id="outsideBoxAllproj">                                '+
' 					<div class="graph1bar1 number" id="graph1bar1proj" style="width:'+baseFromLeft*this.score1+ 'px">'+this.score1+ '   	&nbsp;</div>         '+
' 					<div class="graph1bar2 number" id="graph1bar2proj" style="width:'+baseFromLeft*this.score2+ 'px">'+this.score2+ '   	&nbsp;</div>         '+
' 					<div class="graph1bar3 number" id="graph1bar3proj" style="width:'+baseFromLeft*this.score3+ 'px">'+this.score3+ '   	&nbsp;</div>         '+
' 					<div class="graph1bar4 number" id="graph1bar4proj" style="width:'+baseFromLeft*this.score4+ 'px">'+this.score4+ '   	&nbsp;</div>         '+
' 					<div class="graph1bar5 number" id="graph1bar5proj" style="width:'+baseFromLeft*this.score5+ 'px">'+this.score5+ '   	&nbsp;</div>         '+
' 					<div class="graph1bar6 number" id="graph1bar6proj" style="width:'+baseFromLeft*this.scoreTotal+'px">'+this.scoreTotal+'		&nbsp;</div> '+
' 				</div> <p><i>Note:</i> Total score is determined based on a formula that weights each element differently.</p> </div>                                                                                                                             '+
' 				<div class="leafBox" id="leafBox">&nbsp;</div>'+
' 		</div></div>';


	$.prompt(message,{ 
	      buttons:{ Close:1 },
			promptspeed: 'fast', 
          overlayspeed: 'fast',
	      prefix:'drisurvey',
	      show:'fadeIn'
	});
    /*$.prompt(
        message, 
        { 
            buttons: { 
                'Close Window': true, 
            }, 
            promptspeed: 'fast', 
            overlayspeed: 'fast', 
            show: 'fadeIn',
            prefix: 'drisurvey'
        }
    );*/
}
function showScore(){
	document.getElementById("scoreBoxWithNote").style.display="block";
	document.getElementById("leafBox").style.display="none";
}