/*	SWFObject v2.2 <http://code.google.com/p/swfobject/> 
	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();﻿/*
                 Initialize and render the MenuBar when its elements are ready 
                 to be scripted.
            */

            YAHOO.util.Event.onContentReady("tfs_main_menu", function () {

                var ua = YAHOO.env.ua,
                    oAnim;  


                /*
                     "beforeshow" event handler for each submenu of the MenuBar
                     instance, used to setup certain style properties before
                     the menu is animated.
                */

                function onSubmenuBeforeShow(p_sType, p_sArgs) {

                    var oBody,
                        oElement,
                        oShadow,
                        oUL;
                

                    if (this.parent) {

                        oElement = this.element;

                        /*
                             Get a reference to the Menu's shadow element and 
                             set its "height" property to "0px" to syncronize 
                             it with the height of the Menu instance.
                        */

                        oShadow = oElement.lastChild;
                        oShadow.style.height = "0px";

                        
                        /*
                            Stop the Animation instance if it is currently 
                            animating a Menu.
                        */ 
                    
                        if (oAnim && oAnim.isAnimated()) {
                        
                            oAnim.stop();
                            oAnim = null;
                        
                        }


                        /*
                            Set the body element's "overflow" property to 
                            "hidden" to clip the display of its negatively 
                            positioned <ul> element.
                        */ 

                        oBody = this.body;


                        

                        if (this.parent && 
                            !(this.parent instanceof YAHOO.widget.MenuBarItem)) {
                        

                            /*
                                There is a bug in gecko-based browsers and Opera where 
                                an element whose "position" property is set to 
                                "absolute" and "overflow" property is set to 
                                "hidden" will not render at the correct width when
                                its offsetParent's "position" property is also 
                                set to "absolute."  It is possible to work around 
                                this bug by specifying a value for the width 
                                property in addition to overflow.
                            */

                            if (ua.gecko || ua.opera) {
                            
                                oBody.style.width = oBody.clientWidth + "px";
                            
                            }
                            
                            
                            /*
                                Set a width on the submenu to prevent its 
                                width from growing when the animation 
                                is complete.
                            */
                            
                            if (ua.ie == 7) {

                                oElement.style.width = oElement.clientWidth + "px";

                            }
                        
                        }

    
                        oBody.style.overflow = "hidden";


                        /*
                            Set the <ul> element's "marginTop" property 
                            to a negative value so that the Menu's height
                            collapses.
                        */ 

                        oUL = oBody.getElementsByTagName("ul")[0];

                        oUL.style.marginTop = ("-" + oUL.offsetHeight + "px");
                    
                    }

                }


                /*
                    "tween" event handler for the Anim instance, used to 
                    syncronize the size and position of the Menu instance's 
                    shadow and iframe shim (if it exists) with its 
                    changing height.
                */

                function onTween(p_sType, p_aArgs, p_oShadow) {

                    if (this.cfg.getProperty("iframe")) {
                    
                        this.syncIframe();
                
                    }
                
                    if (p_oShadow) {
                
                        p_oShadow.style.height = this.element.offsetHeight + "px";
                    
                    }
                
                }


                /*
                    "complete" event handler for the Anim instance, used to 
                    remove style properties that were animated so that the 
                    Menu instance can be displayed at its final height.
                */

                function onAnimationComplete(p_sType, p_aArgs, p_oShadow) {

                    var oBody = this.body,
                        oUL = oBody.getElementsByTagName("ul")[0];

                    if (p_oShadow) {
                    
                        p_oShadow.style.height = this.element.offsetHeight + "px";
                    
                    }


                    oUL.style.marginTop = "";
                    oBody.style.overflow = "";
                    

                    

                    if (this.parent && 
                        !(this.parent instanceof YAHOO.widget.MenuBarItem)) {


                        

                        if (ua.gecko || ua.opera) {
                        
                            oBody.style.width = "";
                        
                        }
                        
                        if (ua.ie == 7) {

                            this.element.style.width = "";

                        }
                    
                    }
                    
                }


                /*
                     "show" event handler for each submenu of the MenuBar 
                     instance - used to kick off the animation of the 
                     <ul> element.
                */

                function onSubmenuShow(p_sType, p_sArgs) {

                    var oElement,
                        oShadow,
                        oUL;
                
                    if (this.parent) {

                        oElement = this.element;
                        oShadow = oElement.lastChild;
                        oUL = this.body.getElementsByTagName("ul")[0];
                    

                        /*
                             Animate the <ul> element's "marginTop" style 
                             property to a value of 0.
                        */

                        oAnim = new YAHOO.util.Anim(oUL, 
                            { marginTop: { to: 0 } },
                            .5, YAHOO.util.Easing.easeOut);


                        oAnim.onStart.subscribe(function () {
        
                            oShadow.style.height = "100%";
                        
                        });
    

                        oAnim.animate();

    
                        /*
                            Subscribe to the Anim instance's "tween" event for 
                            IE to syncronize the size and position of a 
                            submenu's shadow and iframe shim (if it exists)  
                            with its changing height.
                        */
    
                        if (YAHOO.env.ua.ie) {
                            
                            oShadow.style.height = oElement.offsetHeight + "px";


                            /*
                                Subscribe to the Anim instance's "tween"
                                event, passing a reference Menu's shadow 
                                element and making the scope of the event 
                                listener the Menu instance.
                            */

                            oAnim.onTween.subscribe(onTween, oShadow, this);
    
                        }
    

                        /*
                            Subscribe to the Anim instance's "complete" event,
                            passing a reference Menu's shadow element and making 
                            the scope of the event listener the Menu instance.
                        */
    
                        oAnim.onComplete.subscribe(onAnimationComplete, oShadow, this);
                    
                    }
                
                }


                /*
                     Instantiate a MenuBar:  The first argument passed to the 
                     constructor is the id of the element in the page 
                     representing the MenuBar; the second is an object literal 
                     of configuration properties.
                */

                var oMenuBar = new YAHOO.widget.MenuBar("tfs_main_menu", { 
                                                            autosubmenudisplay: true, 
                                                            hidedelay: 750,
                                                            shadow: false, 
                                                            lazyload: true });


                /*
                     Subscribe to the "beforeShow" and "show" events for 
                     each submenu of the MenuBar instance.
                */
                
                oMenuBar.subscribe("beforeShow", onSubmenuBeforeShow);
                oMenuBar.subscribe("show", onSubmenuShow);


                /*
                     Call the "render" method with no arguments since the 
                     markup for this MenuBar already exists in the page.
                */

                oMenuBar.render();          
            
            });
            
