
var fw = null; 

function initialize() 
{
    document.write('<div id="placeholder">&nbsp;</div>');
   
}

function checkFlash()
{
/*
    var showFlash = false; 
    var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
    if (plugin) {
        whichPlugin = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1));

        if (whichPlugin >= 8){
            showFlash = true; 
         }     
    }
    
    if((showFlash && document.location.search.indexOf("flash=false")==-1) || document.location.search.indexOf("flash=true")!=-1) {
        
    }
    else
    { 
        var el = document.getElementById("get_flash"); 

        if(el) { 
          el.style.zIndex = 2000; 
        }
    }
    */
}

/* called in header of supporting xhtml files -- redirects to flash page w/ids in query string */
function DeepLink(overlayId,footerId,cultureCode)
{
    var qryStr = document.location.search; 
    
    if (document.location.search.indexOf("dl=false") == -1) {
        var qs = new String("?");
        if (qryStr != null) {
            if (qryStr.indexOf("?") != -1) qs = qryStr + "&";
        }
        qs += "overlay_id="+overlayId+"&footer_id="+footerId+"&UserCulture=" + cultureCode + "&referrer=" + escape(document.referrer);
        
	    document.location.href="default.aspx" + qs;
	}
}

/* returns sectionID from the query string to the swfObject */
function get_ids()
{	
	if(document.location.href.indexOf("?")!=-1) {
		var href	= document.location.href.split("?");
		var qstring	= href[1];
		var nameValue 	= qstring.split("=");
		var id 		= nameValue[1];	
		return id;
	}
}



var syncFlash = new Object();

syncFlash.windowMethods = function() {
    var popWin;
    return {
        getClientHeight : function() {
            var innerHeight = window.innerHeight ? window.innerHeight : 0;
		    var elemClientHeight = document.documentElement ? document.documentElement.clientHeight : 0;
		    var bodyClientHeight = document.body ? document.body.clientHeight : 0;
    		
		    var result = innerHeight ? innerHeight : 0;
    	 
	        if ( elemClientHeight && (!result || (result > elemClientHeight))) result = elemClientHeight;
    	        
	        var actualHeight =  bodyClientHeight && (!result || (result > bodyClientHeight)) ? bodyClientHeight : result;
	        return actualHeight;
        
        },
        getClientWidth : function() {
            var innerWidth = window.innerWidth ? window.innerWidth : 0;
		    var elemClientWidth = document.documentWidth ? document.documentElement.clientWidth : 0;
		    var bodyClientWidth = document.body ? document.body.clientWidth : 0;
    		
		    var result = innerWidth ? innerWidth : 0;
    	 
	        if ( elemClientWidth && (!result || (result > elemClientWidth))) result = elemClientWidth;
    	        
	        var actualWidth =  bodyClientWidth && (!result || (result > bodyClientWidth)) ? bodyClientWidth : result;
	        return actualWidth;
        
        },
        getScreenHeight : function () {
            return screen.height;
        },
        getScreenWidth : function () {
            return screen.width;
        },
        newWindowOpen : function(url,h,w,status,toolbar,scrollbar,resizeable,x,y) {
            var newWidth;
            var options = new String("");
            options += w ? "width=" + w:"";
            options += h ? ",height=" + h:"";
            options += status ? ",status=" + status:"";
            options += toolbar ? ",toolbar=" + toolbar + ",location=" + toolbar:"";
            options += scrollbar ? ",scrollbars=" + scrollbar:"";
            options += resizeable ? ",resizable=" + resizeable:"";
           
            if (popWin && !popWin.closed) {
                popWin.location.replace(url);
            }
            else {
                popWin = window.open(url,"",options);
                    
                if ((x != null) && (y != null)) {
                    popWin.moveTo(x,y);
                }
            }
            
            popWin.focus();
        },
        findPosX: function(obj) {
            var curleft = 0;
            if(obj.offsetParent)
            while(1) 
            {
                curleft += obj.offsetLeft;
                if(!obj.offsetParent)
                    break;
                obj = obj.offsetParent;
            }
            else if(obj.x)
            curleft += obj.x;
            return curleft;
        },
        findPosY: function(obj) {
            var curtop = 0;
            if(obj.offsetParent)
            while(1) 
            {
                curtop += obj.offsetTop;
                if(!obj.offsetParent)
                    break;
                obj = obj.offsetParent;
            }
            else if(obj.y)
            curtop += obj.y;
            return curtop;
        },
        windowReload : function() {
            var url = [];
		    var s = new String(document.location);
		
		    if (s.indexOf("#") != -1) {
			    url = s.split("#")
			}
		    else {
			    url[0] = document.location;
			}

            if (navigator.userAgent.indexOf("Safari") == -1) {
			    document.location.href = url[0];
			}
			else {
			    document.location.href = url[0];
			    setTimeout(function(){document.location.href = url[0]},1000);
			}
        },
        openNews : function() {
            var url = "/news.htm";
            var w = (this.getClientWidth());
            var h = (this.getScreenHeight())-125;
            
            /*
            if (w > 900) {  
                newWidth = (w - 900)/2;
                newWidth += 235; 
            }
            else {
                newWidth = 235;
            }*/
            newWidth = 10;
            this.newWindowOpen(url,h,"605",1,1,1,1,newWidth,10);
        },
        createToolTip : function(obj,xOffSet,yOffSet) {
            var x = this.findPosX(obj);
            var y = this.findPosY(obj);

            var elem = document.getElementById("tool_tip");
            if (elem == null) {
                elem = document.createElement("div");
                elem.id = "tool_tip";
                elem.innerHTML = "External Link";
                elem.className = "tool_tip";
                elem.style.top = (y + 18) + "px";
                
                if (xOffSet != null) {
                    elem.style.left = (x + xOffSet) + "px";
                }
                else {
                    elem.style.left = x + "px";
                }
                
                document.getElementById("outer_container").appendChild(elem);
            }
        },
        destroyToolTip : function() {
            var elem = document.getElementById("tool_tip");
            if (elem != null) {
                document.getElementById("outer_container").removeChild(elem);
            }
        }
        
    }
}(); //instantiate



