// JScript source code

// * Rate Your Ad
// _______________________________________
//
function AddSpecificValue(form_name,element_name,element_value,element_id) {
    boxTotal = parseInt(document.getElementById(element_id).innerHTML);
    if (element_name == "sa_calltoaction_1") {
        if (document.forms[form_name].elements[element_name].checked == true) {
            if (document.forms[form_name].sa_calltoaction_2.checked == true) {
                document.forms[form_name].sa_calltoaction_2.checked = false;
                newTotal = boxTotal - document.forms[form_name].sa_calltoaction_2.value;
                document.getElementById(element_id).innerHTML = newTotal;
                document.getElementById(element_id + "_End").innerHTML = newTotal;
            }
            boxTotal = parseInt(document.getElementById(element_id).innerHTML);
            newTotal = (boxTotal + parseInt(document.forms[form_name].elements[element_name].value));
            document.getElementById(element_id).innerHTML = newTotal;
            document.getElementById(element_id + "_End").innerHTML = newTotal;
        } else if (document.forms[form_name].elements[element_name].checked == false) {
            boxTotal = parseInt(document.getElementById(element_id).innerHTML);
            newTotal = (boxTotal - parseInt(document.forms[form_name].elements[element_name].value));
            document.getElementById(element_id).innerHTML = newTotal;
            document.getElementById(element_id + "_End").innerHTML = newTotal;
        }
    }
    if (element_name == "sa_calltoaction_2") {
        if (document.forms[form_name].elements[element_name].checked == true) {                
            if (document.forms[form_name].sa_calltoaction_1.checked == true) {
                document.forms[form_name].sa_calltoaction_1.checked = false;
                newTotal = boxTotal - document.forms[form_name].sa_calltoaction_1.value;
                document.getElementById(element_id).innerHTML = newTotal;
                document.getElementById(element_id + "_End").innerHTML = newTotal;
            }
            boxTotal = parseInt(document.getElementById(element_id).innerHTML);
            newTotal = (boxTotal + parseInt(document.forms[form_name].elements[element_name].value));
            document.getElementById(element_id).innerHTML = newTotal;
            document.getElementById(element_id + "_End").innerHTML = newTotal;
        } else if (document.forms[form_name].elements[element_name].checked == false) {
            boxTotal = parseInt(document.getElementById(element_id).innerHTML);
            newTotal = (boxTotal - parseInt(document.forms[form_name].elements[element_name].value));
            document.getElementById(element_id).innerHTML = newTotal;
            document.getElementById(element_id + "_End").innerHTML = newTotal;
        }
    }
}

function AddValue(form_name,element_name,element_value,element_id) {
    if (document.forms[form_name].elements[element_name].checked == true) {
        finalValue = parseInt(document.getElementById(element_id).innerHTML);
        variable_name = (finalValue + parseInt(document.forms[form_name].elements[element_name].value));
        document.getElementById(element_id).innerHTML = variable_name;
        document.getElementById(element_id + "_End").innerHTML = variable_name;
    } else {
        finalValue = parseInt(document.getElementById(element_id).innerHTML);
        variable_name = (finalValue - parseInt(document.forms[form_name].elements[element_name].value));
        document.getElementById(element_id).innerHTML = variable_name;
        document.getElementById(element_id + "_End").innerHTML = variable_name;
    }
}

function CalculateTotal() {
    ShowThisDiv("hide_grey_box")
    var FirstScore_End = parseInt(document.getElementById("FirstScore_End").innerHTML);
    var SecondScore_End = parseInt(document.getElementById("SecondScore_End").innerHTML);
    var ThirdScore_End = parseInt(document.getElementById("ThirdScore_End").innerHTML);
    var FourthScore_End = parseInt(document.getElementById("FourthScore_End").innerHTML);

    var totalPoints = FirstScore_End + SecondScore_End + ThirdScore_End + FourthScore_End;
    document.getElementById("Total").innerHTML = totalPoints;

    if (0 < totalPoints || 50 < totalPoints) {
        document.getElementById("YourScoreMeans").innerHTML = "<p id='RateYourAd'><span class='Heading'>Your Score is between a 0 &amp; 50</span><br>Your ad needs improvement in most areas. You're leaving out important information. Consult with your BNI Yellow Pages representative to find out how your ad can be improved to attract more customers. <a href='contact_us.aspx'>Click here to contact us.</a></p>"
    } 
    if (51 < totalPoints || 80 < totalPoints) {
        document.getElementById("YourScoreMeans").innerHTML = "<p id='RateYourAd'><span class='Heading'>Your Score is between a 51 &amp; 80</span><br>You have the foundation for a successful ad, but are missing key elements that consumers seek. Ask your BNI Yellow Pages representative how to strengthen your ad's areas of weakness. <a href='contact_us.aspx'>Click here to contact us.</a></p>"
    }
    if (81 < totalPoints || 110 < totalPoints) {
        document.getElementById("YourScoreMeans").innerHTML = "<p id='RateYourAd'><span class='Heading'>Your Score is between a 81 &amp; 110</span><br>Your ad is very good. Make minor, yet powerful improvements to create additional interest in your business. Your BNI Yellow Pages representative can assist you with this process. <a href='contact_us.aspx'>Click here to contact us.</a></p>"
    }
    if (111 < totalPoints || 140 < totalPoints) {
        document.getElementById("YourScoreMeans").innerHTML = "<p id='RateYourAd'><span class='Heading'>Your Score is between a 111 &amp; 140</span><br>You did a great job following the guidelines for an effective Yellow Pages ad. Remember, your BNI Yellow Pages representative is always available for consultation. <a href='contact_us.aspx'>Click here to contact us.</a></p>"
    }
}