function roll(ele) {
	var img = ele.getElementsByTagName("img")[0];
	var src = img.src;
	img.src = (/_on/.test(src)) ? src.replace('_on', '_off') : src.replace('_off', '_on');
}

function SelectAll(id)
{
    id.focus();
    id.select();
}
function urlencode(str) {
return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}

function openExternal(url,title){

var safeURLs =['.ford.com','.ford.com','.lincoln.com','.mercuryvehicles.com'];
var x;
var found;
found=false;
var u;
u=urlencode(u);

for (x in safeURLs)
{
 
    if ((url.indexOf(safeURLs[x])!=-1) || (u.indexOf(safeURLs[x])!=-1)) found=true;
}

    if (found)
    document.location=url;
    else
    document.location="/external-site/?url="+urlencode(url)+"&return="+urlencode(location.href)+"&title="+urlencode(title);
   
}

function showDisclaimer(obj){
	pos=YAHOO.util.Dom.getXY(obj);
	document.getElementById('disclaimerPopup').style.display='block';
	document.getElementById('disclaimerPopup').style.top=pos[1]-document.getElementById('disclaimerPopup').offsetHeight+21+'px';
	return false;
}
function hideDisclaimer(){
	document.getElementById('disclaimerPopup').style.display='none';
}





var timeout	= 30;
var closetimer	= 0;
var ddmenuitem	= 0;


function mopen(id)
{	

	mcancelclosetime();


	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';


	ddmenuitem = document.getElementById(id);
	
	ddmenuitem.style.visibility = 'visible';

}

function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}


function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}


function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}


document.onclick = mclose; 




        

   
   


﻿
divCounter=0;

function emailFriend(){
	window.open('http://secure.ford.com/thefordstory/tellafriend/index.asp', 'n', 'width=500, height=560, scrollbars=no');
}

function sharethisLink(title,summary,url,imageURL,hover,text,offsetLeft,pagepos){
if(typeof(SHARETHIS) !== 'undefined' && SHARETHIS != null) {
	hoverCode="";
	if (hover){
	
	}
	if (imageURL!="none"){
		if (imageURL=="") imageURL="/wp-content/themes/fordstory/images/icons/share_icon.gif";
		img='<img src="'+imageURL+'"/> ';
	}else{
		img='';
	}
	
	var object = SHARETHIS.addEntry({
		title:title,
		summary: summary,
		url: url},
		{button:false,
		offsetLeft: offsetLeft}
		);
	
	document.write('<span id="share'+divCounter+'"><a href="javascript:tfsEventIgnorePage(this,\'share this\',\'share story: '+ pagepos +' \',\'share this\',\'share this toolbar\');" '+hoverCode+'>'+img+text+'</a></span>');
	
	var element = document.getElementById('share'+divCounter);
	object.attachButton(element);
	divCounter++;
	}
}

function sharethisLinkhdr(title,summary,url,offsetLeft,c){
if(typeof(SHARETHIS) !== 'undefined' && SHARETHIS != null) {
	
	
	var object = SHARETHIS.addEntry({
		title:title,
		summary: summary,
		url: url},
		{button:false,
		offsetLeft: offsetLeft}
		);
	
	
	var element = document.getElementById('hdrshare');
	object.attachButton(element);
	}
}