syncFlash.flashWriter = function(width,height,id,container) {
    var el = document.getElementById("experience").style;
    el.display = "none";
    
    this.width = width;
    this.height = height;
    this.id = id;
    this.container = container;
    this.showFlash = false;

    this.objParams = new Array();
    this.embedParams = new Array();
    this.flash = new String('');
    this.codeBase = new String('http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0');
    this.plugInSpace = new String('http://www.macromedia.com/go/getflashplayer');
    
    this.checkForFlash = this.checkForFlash;
    this.addParameter = this.addParameter;
    this.getObjParameters = this.getObjParameters;
    this.getEmbedParameters = this.getEmbedParameters;
    this.setFlashContainerSize = this.setFlashContainerSize;
    this.writeFlash = this.writeFlash;
    
}

syncFlash.flashWriter.prototype = {
    addParameter: function(key,value,flag) {
    // if flag is 0, is an object param, 1 is an embed, 2 belongs in both.
        if (flag == 0) this.objParams[this.objParams.length] = key + "^" + value;       
        else if (flag==1) this.embedParams[this.embedParams.length] = key + "^" + value;
        else if (flag==2) {
            this.objParams[this.objParams.length] = key + "^" + value;
            this.embedParams[this.embedParams.length] = key + "^" + value;
        }
    },
    getObjParameters: function () {
        var arrTemp;
        var strTemp = "";
        for(i=0; i < this.objParams.length; i++) {
            arrTemp = this.objParams[i].split("^");
            strTemp += '<param name="' + arrTemp[0] + '" value="' + arrTemp[1] + '" />';
        }
        return strTemp;
    },
    getEmbedParameters: function () {
        var arrTemp;
        var strTemp = '<embed width="' + this.width + '" height="' + this.height + '" ';
        for(i=0; i < this.embedParams.length; i++) {
            arrTemp = this.embedParams[i].split("^");
            strTemp += arrTemp[0] + '="' + arrTemp[1] + '" ';
        }
        strTemp += ' pluginspace="' + this.plugInSpace + '" />'
        return strTemp;
    },
    checkForFlash: function () {
        var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
        if (plugin) {
            whichPlugin = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1));
    
            if (whichPlugin >= 8) this.showFlash = true;
            else this.showFlash = false;
            
        }
    },
    setFlashContainerSize: function () {
	    var actualHeight = syncFlash.windowMethods.getClientHeight();
	    if (actualHeight < 625) {
	        var el = document.getElementById(this.container);
	        el.className = "flash800-600";
	    }
	    else {
	        var el = document.getElementById(this.container);
	        el.className = "flashfullsize";
	    }
    },
    writeFlash: function() {
        this.checkForFlash();
        this.showFlash = (this.showFlash && document.location.search.indexOf("flash=false")==-1) || document.location.search.indexOf("flash=true")!=-1;
        if (this.showFlash) {
            this.setFlashContainerSize();
            this.flash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="' + this.codeBase + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '">';
            this.flash += this.getObjParameters();
            this.flash += this.getEmbedParameters();
            this.flash += '</object>'; 
            document.write(this.flash);
        }
        else {
            var el = document.getElementById("experience").style;
            el.display = "none";

            el = document.getElementById("get_flash").style; 
            el.display = "block"; 
            
            el = document.getElementById("placeholder"); 
            
            var mainCont = document.getElementById("main_cont"); 
            mainCont.removeChild(el); 
        }
    }
}


