/*do browser stuff*/

dom = (document.getElementById) ? true : false;
ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
ns4 = (document.layers && !dom) ? true : false;
ie4 = (document.all && !dom) ? true : false;
nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;


var zIndexXPR = 1;

function showhide(iidee)
{
zIndexXPR++;

var theLyr = (ns4)? document.layers[iidee] : (ie4)? document.all[iidee].style : (ie5||ns5)?   document.getElementById(iidee).style: null;				
theLyr.display= theLyr.display=='none' ? '' : 'none';
theLyr.zIndex = zIndexXPR;
}

function showDiv(iidee)
{
zIndexXPR++;

var theLyr = (ns4)? document.layers[iidee] : (ie4)? document.all[iidee].style : (ie5||ns5)?   document.getElementById(iidee).style: null;				
theLyr.display= 'block';
theLyr.zIndex = zIndexXPR;
}

function hideDiv(iidee)
{
var theLyr = (ns4)? document.layers[iidee] : (ie4)? document.all[iidee].style : (ie5||ns5)?   document.getElementById(iidee).style: null;				
theLyr.display= 'none';
}


/* WORD COUNTER */

function CountWords(this_field) {

var char_count = this_field.value.length;
var fullStr = this_field.value + " ";
var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
var splitString = cleanedStr.split(" ");
var word_count = splitString.length - 1;

if (fullStr.length <2) {
word_count = 0;
}

crossobj= document.getElementById("formWordCount");

if(word_count < 199) {
crossobj.innerHTML= 'Words used: <span style="color: green;"><b>' + word_count + '</b></span> (Editors prefer letters that contain no more than 250 words.)';
} else if(word_count >= 199 && word_count <= 249) {
crossobj.innerHTML= 'Words used: <span style="color: orange;"><b>' + word_count + '</b></span> (Editors prefer letters that contain no more than 250 words.)';
} else if(word_count >= 250) {
crossobj.innerHTML= 'Words used: <span style="color: red;"><b>' + word_count + '</b></span> (Editors prefer letters that contain no more than 250 words.)';
}

return word_count;
}

function CountWordsFR(this_field) {

var char_count = this_field.value.length;
var fullStr = this_field.value + " ";
var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
var splitString = cleanedStr.split(" ");
var word_count = splitString.length - 1;

if (fullStr.length <2) {
word_count = 0;
}

crossobj= document.getElementById("formWordCount");

if(word_count < 199) {
crossobj.innerHTML= 'Mots utilisés: <span style="color: green;"><b>' + word_count + '</b></span> (Rédigez une lettre ne comportant pas plus de 250 mots, les éditeurs les préfèrent.)';
} else if(word_count >= 199 && word_count <= 249) {
crossobj.innerHTML= 'Mots utilisés: <span style="color: orange;"><b>' + word_count + '</b></span> (Rédigez une lettre ne comportant pas plus de 250 mots, les éditeurs les préfèrent.)';
} else if(word_count >= 250) {
crossobj.innerHTML= 'Mots utilisés: <span style="color: red;"><b>' + word_count + '</b></span> (Rédigez une lettre ne comportant pas plus de 250 mots, les éditeurs les préfèrent.)';
}

return word_count;
}

$(document).ready(function(){
	
	if($('#slideshow').length > 0){
	
	// variables
	var npos = 0;
	var timer;
	var _total = $('#slideshow .item').length;
	var total_length = $('#slideshow .item').length * 960;
	$('#slideshow #wrapper').css('width',total_length);
	
	// navigation
	for (i=0;i<$('#slideshow .item').length;i++){
		var $href = $('#slideshow .item').eq(i).find('a.item_more').attr('href');
		var $youtube = $('#slideshow .item').eq(i).find('.youtube').text();
		var $link = $('<li><a class="pagination"><span>'+(i+1)+'</span></a></li>')
			.data('id',i)
			.data('youtube',$youtube)
			.data('href',$href)
			.appendTo('#slideshow ul')
			.click(onClick);
	}
	
	$('#slideshow ul li:first a').addClass('active');
	$('#slideshow a.slideshow_more,#slideshow a.slideshow_more-fr').attr("href", $('#slideshow ul li:first').data('href'));
	
	// youtube
	$('#slideshow .item').each(function(){
		if($(this).find('.youtube').text())		$(this).find('.image').remove();
		else									$(this).find('.youtube').remove();
	});
	
	}
	
	// autoplay
	timer = setInterval(function(){	nextSlide(); }, 7000);
	
	function nextSlide(){
		npos++;
		if(npos > _total-1) npos = 0;
		slide();
	}
	
	function onClick(event){
		clearInterval(timer);
		timer = setInterval(function(){	nextSlide(); }, 7000);
		
		npos = $(this).data('id');
		slide();
	}
	
	function slide(){
		var _this = $('#slideshow .item').eq(npos);
		
		$('#slideshow .youtube').empty();
		
		// active class
		$('#slideshow ul a.active').removeClass('active');
		$('#slideshow ul a.pagination').eq(npos).addClass('active');
		
		// button 'more' link
		//console.log(_this.data('href'));
		$('.slideshow_more,.slideshow_more-fr').attr("href", $('#slideshow ul li').eq(npos).data('href'));
		
		// youtube
		if(_this.data('youtube')){
			$embed = embedYoutube(_this.data('youtube'));
			$('#slideshow .item').eq(npos).find('.youtube').html($embed);
		}
		
		// slide
		var $x = npos * -960;
		$('#slideshow #wrapper').animate({left:$x}, 300);
	}
	
	function embedYoutube(code){
		var embed = '<object width="512" height="286" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"> <param value="http://www.youtube.com/v/' + code + '&hl=en&fs=1&rel=0" name="movie"> <param value="transparent" name="wmode"> <param value="true" name="allowFullScreen"> <param value="always" name="allowscriptaccess"> <embed width="512" height="286" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" src="http://www.youtube.com/v/' + code + '&hl=en&fs=1&rel=0"> </object>';
	
		return embed;
	}


});