function getUpdates(){
	window.open('http://www.ford.com/thefordstory/updates', 'n', 'width=538, height=700, scrollbars=1');
	
}





    YAHOO.namespace("media.container");

    function media_view_init() {
      

        if (!YAHOO.media.container.view) {

           
            YAHOO.media.container.view = 
                    new YAHOO.widget.Panel("view",  
                                                    { width: "706px", 
                                                      fixedcenter: true, 
                                                      close: false, 
													  underlay:"none",
                                                      draggable: false, 
                                                      zindex:4,
                                                      modal: true,
                                                      visible: false
                                                    } 
                                                );
    
            
           
			YAHOO.media.container.view.cfg.setProperty("underlay","matte"); 
            YAHOO.media.container.view.setBody('<div><div id="tfsmedia"><div id="content-container"></div></div><div id="mediaclose"><a onclick="hidevideo();"><div class="btn_sprite b_mediaclose"></div></a></div></div>');
            YAHOO.media.container.view.render(document.body);

        }

        


       
    
       
       
    }
    
    function media_flickrview_init() {
      

        if (!YAHOO.media.container.flickrview) {

           
            YAHOO.media.container.flickrview = 
                    new YAHOO.widget.Panel("flickrview",  
                                                    { width: "530px",
                                                      height: "550px", 
                                                      fixedcenter: true, 
                                                      close: false, 
													  underlay:"none",
                                                      draggable: false, 
                                                      zindex:4,
                                                      modal: true,
                                                      visible: false
                                                    } 
                                                );
    
            
           
            YAHOO.media.container.flickrview.setBody('<table cellpadding="0" cellspacing="0"><tr><td><div id="content-container-flickr"></div></td><td valign="top" style="padding-left:5px;"><a onclick="hideflickr();"><div class="btn_sprite b_mediaclose"></div></a></td></tr><tr><td class="flickr_ov_title" id="flickr_ov_title"></td></tr><tr><td class="flickr_ov_sub" id="flickr_ov_sub"></td></tr><tr><td class="flickr_ov_sub" style="font-size:10px;padding-right:15px;">By clicking on the image you will leave Ford Social. The website you will be visiting is not associated with Ford Motor Company, and Ford Motor Company is not responsible for content found on this page.</td></tr></table>');
            YAHOO.media.container.flickrview.render(document.body);

        }
        }
    
function removeElement(parentDiv, childDiv){
     if (childDiv == parentDiv) {
         
     }
     else if (document.getElementById(childDiv)) {     
          var child = document.getElementById(childDiv);
          var parent = document.getElementById(parentDiv);
          parent.removeChild(child);
     }
     else {
        
          return false;
     }
}
function showvideo(videoid)
{
 
 media_view_init();
 removeElement("tfsmedia","moreplayercontent");
  removeElement("tfsmedia","youtubeoverlaydisclamer");
 document.getElementById("content-container").innerHTML="";
 
 var d = document.createElement("div");
 d.setAttribute("id", "socialvideo");
 document.getElementById("content-container").appendChild(d);
 var disc=document.createElement("div");
 disc.setAttribute("id", "youtubeoverlaydisclamer");
 disc.innerHTML='By clicking on the video you will leave Ford Social. The website you will be visiting is not associated with Ford Motor Company, and Ford Motor Company is not responsible for content found on this page.';
 document.getElementById("tfsmedia").appendChild(disc);
 params = { allowScriptAccess: "always", wmode:"transparent"};
 atts = { id: "socialvideo"};
 swfobject.embedSWF("http://cdn.visiblemeasures.com/youtube/embedded/player.swf?youtube="+videoid+"%26hl%3Den%26fs%3D1%26rel%3D0%26showinfo%3D0%26autoplay%3D1&vmcKey=f3ae1da6a7a811debadb0019b9f1584b&resizeable=true", "socialvideo",  "640","385", "8", "expressInstall.swf", null, params, atts);
 YAHOO.media.container.view.show();
}


function showvideomore(videoid,more)
{
 media_view_init();
  removeElement("tfsmedia","moreplayercontent");
 removeElement("tfsmedia","youtubeoverlaydisclamer");
 document.getElementById("content-container").innerHTML="";
 
 var d = document.createElement("div");
 d.setAttribute("id", "socialvideo");
 document.getElementById("content-container").appendChild(d);
 var m= document.getElementById(more);
 var d2 = document.createElement("div");
 d2.setAttribute("id", "moreplayercontent");
 d2.innerHTML=m.innerHTML;
 document.getElementById("tfsmedia").appendChild(d2);
 var disc=document.createElement("div");
 disc.setAttribute("id", "youtubeoverlaydisclamer");
 disc.innerHTML='By clicking on the video you will leave Ford Social. The website you will be visiting is not associated with Ford Motor Company, and Ford Motor Company is not responsible for content found on this page.';
 document.getElementById("tfsmedia").appendChild(disc);
 params = { allowScriptAccess: "always", wmode:"transparent"};
 atts = { id: "socialvideo"};
 swfobject.embedSWF("http://cdn.visiblemeasures.com/youtube/embedded/player.swf?youtube="+videoid+"%26hl%3Den%26fs%3D1%26rel%3D0%26showinfo%3D0%26autoplay%3D1&vmcKey=f3ae1da6a7a811debadb0019b9f1584b&resizeable=true", "socialvideo",  "640","385", "8", "expressInstall.swf", null, params, atts);
 YAHOO.media.container.view.show();
}