function buildFlashWriter(fvars) 
{
    fw = new syncFlash.flashWriter("852","600","sync","flash_container"); 
    
    fw.addParameter("src","/syncmedia/sync.swf",1);
    fw.addParameter("movie","/syncmedia/sync.swf",0);  
    fw.addParameter("bgcolor","#000000",2);

    fw.addParameter("allowScriptAccess","always",2);
    fw.addParameter("menu","false",2);
    fw.addParameter("scale","exactfit",2);
    fw.addParameter("quality","best",2);
    fw.addParameter("wmode","transparent",2);
    
    fw.addParameter("swLiveConnect","true",1);
    fw.addParameter("name","sync",1);
    fw.addParameter("type","application/x-shockwave-flash",1);

    fw.addParameter("FlashVars",fVars,2);
   
    fw.addParameter("swLiveConnect","true",1);
    fw.addParameter("name","sync",1);
    fw.addParameter("type","application/x-shockwave-flash",1);
    
}

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG(myImage) 
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}



var newsWin;
function openNewsletter(url) {
    var newWidth;
    var options = new String("");
    options += "width=" + 605;
    options += ",height=" + 500;
    options += ",status=1,toolbar=1,location=1,scrollbars=1,resizable=1";
   
    if (newsWin && !newsWin.closed) {
        newsWin.location.replace(url);
    }
    else {
        newsWin = window.open(url,"",options);
    }
    newsWin.focus();
}

function isValidEmail(val) { return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(val) }

/* Metrics Code */

var JS = {};
$extend(JS, {'Ford':{'Sync':{}}});

JS.Ford.Sync.Metrics = new Class({ 
    '_s' : {},
    '_onClickProps' : {},
    
    'initialize' : function(sAccount,options) {
        this._s = s_gi(sAccount); 
        this._s = $extend(this._s,(options || {}))
    },
    
    'sendOnClick' : function(obj,type,pageName) {
        var onClickType = 'o'; //default click type. 
        pageName = $chk(pageName) ? pageName : this._s.pageName; 
        
        if($chk(type)) { 
            onClickType = type; 
        }

        this._s.tl(obj,onClickType,pageName); 
    }
}); 

function genericSendMetricsOnClick(sProp,linkName,clickType) {   
   
    new JS.Ford.Sync.Metrics(s_account,{
        'prop5' : sProp,
        'linkTrackVars' : 'prop5'
    }).sendOnClick(this,clickType, linkName);
	
	return true;
    
}

function genericMetricsWithTitle(sProp) {
    var fnTitle = document.title;
    genericSendMetricsOnClick(sProp + ":" + fnTitle);
}

function genericSendProp6(sProp) {       
    new JS.Ford.Sync.Metrics(s_account,{
        'prop6' : sProp,
        'linkTrackVars' : 'prop6'
    }).sendOnClick(this,'o',sProp); 
}

function genericSendProp7(sProp) {   
    new JS.Ford.Sync.Metrics(s_account,{
        'prop7' : sProp,
        'linkTrackVars' : 'prop7'
    }).sendOnClick(this,'o',sProp); 
}