// _______________________________________


// * Testimonials Page
// _______________________________________
//

function Testimonials(page) {
    window.open(page, "new_win", "resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no, width=720, height=530, top=100, left=100")
}

// _______________________________________

function HideThisDiv(element_id) {
    document.getElementById(element_id).style.display='none';
}

function ShowThisDiv(element_id) {
    document.getElementById(element_id).style.display='block';
}

function OpenNewImage(page,width_1,height_1) {
    window.open("new_window.asp?img="+ page,"name", "resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no, width="+width_1+", height="+height_1+", top=100, left=100")
    //window.open("new_window.asp?img=","new_win",resizable="no", scrollbars="no", toolbar="no", location="no", directories="no", status="no", menubar="no", width=width_1, height=height_1, top="100", left="100");
}

function GenerateRadioGraph(strategy,processes,technology) {

	document.write('<img src="http://chart.apis.google.com/chart?' +
	'chs=450x400' +
	'&amp;cht=r' +
	'&amp;chco=FF0000' +
	'&amp;chxt=x,y' +
	'&amp;chls=3' +
	'&amp;chd=t:' + strategy + ',' + processes + ',' + technology + ',' + strategy +
	'&amp;chxr=1,0,100,20' +
	'&amp;chxs=0,000000,16|1,000000,12' +
	'&amp;chxl=0:|Strategy|Processes|Technology" />');

}

function GenerateScatterPlot(strategy,processes,technology) {

	var connectivity = (processes+technology)/2;
	
	document.write('<div style="clear:both; width: 476px; height: 350px;">');
	document.write('<img src="images/chart_splatter_bg.png" style="float: left; position: absolute;" />');
	document.write('<img src="http://chart.apis.google.com/chart?' +
	'cht=s' +
	'&amp;chd=t:' + strategy + '|' + connectivity +
	'&amp;chxt=x,y' +
	'&amp;chxl=0:|0|20|40|60|80|100|1:|0|20|40|60|80|100' +
	'&amp;chs=400x300' +
	'&amp;chxs=0,000000,12|1,000000,12' +
	'&amp;chm=o,FF0000,0,1,20.0|N,000000,0,15,24' +
	'&amp;chg=20,20,5,5" style="float: left; position: absolute; padding-left: 42px;" />');
	document.write('</div>');

}

function AvailableWhitePapers() {
    var WhitePapers = new Array();
    
    /*
    WhitePapers[NaN] = Array(
        IMAGE,
        TITLE,
        DESCRIPTION,
        PDF TITLE);
    */
    WhitePapers[1] = Array(
        "whitepaper_id1.jpg",
        "Voice search options continue to expand",
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum neque odio, gravida vitae auctor quis, commodo vitae lorem. In quis orci blandit augue pellentesque tempor.",
        "VoiceSearch.pdf");
    
    WhitePapers[2] = Array(
        "whitepaper_id1.jpg",
        "What Makes an Effective SEM Program?",
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum neque odio, gravida vitae auctor quis, commodo vitae lorem. In quis orci blandit augue pellentesque tempor.",
        "EffectiveSEMprogram.pdf");
    
    WhitePapers[3] = Array(
        "whitepaper_id1.jpg",
        "What is the upside to media fragmentation?",
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum neque odio, gravida vitae auctor quis, commodo vitae lorem. In quis orci blandit augue pellentesque tempor.",
        "MediaFragmentationUpside.pdf");
        
    WhitePapers[4] = Array(
        "whitepaper_id1.jpg",
        "4 ways to wreck an online video ad campaign",
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum neque odio, gravida vitae auctor quis, commodo vitae lorem. In quis orci blandit augue pellentesque tempor.",
        "4WaysVideoCampaign.pdf");
    
    return WhitePapers;
}

function PopulateWhitePapers() {
    // Populate Array
    var WhitePapers = AvailableWhitePapers();
    
    document.write('<ul>');
    for ( var i = 1, length = WhitePapers.length; i<length; ++i ){
        document.write('<li><a href="white_papers.aspx?p=' + i + '">' + WhitePapers[i][1] + '</a></li>');
    }
    document.write('</ul>');
}

function GetWhitePaperByID(id) {
    // Populate Array
    var WhitePapers = AvailableWhitePapers();
    
    document.getElementById('wp_IMG').innerHTML = '<img src="images/' + WhitePapers[id][0] + '" />';
    document.getElementById('wp_Title').innerHTML = WhitePapers[id][1];
    document.getElementById('wp_Desc').innerHTML = WhitePapers[id][2];
    
}

function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return pair[1];
        }
    }
}