function hidevideo()
{
 removeElement("tfsmedia","moreplayercontent");
 removeElement("content-container","flickrpicture");
swfobject.removeSWF("socialvideo");
YAHOO.media.container.view.hide();
}

function hideflickr()
{

 removeElement("content-container-flickr","flickrpicture");

YAHOO.media.container.flickrview.hide();
}

function showflickr(link,title,imagepath,subtext)
{
 if (subtext=='undefined'||subtext==null)subtext="";
 if (imagepath.substr(imagepath.length-6,1)=="_")
 {
    imagepath=imagepath.substr(0,imagepath.length-6)+imagepath.substr(imagepath.length-4,6);
 }
 
 media_flickrview_init();
 var d = document.createElement("div");
 d.setAttribute("id", "flickrpicture");
 d.innerHTML='<a href="'+link+'" target="_blank"><img src="'+imagepath+'" alt="'+title+'" /></a>';
 document.getElementById("content-container-flickr").appendChild(d);
 document.getElementById("flickr_ov_title").innerHTML=title;
 document.getElementById("flickr_ov_sub").innerHTML=subtext;
 
 
 YAHOO.media.container.flickrview.show();

}

function showslideshow(user,photoset)
{
media_view_init();
 
 var d = document.createElement("div");
 d.setAttribute("id", "socialvideo");
 document.getElementById("content-container").appendChild(d);
var flashvars = {
			offsite:"true",
			lang:"en-us",
			page_show_url:"%2Fphotos%2F"+user+"%2Fsets%2F"+photoset+"%2Fshow%2F",
			page_show_back_url:"%2Fphotos%2F"+user+"%2Fsets%2F"+photoset+"%2F",
			set_id:photoset,
			jump_to:""
		};
 params = { allowScriptAccess: "always", wmode:"opaque"};
 atts = { id: "socialvideo"};
 swfobject.embedSWF("http://www.flickr.com/apps/slideshow/show.swf?v=71649", "socialvideo",  "640","385", "8", "expressInstall.swf", flashvars, params, atts);
 YAHOO.media.container.view.show();
}

function Set_Cookie( name, value, expires, path, domain, secure )
{

var today = new Date();
today.setTime( today.getTime() );

if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


function Get_Cookie( check_name ) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; 

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		
		a_temp_cookie = a_all_cookies[i].split( '=' );


		
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
		
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
	
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}
				


function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}



function logout()
{
 //document.getElementById('outmenu').style.display="none";
 //document.getElementById('inmenu').style.display="block";
 //Delete_Cookie( 'uuid', '/' );

 document.location="/members/logout/?return="+document.location;
}


 function alert_init(w,h) {
      if ((w==null) || (w=='')) w="300px";
      if ((h==null) || (h=='')) w="200px";

        if (!YAHOO.media.container.alertwindow) {

           
            YAHOO.media.container.alertwindow = 
                    new YAHOO.widget.Panel("alertwindow",  
                                                    { width: "370px",
                                                      height: h, 
                                                      fixedcenter: true, 
                                                      close: false, 
													  underlay:"none",
                                                      draggable: false, 
                                                      zindex:10,
                                                      modal: true,
                                                      visible: false
                                                    } 
                                                );
    
            
           
            YAHOO.media.container.alertwindow.setBody('<table cellpadding="0" cellspacing="0"><tr><td><div id="content-container-alert"></div></td><td valign="top" style="padding-left:5px;"><a onclick="YAHOO.media.container.alertwindow.hide();"><div class="btn_sprite b_mediaclose"></div></a></td></tr></table>');
            YAHOO.media.container.alertwindow.render(document.body);

        }
        }
        
function tfs_alert(msg,w,h)
{
    alert_init(w,h);
    document.getElementById('content-container-alert').innerHTML=msg;
    YAHOO.media.container.alertwindow.show(); 
}        ﻿heroWidgetTimerPosition=-112;
heroWidgetTimers="";
newsWidetItems="";
heroWidgetItemId=0;
heroWidgetTimeout="";

var onitem=-1;

var go=true;
var attributes_close = {
	height: { to: 96 }
};
var attributes_open = {
	height: { to: 162 }
};

var attributes_close_overlay = {
	top: { to: 2 }
};
var attributes_open_overlay = {
	top: { to: -63 }
};


function heroWidgetTimer(){

	if (heroWidgetTimerPosition==-208){
			if (heroWidgetItemId==2)
				toggle(0);
			else
				toggle(heroWidgetItemId+1);
		}
		heroWidgetTimerPosition=heroWidgetTimerPosition-12;
		for (i=0;i<heroWidgetTimers.length;i++){
			heroWidgetTimers[i].style.backgroundPosition=heroWidgetTimerPosition+"px -29px";
		}
	heroWidgetTimeout=setTimeout("this.heroWidgetTimer()",1000);
}

