//add www in url
	function addWWWInUrl(baseUrl){
		window.location.href = baseUrl;
	}
	
	//analysis url
/*	function analysisAddress(){
	var str= window.location.href;
	var sliceStr = window.location.href.slice(7);
		if(str.indexOf("www")==-1 && str.indexOf("file:")==-1 && str.indexOf("localhost")==-1){
			url = "http://www." + sliceStr;
			addWWWInUrl(url);
		}
	}
	
	analysisAddress();*/

	//-----------settings-----------------------------------------start
	var siteName = "The Visionaire | LEED Certified Green Condos in Battery Park, NYC";
	var swfFileName = "content/main.swf"
	var flashvars = {};
	//flashvars.varName = "varValue";
	var swfWidth = 1000;
	var swfHeight = 550;
	var bgColor = "#6B763D";
	var flashVersion = "9";
	var googleAnalyticsAccountNumber = "";
	//-----------settings-----------------------------------------e-n-d

	var viewportwidth;
	var viewportheight;
	//-----------change title

	//window.onload = function() {
	//	document.title = siteName;
	//}

	//-----------swfobject

	var params = {};
	params.bgcolor = bgColor;
	params.menu = "true";
	//params.quality = "autohigh";
	params.scale = "noscale";
	params.wmode = "window";
	params.swliveconnect = "true";
	params.allowfullscreen = "true";
	params.allowscriptaccess = "always";
	params.allownetworking = "all";
	params.base = "content";
	var attributes = {};
	attributes.id = "FlashContent";
	attributes.name = "FlashContent";
	swfobject.embedSWF(swfFileName, "FlashContent", "100%", "100%",
			flashVersion, "content/javascript/expressInstall.swf", flashvars, params,
			attributes);

	//-----------swffit

	swffit.fit("FlashContent", swfWidth, swfHeight);

	swfmacmousewheel.registerObject(attributes.id);
	
	function getFlashPlayerRequirement() {
		return flashVersion;
	}

	var intervalID;
	function resizeFit() {
		resizeW = swfWidth;
		resizeH = swfHeight;
		intervalID = window.setInterval("resizing()", 1);
	}

	var resizeW = 100, resizeH = 80;
	function resizing() {
		if (inWidth < swfWidth) {
			resizeW += 20;

		}
		if (inHeight < swfHeight) {
			resizeH += 20;
		}
		if (inWidth < swfWidth || inHeight < swfHeight) {
			self.resizeTo(resizeW, resizeH);
		} else {
			self.resizeTo(resizeW + 60, resizeH + 100);
			self.moveTo((screen.availWidth - resizeW - 60) / 2,
					(screen.availHeight - resizeH - 100) / 2);
			clearInterval(intervalID);
			//alert("resize to Flash Size:" + inWidth + "x" + inHeight);
		}
		getViewportSize();
	}

	function resizeFull() {
		//alert("resizeFull");
		self.moveTo(0, 0);
		self.resizeTo(screen.availWidth, screen.availHeight);
	}

	function resizeWindow(w, h) {
		self.moveTo((screen.availWidth - w) / 2, (screen.availHeight - h) / 2);
		self.resizeTo(w, h);
	}

	//-----------2.get swf size
	function getSwfSize() {
		flashsize = [ swfWidth, swfHeight ]
		return flashsize;
	}
	//-----------3.get viewport size
	var inWidth = 0, inHeight = 0;
	getViewportSize();
	function getViewportSize() {
		if (typeof (window.innerWidth) == 'number') {
			//Non-IE
			inWidth = window.innerWidth;
			inHeight = window.innerHeight;
			outWidth = window.outerWidth;
			outHeight = window.outerHeight;
		} else if (document.documentElement
				&& (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			//IE 6+ in 'standards compliant mode'
			inWidth = document.documentElement.clientWidth;
			inHeight = document.documentElement.clientHeight;
			outWidth = window.outerWidth;
			outHeight = window.outerHeight;
		} else if (document.body
				&& (document.body.clientWidth || document.body.clientHeight)) {
			//IE 4 compatible
			inWidth = document.body.clientWidth;
			inHeight = document.body.clientHeight;
		}
		//alert("browser size" + inWidth + "x" + inHeight);

		viewportSize = [ inWidth, inHeight ];
		return viewportSize;
	}
	
	function getGaData(){
		
	 var gac = new gaCookies();
	 var gaData = "Source"  + " : " + gac.getCampaignSource() + "<br />";
		 gaData += "Medium"  + " : " +gac.getCampaignMedium() + "<br />";
		 gaData += "Visits"  + " : " + gac.getSessionCounter() + "<br />";
		 gaData += "Keyword"  + " : " + gac.getCampaignTerm() + "<br />";
		 return gaData;
	}
	

	
	
	
	/**
 *  @author:    Danny Ng (http://www.dannytalk.com/2010/08/19/read-google-an…-cookie-script/)
 *  @modified:  19/08/10
 *  @notes:     Free to use and distribute without altering this comment. Would appreciate a link back :)
 */
 
// Strip leading and trailing white-space
String.prototype.trim = function() { return this.replace(/^\s*|\s*$/g, ''); }
 
// Check if string is empty
String.prototype.empty = function() {
    if (this.length == 0)
        return true;
    else if (this.length > 0)
        return /^\s*$/.test(this);
}
 
// Breaks cookie into an object of keypair cookie values
function crumbleCookie(c)
{
    var cookie_array = document.cookie.split(';');
    var keyvaluepair = {};
    for (var cookie = 0; cookie < cookie_array.length; cookie++)
    {
        var key = cookie_array[cookie].substring(0, cookie_array[cookie].indexOf('=')).trim();
        var value = cookie_array[cookie].substring(cookie_array[cookie].indexOf('=')+1, cookie_array[cookie].length).trim();
        keyvaluepair[key] = value;
    }
 
    if (c)
        return keyvaluepair[c] ? keyvaluepair[c] : null;
 
    return keyvaluepair;
}
 
/**
 *  For GA cookie explanation, see http://services.google.com/analytics/breeze/en/ga_cookies/index.html.
 *
 *  @return             -   <void>
 *
 *  @pre-condition      -   pageTracker initialised properly
 *  @post-condition     -   provides 'get' methods to access specific values in the Google Analytics cookies
 */
function gaCookies()
{
    // Cookie syntax: domain-hash.unique-id.ftime.ltime.stime.session-counter
    var utma = function() {
        var utma_array;
 
        if (crumbleCookie('__utma'))
            utma_array =  crumbleCookie('__utma').split('.');
        else
            return null;
 
        var domainhash = utma_array[0];
        var uniqueid = utma_array[1];
        var ftime = utma_array[2];
        var ltime = utma_array[3];
        var stime = utma_array[4];
        var sessions = utma_array[5];
 
        return {
            'cookie': utma_array,
            'domainhash': domainhash,
            'uniqueid': uniqueid,
            'ftime': ftime,
            'ltime': ltime,
            'stime': stime,
            'sessions': sessions
        };
    };
 
    // Cookie syntax: domain-hash.gif-requests.10.stime
    var utmb = function() {
        var utmb_array;
 
        if (crumbleCookie('__utmb'))
            utmb_array = crumbleCookie('__utmb').split('.');
        else
            return null;
        var gifrequest = utmb_array[1];
 
        return {
            'cookie': utmb_array,
            'gifrequest': gifrequest
        };
    };
 
    // Cookie syntax: domain-hash.value
    var utmv = function() {
        var utmv_array;
 
        if (crumbleCookie('__utmv'))
            utmv_array = crumbleCookie('__utmv').split('.');
        else
            return null;
 
        var value = utmv_array[1];
 
        return {
            'cookie': utmv_array,
            'value': value
        };
    };
 
    // Cookie syntax: domain-hash.ftime.?.?.utmcsr=X|utmccn=X|utmcmd=X|utmctr=X
    var utmz = function() {
        var utmz_array, source, medium, name, term, content, gclid;
 
        if (crumbleCookie('__utmz'))
            utmz_array = crumbleCookie('__utmz').split('.');
        else
            return null;
 
        var utms = utmz_array[4].split('|');
        for (var i = 0; i < utms.length; i++) {
            var key = utms[i].substring(0, utms[i].indexOf('='));
            var val = decodeURIComponent(utms[i].substring(utms[i].indexOf('=')+1, utms[i].length));
            val = val.replace(/^\(|\)$/g, '');  // strip () brackets
            switch(key)
            {
                case 'utmcsr':
                    source = val;
                    break;
                case 'utmcmd':
                    medium = val;
                    break;
                case 'utmccn':
                    name = val;
                    break;
                case 'utmctr':
                    term = val;
                    break;
                case 'utmcct':
                    content = val;
                    break;
                case 'utmgclid':
                    gclid = val;
                    break;
            }
        }
 
        return {
            'cookie': utmz_array,
            'source': source,
            'medium': medium,
            'name': name,
            'term': term,
            'content': content,
            'gclid': gclid
        };
    };
 
    // Establish public methods
 
    // utma cookies
    this.getDomainHash = function() { return (utma() && utma().domainhash) ? utma().domainhash : null };
    this.getUniqueId = function() { return (utma() && utma().uniqueid) ? utma().uniqueid : null };
 
    this.getInitialVisitTime = function() { return (utma() && utma().ftime) ? utma().ftime : null };
    this.getPreviousVisitTime = function() { return (utma() && utma().ltime) ? utma().ltime : null };
    this.getCurrentVisitTime = function() { return (utma() && utma().stime) ? utma().stime : null };
    this.getSessionCounter = function() { return (utma() && utma().sessions) ? utma().sessions : null };
 
    // utmb cookies
    this.getGifRequests = function() { return (utmb() && utmb().gifrequest) ? utmb().gifrequest : null }; 
 
    // utmv cookies
    this.getUserDefinedValue = function () { return (utmv() && utmv().value) ? decodeURIComponent(utmv().value) : null };
 
    // utmz cookies
    this.getCampaignSource = function () { return (utmz() && utmz().source) ? utmz().source : null };
    this.getCampaignMedium = function () { return (utmz() && utmz().medium) ? utmz().medium : null };
    this.getCampaignName = function () { return (utmz() && utmz().name) ? utmz().name : null };
    this.getCampaignTerm = function () { return (utmz() && utmz().term) ? utmz().term : null};
    this.getCampaignContent = function () { return (utmz() && utmz().content) ? utmz().content : null };
    this.getGclid = function () { return (utmz() && utmz().gclid) ? utmz().gclid : null };
}