/*  JAVASCRIPT TABLE BUILDING SCRIPT V2! */

var tdCount2 = 0;

function setupTable2(tableName,columns) {

table = document.getElementById(tableName);
tb=document.createElement('tbody');

table.appendChild(tb);

tdCount2 = 0;
maxTD = columns;

}

function addTableCell2(tableData) {

if (tdCount2 == 0) {
tr=document.createElement('tr');
tb.appendChild(tr);
}

//create our new cell
td=document.createElement('td');

//jQuery method to pass content into the new cell without quotes conflicts
jQuery(td).html(tableData);


//add our cell to the current row
tr.appendChild(td);

tdCount2++;

if (tdCount2 == maxTD) {
tdCount2 = 0;
}

}


/* FLASH VIDEO JAVASCRIPT */

var videoLoaded2 = 0;




function loadGutterVideoScreen2009(movieName)
{

crossobj= document.getElementById("cp09GutterVideoScreen") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="315px" height="200px" id="flvplayer2009"  align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/flvPlayerGutter2008v3.swf?file='+movieName+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/flvPlayerGutter2008v3.swf?file='+movieName+'" menu="false" quality="high" wmode=transparent width="315px" height="200px" name="flvplayer2009"  align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}

function loadGutterVideoScreen2009FR(movieName)
{

crossobj= document.getElementById("cp09GutterVideoScreen-f") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="315px" height="200px" id="flvplayer2009"  align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/flvPlayerGutter2008v3.swf?file='+movieName+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/flvPlayerGutter2008v3.swf?file='+movieName+'" menu="false" quality="high" wmode=transparent width="315px" height="200px" name="flvplayer2009"  align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}




function loadGutterVideoScreen2008(movieName)
{

crossobj= document.getElementById("aug08GutterVideoScreen") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="100%" id="flvplayer2008"  align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/flvPlayerGutter2008.swf?file='+movieName+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/flvPlayerGutter2008.swf?file='+movieName+'" menu="false" quality="high" wmode=transparent width="100%" height="100%" name="flvplayer2008"  align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}

function loadGutterVideoScreen2008FR(movieName)
{

crossobj= document.getElementById("aug08GutterVideoScreen-f") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="100%" id="flvplayer2008"  align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/flvPlayerGutter2008.swf?file='+movieName+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/flvPlayerGutter2008.swf?file='+movieName+'" menu="false" quality="high" wmode=transparent width="100%" height="100%" name="flvplayer2008"  align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}

function aug08loadFlashVideoScreen(movieName)
{

crossobj= document.getElementById("aug08VideoScreen");

//crossobj= document.getElementById("cpcVideoScreen");

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="100%" id="flvplayer" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/flvPlayerGutter2008.swf?file='+movieName+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/flvPlayerGutter2008.swf?file='+movieName+'" menu="false" quality="high" wmode=transparent width="100%" height="100%" name="flvplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}

function aug08Enlarge(which){

if (ie||ns6){
crossobj= document.getElementById("aug08PhotoGalleryImage") ;
}

crossobj.innerHTML='<img src="'+which+'" align=center>';
firstItem = false;

return false;
}

function aug08ShowImageInfo(title, description)
{
crossobj = document.getElementById("aug08PhotoGalleryInfo");
crossobj.innerHTML= '<span class=galleryInfoTitle>' + title+ '</span><span class=galleryInfoDesc>  ' +description+ '</span>';

return false;
}


/* FLASH VIDEO JAVASCRIPT */

var videoLoaded = 0;

function loadGutterVideoScreen2007(movieName)
{

crossobj= document.getElementById("May2007GutterVideoScreen") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="186" height="165" id="flvplayer2007"  align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/flvPlayerGutter2007.swf?file='+movieName+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/flvPlayerGutter2007.swf?file='+movieName+'" menu="false" quality="high" wmode=transparent width="186" height="165" name="flvplayer2007"  align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}

function loadGutterVideoScreen2007FR(movieName)
{

crossobj= document.getElementById("May2007GutterVideoScreenFR") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="186" height="165" id="flvplayer2007"  align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/flvPlayerGutter2007.swf?file='+movieName+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/flvPlayerGutter2007.swf?file='+movieName+'" menu="false" quality="high" wmode=transparent width="186" height="165" name="flvplayer2007"  align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}


/* GUTTER AUDIO PLAYER JS*/

function loadGutterAudio2007(audioFile, audioTitle)
{

crossobj= document.getElementById("cpcGutterAudioPlayer") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="186" height="100" id="flvplayer" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/audioPlayerGutter2007.swf?audioFile='+audioFile+'&audioTitle='+audioTitle+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/audioPlayerGutter2007.swf?audioFile='+audioFile+'&audioTitle='+audioTitle+'" menu="false" quality="high" wmode=transparent width="186" height="100" name="flvplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}


function loadGutterAudio2007FR(audioFile, audioTitle)
{

crossobj= document.getElementById("cpcGutterAudioPlayer") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="186" height="100" id="flvplayer" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/audioPlayerGutter2007-FR.swf?audioFile='+audioFile+'&audioTitle='+audioTitle+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/audioPlayerGutter2007-FR.swf?audioFile='+audioFile+'&audioTitle='+audioTitle+'" menu="false" quality="high" wmode=transparent width="186" height="100" name="flvplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}


var ie=document.all
var ns6=document.getElementById&&!document.all
var firstItem = true;

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body
}

function enlarge(which){

if (ie||ns6){
crossobj= document.getElementById("May2007PhotoGalleryImage") ;
}

crossobj.innerHTML='<img src="'+which+'" align=center>';
firstItem = false;

return false;
}

function showImageInfo(title, description)
{
crossobj = document.getElementById("May2007PhotoGalleryInfo");
crossobj.innerHTML= '<span class=galleryInfoTitle>' + title+ '</span><span class=galleryInfoDesc>  ' +description+ '</span>';

return false;
}

function checkrequired(which) {
    var pass=true;
    if (document.images) {
        for (i=0;i<which.length;i++) {
            var tempobj=which.elements[i];
            if (tempobj.name.substring(0,8)=="required") {
                if (((tempobj.type=="text"||tempobj.type=="textarea")&&
                tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
                tempobj.selectedIndex==0)) {
                    pass=false;
                    break;
                } else if (tempobj.type=="checkbox" && tempobj.checked == false) {
                    pass=false;
                    break;
                }
            }
        }
        if (!pass) {
            shortFieldName=tempobj.name.substring(8,30).toUpperCase();
            alert("Please check the agreement "+shortFieldName+" before registering.");
            return false;
        }
    } else {
        return true;
    }
}


//do browser stuff
dom = (document.getElementById) ? true : false;
ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
ns4 = (document.layers && !dom) ? true : false;
ie4 = (document.all && !dom) ? true : false;
nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;
var zIndexXPR = 1;

function showDiv(iidee)
{
zIndexXPR++;

var theLyr = (ns4)? document.layers[iidee] : (ie4)? document.all[iidee].style : (ie5||ns5)?   document.getElementById(iidee).style: null;				
theLyr.display= '';
theLyr.zIndex = zIndexXPR;
}

function hideDiv(iidee)
{
var theLyr = (ns4)? document.layers[iidee] : (ie4)? document.all[iidee].style : (ie5||ns5)?   document.getElementById(iidee).style: null;				
theLyr.display= 'none';
}

/* EMAIL FOR RECIPIENT DECIDER SCRIPT */

function setMailtoAddress(form) {

    var index=0;
    var strFeedbackTypeArr  =  new Array("Please select one","Membership","Donations","Website","Policy");
    var emailArr  =  new Array("","membership@conservative.ca","donations@conservative.ca","web@conservative.ca","policy@conservative.ca");
   
    sel=form.strFeedback_type.selectedIndex;

if (emailArr[sel] != '') {
    form.emailTo.value=emailArr[sel];
}
}

function setMailtoAddress2011(form) {

    var index=0;
    var strFeedbackTypeArr  =  new Array("Please select one","Website","Fundraising/Membership");
    var emailArr  =  new Array("","web@conservative.ca","membership@conservative.ca");
   
    sel=form.strFeedback_type.selectedIndex;
    
if (emailArr[sel] != '') {
    form.emailTo.value=emailArr[sel];

}

}



function validateAll(which) {


var pass=true;
if (document.images) {

for (i=0;i<which.length;i++) {

var tempobj=which.elements[i];
if (tempobj.name.substring(0,1)=="*") {

if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
         }
      }
   }
}

if (!pass) {
shortFieldName=tempobj.name.substring(1,40).toUpperCase();
alert("Please make sure the "+shortFieldName+" field was properly completed.");
return false;
}
else
return true;
}

/*  FRENCH VERSION */

function validateAllFrench(which) {

var pass=true;
if (document.images) {

for (i=0;i<which.length;i++) {

var tempobj=which.elements[i];
if (tempobj.name.substring(0,1)=="*") {

if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
         }
      }
   }
}

if (!pass) {
shortFieldName=tempobj.name.substring(1,40).toUpperCase();
alert("Veuillez vous assurer que le champ "+shortFieldName+" a �t� correctement rempli.");
return false;
}
else
return true;
}

var ie=document.all;
var ns6=document.getElementById&&!document.all;


function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body;
}

function enlarge(which){

alert("hello");

if (ie||ns6){
crossobj= document.getElementById("showimage") ;
if (crossobj==null)
crossobj= document.getElementById("showimage") ;
}

crossobj.innerHTML='<img src="'+which+'" align=center>';
crossobj.style.visibility="visible";
return false;

}


function showImageInfo(title, description)
{
document.getElementById("info") .innerHTML= '<p class=galleryInfoDesc>' +description+ '</p>';
return false;
}

var totalRows = 0;
var currentRow =0;

function switchRow(direction) {

rowName = 'imageRow'+ currentRow;

//hide the current row that is visible.
openhide(rowName);


if (direction == 'next')  {
currentRow++;

//check to see if the new number is greater than total rows
if (currentRow > totalRows) {
currentRow = 1;
} 

} else if (direction == 'back') {
currentRow--;

//check to see if the new number is less than 1
if (currentRow == 0) {
currentRow = totalRows;
} 

}

rowName = 'imageRow'+ currentRow;
//hide the current row that is visible.
openhide(rowName);
}

/* FLASH VIDEO JAVASCRIPT */

var videoLoaded = 0;

function loadGutterVideoScreen(movieName)
{

crossobj= document.getElementById("cpcGutterVideoScreen") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="100%" id="flvplayer" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/flvPlayerHome.swf?file='+movieName+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/flvPlayerHome.swf?file='+movieName+'" menu="false" quality="high" wmode=transparent width="100%" height="100%" name="flvplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}

function loadFlashVideoScreen(movieName)
{

crossobj= document.getElementById("election07VideoScreen");

//crossobj= document.getElementById("cpcVideoScreen");

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="100%" id="flvplayer" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/templateElements/moduleinterface/1884/flvplayer.swf?file='+movieName+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/templateElements/moduleinterface/1884/flvplayer.swf?file='+movieName+'" menu="false" quality="high" wmode=transparent width="100%" height="100%" name="flvplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}

/* GUTTER AUDIO PLAYER JS*/

function loadGutterAudio(audioFile, audioTitle)
{

crossobj= document.getElementById("cpcGutterAudioPlayer") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="198" height="100" id="flvplayer" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/cpcAudioPlayer.swf?audioFile='+audioFile+'&audioTitle='+audioTitle+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/cpcAudioPlayer.swf?audioFile='+audioFile+'&audioTitle='+audioTitle+'" menu="false" quality="high" wmode=transparent width="198" height="100" name="flvplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}


function loadGutterAudioFR(audioFile, audioTitle)
{

crossobj= document.getElementById("cpcGutterAudioPlayer") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="198" height="100" id="flvplayer" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/cpcAudioPlayerFr.swf?audioFile='+audioFile+'&audioTitle='+audioTitle+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/cpcAudioPlayerFr.swf?audioFile='+audioFile+'&audioTitle='+audioTitle+'" menu="false" quality="high" wmode=transparent width="198" height="100" name="flvplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}


/*  Description changer  */

function loadFlashVideoDetails(info, objectName)
{

if (ie||ns6){
crossobj= document.getElementById(objectName) ;
if (crossobj==null)
crossobj= document.getElementById(objectName) ;
}

crossobj.innerHTML = info;

return false;

}

/* Video Screen Quicktime - JS */

function loadVideoScreen(movieName)
{

if (ie||ns6){
crossobj= document.getElementById("videoScreen") ;
if (crossobj==null)
crossobj= document.getElementById("videoScreen") ;
}


//alert(movieName);

crossobj.innerHTML= '<embed src=' + movieName + ' width="320" height="256" type="video/quicktime" caching="yes" pluginspage="http://www.apple.com/quicktime"></embed>';

return false;

}



// store functions

function enableField(fieldObject) {
    fieldObject.disabled = false;
}

function disableField(fieldObject) {
    fieldObject.disabled = true;
}

function checkMaximumValue(fieldObject) {
    theValue = Number(fieldObject.value);
    if (isNaN(theValue)) {
        alert("Please input a numeric value.");
        fieldObject.focus();
        return;
    }

    if (theValue > 1100) {
        alert("Sorry, you may not make a donation larger than the maximum amount.");
        fieldObject.focus();
    }
}

/*  JAVASCRIPT TABLE BUILDING SCRIPT */

var tdCount = 0;

function setupTable(tableName,columns) {

table = document.getElementById(tableName);
tb=document.createElement('tbody');

table.appendChild(tb);

tdCount = 0;
maxTD = columns;

}

function addTableCell(tableData) {

if (tdCount == 0) {
tr=document.createElement('tr');
tb.appendChild(tr);
}

//create our new cell
td=document.createElement('td');
td.innerHTML=tableData;

//add our cell to the current row
tr.appendChild(td);

tdCount++;

if (tdCount == maxTD) {
tdCount = 0;
}

}




/*  JAVASCRIPT TABLE BUILDING SCRIPT V2*/

var tdCount2 = 0;
var trCount2 = 0;

function setupTable2(tableName,columns,rows) {

table = document.getElementById(tableName);
tb=document.createElement('tbody');

table.appendChild(tb);

tdCount2 = 0;
trCount2 = 0;
maxTD = columns;
maxTR = rows;
}

function addTableCell2(tableData) {

if (tdCount2 == 0) {
tr=document.createElement('tr');
tb.appendChild(tr);
}

if(trCount2 == 0) {
td=document.createElement('td');
tr.appendChild(td);
}

if(trCount2 < maxTR){
//create our new cell
div=document.createElement('div');
div.innerHTML=tableData;

//add our cell to the current row
td.appendChild(div);	
} else {

//create our new cell
td=document.createElement('td');
td.innerHTML=tableData;

//add our cell to the current row
tr.appendChild(td);
	
}

tdCount2++;
trCount2++;

if (tdCount2 == maxTD) {
tdCount2 = 0;
}

if (trCount2 == maxTR) {
trCount2 = 0;
}

}



objects = document.getElementsByTagName("object"); 
for (var i = 0; i < objects.length; i++) 
{ 
    objects[i].outerHTML = objects[i].outerHTML; 
}

function loadGutterVideoScreen2010(movieName)
{

crossobj= document.getElementById("sep10GutterVideoScreen") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="512" height="288" id="flvplayer2010"  align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/flvPlayerGutter2010.swf?file='+movieName+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/flvPlayerGutter2010.swf?file='+movieName+'" menu="false" quality="high" width="512" height="288" name="flvplayer2008" wmode="transparent" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}

function loadGutterVideoScreen2010FR(movieName)
{

crossobj= document.getElementById("sep10GutterVideoScreen-f") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="512" height="288" id="flvplayer2010"  align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/flvPlayerGutter2010.swf?file='+movieName+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/flvPlayerGutter2010.swf?file='+movieName+'" menu="false" quality="high" width="512" height="288" name="flvplayer2008" wmode="transparent" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}

function loadGutterVideoScreen2011(movieName)
{

crossobj= document.getElementById("sep10GutterVideoScreenSub") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="320" height="202" id="flvplayer2011"  align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/flvPlayerGutter2011.swf?file='+movieName+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/flvPlayerGutter2011.swf?file='+movieName+'" menu="false" quality="high" width="320" height="202" name="flvplayer2008" wmode="transparent" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}

function loadGutterVideoScreen2011FR(movieName)
{

crossobj= document.getElementById("sep10GutterVideoScreenSub-fr") ;

crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="320" height="202" id="flvplayer2011"  align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/media/flvPlayerGutter2011.swf?file='+movieName+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <PARAM NAME=wmode VALUE=transparent> <embed src="/media/flvPlayerGutter2011.swf?file='+movieName+'" menu="false" quality="high" width="320" height="202" name="flvplayer2008" wmode="transparent" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object>';

return false;

}


/* IMAGE MANAGEMENT JAVASCRIPT */

function MM_swapImgRestore() {
  	var i, x, a = document.MM_sr;
  	for(i=0; a&&i < a.length&&(x=a[i])&&x.oSrc; i++) {
  		x.src=x.oSrc;
	}
}

function MM_preloadImages() {
  	var d = document;
	if(d.images){
		if(!d.MM_p) {
			d.MM_p=new Array();
		}
    	var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
		for(i=0; i < a.length; i++) {
    		if (a[i].indexOf("#")!=0) {
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
		}
	}
}

function MM_findObj(n, d) {
  	var p, i, x;
	if(!d) {
		d=document;
	}
	if((p=n.indexOf("?")) > 0&&parent.frames.length) {
    	d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
  	if(!(x=d[n])&&d.all) {
		x=d.all[n];
	}
	for (i=0; !x&&i<d.forms.length; i++) {
		x=d.forms[i][n];
	}
  	for(i=0; !x&&d.layers&&i<d.layers.length; i++) {
		x=MM_findObj(n,d.layers[i].document);
	}
	return x;
}

function MM_swapImage() {
  	var i, j = 0, x, a = MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0; i < (a.length-2); i+=3) {
   		if ((x=MM_findObj(a[i])) != null){
			document.MM_sr[j++]=x;
			if(!x.oSrc) {
				x.oSrc=x.src;
				x.src=a[i+2];
			}
		}
	}
}

function openPopup(theURL,winName,features)
{
    window.open(theURL,winName,features);
}

function openPreview(URLtoOpen,windowName,screenWidth, screenHeight) {
	var screenWidth;
	var screenHeight;

	if (navigator.appName == 'Microsoft Internet Explorer' && (navigator.platform.substring(0,3) == 'Win')) {
			var scw=screenWidth;
			var sch=screenHeight;
			var scl=(screen.width / 2) - (screenWidth / 2);
			var sct=(screen.height / 2) - (screenHeight / 2);
			window.open (URLtoOpen, windowName, "left=" + scl + ",top=" + sct + ",width=" + scw + ",height=" + sch + ',scrollbars=yes,status=no,resizable=yes');
		}
	else if (navigator.appName == 'Netscape' || navigator.platform == 'MacPPC') {
			var scw=screenWidth;
			var sch=screenHeight;
			var scl=(screen.width / 2) - (screenWidth / 2);
			var sct=(screen.height / 2) - (screenHeight / 2);
			window.open (URLtoOpen, windowName, "screenX=" + scl + ",screenY=" + sct + ",outerWidth=" + scw + ",outerHeight=" + sch + ',scrollbars=yes,status=no,resizable=yes');
		}
	else {
			var scw=screenWidth;
			var sch=screenHeight;
			var scl=(screen.width / 2) - (screenWidth / 2);
			var sct=(screen.height / 2) - (screenHeight / 2);
			window.open (URLtoOpen, windowName, "screenX=" + scl + ",screenY=" + sct + ",outerWidth=" + scw + ",outerHeight=" + sch + ',scrollbars=yes,status=no,resizable=yes');
		}
}


function openPopup(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function show_msg(msg) { alert(msg); }

function validateForm() {
	missing_required = 0;

	for (i = 0; i < arguments.length; i++) {
		if(arguments[i] == '') {
			missing_required = 1;
		}
	}

	if(missing_required) {
		alert("A required form field is missing.");
		return false;
	} else {
		return true;
	}
}

function expCustomLink(myURL) {
	location.href = myURL;
}

function setStatus(message)
{
	window.status = message;
}

function setUrl(path)
{
	document.location.href = path;
}

var screenWidth;
var screenHeight;

function expArticleLink(sectionId, articleId) {

	location.href = '/index.php?section_id=' + sectionId + '&section_copy_id=' + articleId;
}

function expPopupWindow(url, widthVal, heightVal, resizableVal, scrollbarsVal, toolbarVal, locationVal, directoriesVal, statusVal, menubarVal, copyHistoryVal) {

	var attributes = "width="  	 	 + widthVal       +
				 	 ",height=" 	 + heightVal      +
				 	 ",resizable="  + resizableVal  +
				 	 ",scrollbars="  + scrollbarsVal  +
				 	 ",toolbar=" 	 + toolbarVal 	  +
				 	 ",location=" 	 + locationVal 	  +
				 	 ",directories=" + directoriesVal +
				 	 ",status=" 	 + statusVal 	  +
				 	 ",menubar=" 	 + menubarVal 	  +
				 	 ",copyhistory=" + copyHistoryVal;

	window.open(url, 'WindowName', attributes);
}

<!--
// callback pool needs global scope
var jsrsContextPoolSize = 0;
var jsrsContextMaxPool = 10;
var jsrsContextPool = new Array();
var jsrsBrowser = jsrsBrowserSniff();
var jsrsPOST = true;
var containerName;

// constructor for context object
function jsrsContextObj( contextID ){
  
  // properties
  this.id = contextID;
  this.busy = true;
  this.callback = null;
  this.container = contextCreateContainer( contextID );
  
  // methods
  this.GET = contextGET;
  this.POST = contextPOST;
  this.getPayload = contextGetPayload;
  this.setVisibility = contextSetVisibility;
}

//  method functions are not privately scoped 
//  because Netscape's debugger chokes on private functions
function contextCreateContainer( containerName ){
  // creates hidden container to receive server data 
  var container;
  switch( jsrsBrowser ) {
    case 'NS':
      container = new Layer(100);
      container.name = containerName;
      container.visibility = 'hidden';
      container.clip.width = 100;
      container.clip.height = 100;
      break;
    
    case 'IE':
      document.body.insertAdjacentHTML( "afterBegin", '<span id="SPAN' + containerName + '"></span>' );
      var span = document.all( "SPAN" + containerName );
      var html = '<iframe name="' + containerName + '" src="" charset="iso-8859-1"></iframe>';
      span.innerHTML = html;
      span.style.display = 'none';
      container = window.frames[ containerName ];
      break;
      
    case 'MOZ':  
      var span = document.createElement('SPAN');
      span.id = "SPAN" + containerName;
      document.body.appendChild( span );
      var iframe = document.createElement('IFRAME');
      iframe.name = containerName;
      iframe.id = containerName;
      span.appendChild( iframe );
      container = iframe;
      break;

    case 'OPR':  
      var span = document.createElement('SPAN');
      span.id = "SPAN" + containerName;
      document.body.appendChild( span );
      var iframe = document.createElement('IFRAME');
      iframe.name = containerName;
      iframe.id = containerName;
      span.appendChild( iframe );
      container = iframe;
      break;
  }
  return container;
}

function contextPOST( rsPage, func, parms ){
  var d = new Date();
  var unique = d.getTime() + '' + Math.floor(1000 * Math.random());
  var doc = (jsrsBrowser == "IE" ) ? this.container.document : this.container.contentDocument;
  
doc.open();
  doc.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body>');
  doc.write('<form accept-charset="iso-8859-1" name="jsrsForm" method="post" target="" ');
  doc.write(' action="' + rsPage + '&U=' + unique + '">');
  doc.write('<input type="hidden" name="C" value="' + this.id + '">');

  // func and parms are optional
  if (func != null){
  doc.write('<input type="hidden" name="F" value="' + func + '">');

    if (parms != null){
      if (typeof(parms) == "string"){
        // single parameter
        doc.write( '<input type="hidden" name="P0" '
                 + 'value="[' + jsrsEscapeQQ(parms) + ']">');
      } else {
        // assume parms is array of strings
        for( var i=0; i < parms.length; i++ ){
          doc.write( '<input type="hidden" name="P' + i + '" '
                   + 'value="[' + jsrsEscapeQQ(parms[i]) + ']">');
        }
      } // parm type
    } // parms
  } // func

  doc.write('</form></body></html>');
  doc.close();
  doc.forms['jsrsForm'].submit();

}

function contextGET( rsPage, func, parms ){

  // build URL to call
  var URL = rsPage;

  // always send context
  URL += "?C=" + this.id;

  // func and parms are optional
  if (func != null){
    URL += "&F=" + escape(func);

    if (parms != null){
      if (typeof(parms) == "string"){
        // single parameter
        URL += "&P0=[" + escape(parms+'') + "]";
      } else {
        // assume parms is array of strings
        for( var i=0; i < parms.length; i++ ){
          URL += "&P" + i + "=[" + escape(parms[i]+'') + "]";
        }
      } // parm type
    } // parms
  } // func

  // unique string to defeat cache
  var d = new Date();
  URL += "&U=" + d.getTime();
 
  // make the call
  switch( jsrsBrowser ) {
    case 'NS':
      this.container.src = URL;
      break;
    case 'IE':
      this.container.document.location.replace(URL);
      break;
    case 'MOZ':
      this.container.src = '';
      this.container.src = URL; 
      break;
    case 'OPR':
      this.container.src = '';
      this.container.src = URL; 
      break;
  }  
  
}

function contextGetPayload(){
  switch( jsrsBrowser ) {
    case 'NS':
      return this.container.document.forms['jsrs_Form'].elements['jsrs_Payload'].value;
    case 'IE':
      return this.container.document.forms['jsrs_Form']['jsrs_Payload'].value;
    case 'MOZ':
      return window.frames[this.container.name].document.forms['jsrs_Form']['jsrs_Payload'].value; 
    case 'OPR':
      var textElement = window.frames[this.container.name].document.getElementById("jsrs_Payload");
      return textElement.value;
  }  
}

function contextSetVisibility( vis ){
  switch( jsrsBrowser ) {
    case 'NS':
      this.container.visibility = (vis)? 'show' : 'hidden';
      break;
    case 'IE':
      document.all("SPAN" + this.id ).style.display = (vis)? '' : 'none';
      break;
    case 'MOZ':
      document.getElementById("SPAN" + this.id).style.visibility = (vis)? '' : 'hidden';
    case 'OPR':
      document.getElementById("SPAN" + this.id).style.visibility = (vis)? '' : 'hidden';
      this.container.width = (vis)? 250 : 0;
      this.container.height = (vis)? 100 : 0;
      break;
  }  
}

// end of context constructor

function jsrsGetContextID(){
  var contextObj;
  for (var i = 1; i <= jsrsContextPoolSize; i++){
    contextObj = jsrsContextPool[ 'jsrs' + i ];
    if ( !contextObj.busy ){
      contextObj.busy = true;      
      return contextObj.id;
    }
  }
  // if we got here, there are no existing free contexts
  if ( jsrsContextPoolSize <= jsrsContextMaxPool ){
    // create new context
    var contextID = "jsrs" + (jsrsContextPoolSize + 1);
    jsrsContextPool[ contextID ] = new jsrsContextObj( contextID );
    jsrsContextPoolSize++;
    return contextID;
  } else {
    alert( "jsrs Error:  context pool full" );
    return null;
  }
}

function jsrsExecute( rspage, callback, func, parms, visibility ){
  // call a server routine from client code
  //
  // rspage      - href to asp file
  // callback    - function to call on return 
  //               or null if no return needed
  //               (passes returned string to callback)
  // func        - sub or function name  to call
  // parm        - string parameter to function
  //               or array of string parameters if more than one
  // visibility  - optional boolean to make container visible for debugging

  // get context
  var contextObj = jsrsContextPool[ jsrsGetContextID() ];
  contextObj.callback = callback;

  var vis = (visibility == null)? false : visibility;
  contextObj.setVisibility( vis );

  if ( jsrsPOST && ((jsrsBrowser == 'IE') || (jsrsBrowser == 'MOZ'))){
    contextObj.POST( rspage, func, parms );
  } else {
    contextObj.GET( rspage, func, parms );
  }
  
  return contextObj.id;
}

function jsrsLoaded( contextID ){
  // get context object and invoke callback
  var contextObj = jsrsContextPool[ contextID ];
  if( contextObj.callback != null){
    contextObj.callback( jsrsUnescape( contextObj.getPayload() ), contextID );
  }
  // clean up and return context to pool
  contextObj.callback = null;
  contextObj.busy = false;
}

function jsrsError( contextID, str ){
  alert( unescape(str) );
  jsrsContextPool[ contextID ].busy = false
}

function jsrsEscapeQQ( thing ){
  return thing.replace(/'"'/g, '\\"');
}

function jsrsUnescape( str ){
  // payload has slashes escaped with whacks
  return str.replace( /\\\//g, "/" );
}

function jsrsBrowserSniff(){
if (document.layers) { return "NS"; }
if (document.all) {
		// But is it really IE?
		// convert all characters to lowercase to simplify testing
		var agt=navigator.userAgent.toLowerCase();
		var is_opera = (agt.indexOf("opera") != -1);
		if(is_opera) {
			return "OPR";
		} else {
			return "IE";
		}
  }
  if (document.getElementById) return "MOZ";
  return "OTHER";
}

function jsrsArrayFromString( s, delim ){
  // rebuild an array returned from server as string
  // optional delimiter defaults to ~
  var d = (delim == null)? '~' : delim;
  return s.split(d);
}

function jsrsDebugInfo(){
  // use for debugging by attaching to f1 (works with IE)
  // with onHelp = "return jsrsDebugInfo();" in the body tag
  var doc = window.open().document;
  doc.open;
  doc.write( 'Pool Size: ' + jsrsContextPoolSize + '<br><font face="arial" size="2"><b>' );
  for( var i in jsrsContextPool ){
    var contextObj = jsrsContextPool[i];
    doc.write( '<hr>' + contextObj.id + ' : ' + (contextObj.busy ? 'busy' : 'available') + '<br>');
    doc.write( contextObj.container.document.location.pathname + '<br>');
    doc.write( contextObj.container.document.location.search + '<br>');
    doc.write( '<table border="1"><tr><td>' + contextObj.container.document.body.innerHTML + '</td></tr></table>' );
  }
  doc.write('</table>');
  doc.close();
  return false;
}
//-->