function heroWidgetResetTimers(){
	heroWidgetTimerPosition=-112;
	for (i=0;i<heroWidgetTimers.length;i++){
	heroWidgetTimers[i].style.backgroundPosition=heroWidgetTimerPosition+"px -29px";
	}
}


function toggle(item){
if ((item!=heroWidgetItemId) && (go)){
onitem=item;

var anim = new YAHOO.util.Anim('hero_item_left_over_'+heroWidgetItemId, attributes_close_overlay, .3, YAHOO.util.Easing.easeIn);

anim.onComplete.subscribe(function () { 
	document.getElementById('hero_item_left_'+heroWidgetItemId).style.display = "none";
	document.getElementById('hero_item_left_'+onitem).style.display = "block";
	document.getElementById('hero_info_'+heroWidgetItemId).style.display = "none";
	document.getElementById('hero_info_'+onitem).style.display = "block";
	document.getElementById('hero_item_'+onitem).style.backgroundPosition="0 0";
	document.getElementById('hero_item_'+onitem).style.color="#FFFFFF";
	document.getElementById('hero_item_'+heroWidgetItemId).style.backgroundPosition="-382px 0";
	document.getElementById('hero_item_'+heroWidgetItemId).style.color="#666666";
	heroWidgetResetTimers();
	heroWidgetItemId=item;
		 var anim2 = new YAHOO.util.Anim('hero_item_left_over_'+onitem, attributes_open_overlay, .3, YAHOO.util.Easing.easeIn); 
	anim2.animate();
	go=true;
    
	});   
	go=false;
	anim.animate();
	
	
	
	}
};
function heroWidgetTimerInit(){
	YAHOO.util.Event.on('hero_item_0', 'mouseover', function() {toggle(0);});

	YAHOO.util.Event.on('hero_item_1', 'mouseover', function() {toggle(1);});

	YAHOO.util.Event.on('hero_item_2', 'mouseover', function() {toggle(2);});

	heroWidgetTimers=YAHOO.util.Dom.getElementsByClassName("i_sprite i_timer","div");

	heroWidgetTimer();
}

function toggle_view(id){
var ele = document.getElementById(id);
	
	if(ele.style.display == "block") {
    		ele.style.display = "none";
		
  	}
	else {
		ele.style.display = "block";
		
	}
}
function toggle_viewmore(){
		
 toggle_view("hiddenpostslist");
 toggle_view("viewmore");
			
	}﻿function CookieHandler() {
 
	this.setCookie = function (name, value, seconds) {
 
		if (typeof(seconds) != 'undefined') {
			var date = new Date();
			date.setTime(date.getTime() + (seconds*1000));
			var expires = "; expires=" + date.toGMTString();
		}
		else {
			var expires = "";
		}
 
		document.cookie = name+"="+value+expires+"; path=/";
	}
 
	this.getCookie = function (name) {
 
		name = name + "=";
		var carray = document.cookie.split(';');
 
		for(var i=0;i < carray.length;i++) {
			var c = carray[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
		}
 
		return null;
	}
 
	this.deleteCookie = function (name) {
		this.setCookie(name, "", -1);
	}
 
}

/* empty */

function GisValidEmail(str) {
 var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;   
   return emailPattern.test(str);  
		
	}

	function GisNotBlank(v,id,valid) {
		
		if (v.value=="") {
			document.getElementById(id).style.color="#da121a";
				return false;
				
			} else {
				document.getElementById(id).style.color="#383838";
				return valid;
			}	
	}

	function GisChecked(v,id,valid) {
		if (!v.checked) {
			document.getElementById(id).style.color="#da121a";
				return false;				
				
			} else {
				document.getElementById(id).style.color="#383838";
				return valid;
			}	
	}


function PostData()
{ 
   
    var valid=true;
		
		 var f=	document.frmEntry;
		 
		 
		 
		 valid=GisNotBlank(f.firstName,"firstNametxt",valid); 
		 valid=GisNotBlank(f.lastName,"lastNametxt",valid); 
		 valid=GisNotBlank(f.email,"emailtxt",valid); 
		 valid=GisNotBlank(f.notifyemail,"notifyemailtxt",valid); 
		 valid=GisNotBlank(f.zipcode,"zipcodetxt",valid); 
		 
		 if (f.notifyemail.value!=f.email.value) {
				valid=false;
				document.getElementById("notifyemailtxt").style.color="#da121a";
				document.getElementById("emailtxt").style.color="#da121a";
			} else 
			{
			document.getElementById("notifyemailtxt").style.color="#fff";
			document.getElementById("emailtxt").style.color="#fff";
			}
		
		if (!GisValidEmail(f.email.value)) {
				valid=false;
				document.getElementById("emailtxt").style.color="#da121a";
			} else document.getElementById("emailtxt").style.color="#fff";
		f.returnurl.value=document.location;
		f.title.value=document.title;
		if (valid)document.frmEntry.submit();	 
}


var keynoteInterceptLikelihood = 0.25;
	var keynoteInterceptTaskKey = 'Ford_Story_Visitor_Profile_Survey_08042010';
	var keynoteInterceptType = 'Layer';
	function HandleKeynoteIntercept()
	{ 
		try {
			if (Math.random() >= (keynoteInterceptLikelihood*5)) return;
			var s = document.createElement('script');
			s.src = 'http://webeffective.keynote.com/applications/intercept/filter_page.asp?inv=' + keynoteInterceptTaskKey + '&type=' + keynoteInterceptType + '&rate=' + keynoteInterceptLikelihood + '&max=5';
			document.body.insertBefore(s, document.body.firstChild);
			window.keynoteConnectorWindow = 'primary';
		}
		catch(e){}
	}
	if (window.attachEvent) window.attachEvent('onload',HandleKeynoteIntercept);
		else window.addEventListener('load',HandleKeynoteIntercept,false);
var totalNewsItemsPerSet = 3;
var currentNewsItemHighlighted = 0;
var currentNewsPage = 1;
var totalNewsPages = 3;
var startNewsIndex = 0;
var newsWidgetImagePath = "/wp-content/plugins/newsWidget/images/";
var newsRollOverAllowed = false;

var nextSetRange = totalNewsItemsPerSet*currentNewsPage;

var animationNwVectors = new Array();
animationNwVectors[0] = {elemForward:-356,elemBack:0,startTweetIndex:0};
animationNwVectors[1] = {elemForward:-712,elemBack:-356,startTweetIndex:3};
animationNwVectors[2] = {elemForward:-1068,elemBack:-712,startTweetIndex:6};

function newsOver(newsItemIndex){
	if(newsItemIndex != currentNewsItemHighlighted && newsRollOverAllowed == true){
		closeNewsItem(currentNewsItemHighlighted);
		openNewsItem(newsItemIndex);
		currentNewsItemHighlighted = newsItemIndex;
	}
}

var _nwAnimIn;
function slideNewsForward(){
	if(currentNewsPage < totalNewsPages){
		var _inAttributes = { 
		   left: { to: animationNwVectors[currentNewsPage-1].elemForward } 
		};
		_nwAnimIn = new YAHOO.util.Anim('newsWidgetTable', _inAttributes, .5, YAHOO.util.Easing.easeIn);
		_nwAnimIn.onComplete.subscribe(onNewsSlideIn);
		slideNewsIn();
		newsOver(animationNwVectors[currentNewsPage-1].startTweetIndex);
		newsRollOverAllowed = false;
		
		currentNewsItemHighlighted = animationNwVectors[currentNewsPage].startTweetIndex;
		
		i = document.getElementById('newsSet' + currentNewsPage);
		i.style.backgroundPosition="-103px -52px";
		
		currentNewsPage++;
		i = document.getElementById('newsSet' + currentNewsPage);
		i.style.backgroundPosition="-96px -52px";
	}
}

function onNewsSlideIn(){
	newsRollOverAllowed = true;
}


function slideNewsBack(){
	if(currentNewsPage > 1){
		newsOver(animationNwVectors[currentNewsPage-1].startTweetIndex);
		newsRollOverAllowed = false;
		i = document.getElementById('newsSet' + currentNewsPage);
		i.style.backgroundPosition="-103px -52px";
		currentNewsPage--;
		var _inAttributes = { 
		   left: { to: animationNwVectors[currentNewsPage-1].elemBack } 
		};
		_nwAnimIn = new YAHOO.util.Anim('newsWidgetTable', _inAttributes, .5, YAHOO.util.Easing.easeIn);
		_nwAnimIn.onComplete.subscribe(onNewsSlideIn);
		slideNewsIn();
		
		currentNewsItemHighlighted = animationNwVectors[currentNewsPage-1].startTweetIndex;
		
		
		i = document.getElementById('newsSet' + currentNewsPage);
		i.style.backgroundPosition="-96px -52px";
	}
}
  

function slideNewsIn(){
  _nwAnimIn.animate();
}

function newsWidgetInit() {
	
	setTopNewsItem();
}

function openNewsItem(tweetId){
	var newsStyle = document.getElementById("newsWidg" + tweetId).style;
	newsStyle.backgroundColor = "#e9f3fa";
	newsStyle.height = "73px";
}

function closeNewsItem(newsWidgId){
	var newsStyle = document.getElementById("newsWidg" + newsWidgId).style;
	newsStyle.backgroundColor = "#D3E7F6";
	newsStyle.height = "20px";
}

function setTopNewsItem(){
	openNewsItem(0);
	openNewsItem(3);
	openNewsItem(6);
	newsRollOverAllowed = true;
}


function launchNewsPage(newsUrl){
	var newWindow = window.open(newsUrl, '_blank');
	newWindow.focus();
}

YAHOO.util.Event.on('newsWidgetForward', 'click', slideNewsForward);
YAHOO.util.Event.on('newsWidgetBack', 'click', slideNewsBack);
YAHOO.util.Event.onDOMReady(newsWidgetInit);
var totalTweetsPerSet = 4;
var currentTweetHighlighted = 0;
var currentPage = 1;
var totalPages = 3;
var startIndex = 0;
var twitterImagePath = "/wp-content/plugins/newsWidget/images/";
var rollOverAllowed = false;

var nextSetRange = totalTweetsPerSet*currentPage;

var animationVectors = new Array();
animationVectors[0] = {elemForward:-356,elemBack:0,startTweetIndex:0};
animationVectors[1] = {elemForward:-712,elemBack:-356,startTweetIndex:4};
animationVectors[2] = {elemForward:-1068,elemBack:-712,startTweetIndex:8};

function tweetOver(tweetIndex){
	if(currentTweetHighlighted != tweetIndex && rollOverAllowed == true){
		closeTweet(currentTweetHighlighted);
		openTweet(tweetIndex);
		currentTweetHighlighted = tweetIndex;
	}
}

var _animIn;
function slideTweetsForward(){

	if(currentPage < totalPages){
		var _inAttributes = { 
		   left: { to: animationVectors[currentPage-1].elemForward } 
		};
		tweetOver(animationVectors[currentPage-1].startTweetIndex);
		rollOverAllowed = false;
		currentTweetHighlighted = animationVectors[currentPage].startTweetIndex;
		
		i = document.getElementById('set' + currentPage);
		i.style.backgroundPosition="-103px -52px";
		
		currentPage++;
		i = document.getElementById('set' + currentPage);
		i.style.backgroundPosition="-96px -52px";
		
		_animIn = new YAHOO.util.Anim('twitterTable', _inAttributes, .5, YAHOO.util.Easing.easeIn);
		_animIn.onComplete.subscribe(onSlideIn);
		slideIn();
	}
}

function onSlideIn(){
	rollOverAllowed = true;
}

function slideTweetsBack(){
 
	if(currentPage > 1){
		tweetOver(animationVectors[currentPage-1].startTweetIndex);
		rollOverAllowed = false;
		i = document.getElementById('set' + currentPage);
		i.style.backgroundPosition="-103px -52px";
		currentPage--;
		var _inAttributes = { 
		   left: { to: animationVectors[currentPage-1].elemBack } 
		};
		_animIn = new YAHOO.util.Anim('twitterTable', _inAttributes, .5, YAHOO.util.Easing.easeIn);
		_animIn.onComplete.subscribe(onSlideIn);
		slideIn();
		
		currentTweetHighlighted = animationVectors[currentPage-1].startTweetIndex;
		
		i = document.getElementById('set' + currentPage);
		i.style.backgroundPosition="-96px -52px";
	}
}


function slideIn(){
  _animIn.animate();
}



function openTweet(tweetId){
	var tweetStyle = document.getElementById("tweet" + tweetId).style;
	tweetStyle.backgroundColor = "#e9f3fa";
	tweetStyle.height = "73px";
}

function closeTweet(tweetId){
	var tweetStyle = document.getElementById("tweet" + tweetId).style;
	tweetStyle.backgroundColor = "#D3E7F6";
	tweetStyle.height = "20px";
}

function setTopTweet(){
	openTweet(0);
	openTweet(4);
	openTweet(8);
	rollOverAllowed = true;
}

function twitterWidgetInit() {

	
	setTopTweet();
} 


var totalAnswers;
var totalAnswerImages = 0;
var pollCompleted = false;
var pollId;
var tablePadding = 1;
var tableSpacing = 4;
var tableBorder = 0;
var answerId;

var blue = "#7fbe1d";
var green = "#ec602b";

function loadPoll(data){
	var pollXml = data.responseXML.documentElement;
	var pollWrapper = "<form name='pollWidgetForm' id='pollWidgetForm' onSubmit='return sendPollResponse()' style='display:inline'>";
	pollQuestion = pollXml.getElementsByTagName('pollQuestion')[0].firstChild.nodeValue;
	pollAnswers = pollXml.getElementsByTagName('pollAnswer');
	pollWrapper += "<div id='pollQuestion'>" + pollQuestion + "</div>";
	for(i=0;i<pollAnswers.length;i++){
		
		pollWrapper += "<div class='pollAnswer'><table cellpadding='0' cellspacing'0'><tr><td valign='top'><input type='radio' onclick='selectOption(this)' name='pollWidgetAnswer' id='a" + i + "' /></td><td><div id='pollAnswerText'>" + pollAnswers[i].firstChild.nodeValue + "</div></td></tr></table></div>";
	}
	totalAnswers = i;
	pollWrapper += "<div id='pollButton'><table cellpadding='0' cellspacing'0'><tr><td><span id='voteButton'><input type='image' name='voteButton' src='" + pollWidgetPath + "images/vote.png' alt='Vote' title='Vote' onmouseover='javascript:this.src=\"" + pollWidgetPath + "images/vote-over.png\";' onmouseout='javascript:this.src=\"" + pollWidgetPath + "images/vote.png\";' /></span></td><td><span><div class='btn_sprite b_viewResults' onclick='return viewPublicResults()' ></div></span></td></tr></table></div></form>";
	
	pollWidgetDiv = new YAHOO.widget.Module("pollMarkup");
	pollWidgetDiv.setBody(pollWrapper);
	pollWidgetDiv.render();
}

function showPollResultsPublic(data){
	var pollXml = data.responseXML.documentElement;
	pollQuestion = pollXml.getElementsByTagName('pollQuestion')[0].firstChild.nodeValue;
	pollAnswers = pollXml.getElementsByTagName('pollAnswer');
	var graphIncrement = 300 / 100;
	var pollWrapper = "<div id='pollWidgetResults'>";
	pollWrapper += "<div id='resultsMarkup' class='resultMarkupCSS'><table  cellpadding='0' cellspacing='0' width='352'>";
	pollWrapper += "<tr><td id='resultQuestion' colspan='2'>" + pollQuestion + "</td></tr>";
	for(i=0;i<pollAnswers.length;i++){
		var textColor = "#ffffff";
		var graphWidth = (pollAnswers[i].getAttribute("percent") == "0") ? 1 : pollAnswers[i].getAttribute("percent");
		
		pollWrapper += "<tr><td colspan='2'><table width='316' cellpadding='0' cellspacing='0'><tr><td class='resultAnswer' valign='bottom'>" + pollAnswers[i].firstChild.nodeValue + "</td><td class='smallFont' valign='bottom' align='right'>" + pollAnswers[i].getAttribute("totalResponse") + " votes</td></tr></table></td></tr>";
		pollWrapper += "<tr><td><div class='graphBg'><div class='pollGraph' style='width:" + (graphWidth*graphIncrement) + "px;background-color:" + ((answerId == i && pollCompleted == true) ? green : blue) + ";color:" + textColor + "' class='none'></div></div></td>";
		pollWrapper += "<td class='percentFont' align='left' valign='top'>" + pollAnswers[i].getAttribute("percent") + "%</td></tr>";
	}
	backToPoll = (pollCompleted == false) ? "<div class='btn_sprite b_backToPoll' onclick='return getPollXml()'></div>" : "";
	totalAnswers = i;
	pollWrapper += "<tr><td colspan='2'><table width='316' cellpadding='0' cellspacing='0' ><tr><td class='totalFont'>Total votes: " + pollXml.getAttribute("totalResponse") + "</td><td align='right' width='100px' >" + backToPoll + "</td><td align='right' width='100'><div class='btn_sprite b_viewArchive' onclick='document.location=\"/poll-archive/\";'></div></td></tr></table></td></tr></table>";
	
	pollWrapper += "</div></div>";
	
	pollWidgetDiv = new YAHOO.widget.Module("pollMarkup");
	pollWidgetDiv.setBody(pollWrapper);
	pollWidgetDiv.render();
}

function viewPublicResults(){
	var postData = "pid=" + pollId + "&x=pollResults";
	var callback = {success:showPollResultsPublic,failure:function(){}};
	var transaction = YAHOO.util.Connect.asyncRequest('POST', pollWidgetPath + "php/Polling/polls.php", callback, postData);
	return false;
}

function selectOption(radioObj){
	answerId = radioObj.id.substring(1,radioObj.id.length);
}

function sendPollResponse(){
	if(answerId != null){
		var postData = "pid=" + pollId + "&x=logResponse&answerId=" + answerId;
		var callback = {success:showPollResultsPublic,failure:function(){}};
		var transaction = YAHOO.util.Connect.asyncRequest('POST', pollWidgetPath + "php/Polling/polls.php", callback, postData);
		pollCompleted = true;
	}
	else{
		alert("An answer is required to respond to the poll");
	}
	return false;
}

function getPollXml(){ 
	var postData = "pid=" + pollId + "&x=getWidget";
	var callback = {success:loadPoll,failure:function(){}};
	var transaction = YAHOO.util.Connect.asyncRequest('POST', pollWidgetPath + "php/Polling/polls.php", callback, postData);
	return false;
}

function checkPollCompleted(){
	var rand = Math.random();
	var postData = "pid=" + pollId + "&x=checkCompleted&r=" + rand;
	var callback = {success:returnPollCompleted,failure:function(){}};
	var transaction = YAHOO.util.Connect.asyncRequest('POST', pollWidgetPath + "php/Polling/polls.php", callback, postData);
}

function returnPollCompleted(data){
	if(data.responseText == "-1"){
		getPollXml();
	}
	else{
		pollCompleted = true;
		answerId = data.responseText;
		viewPublicResults();
	}
}

YAHOO.util.Event.onDOMReady(checkPollCompleted);
