var VIDEO_URL_ROOT = "rtmp://flash.edgecastcdn.net/00036D";  //--- EdgeCast Flash streaming server
//var HTTP_URL_ROOT = "http://ne.edgecastcdn.net/00036D";  //--- EdgeCast web server
var HTTP_URL_ROOT = "/text";  //--- ML web server
var PLAYER = HTTP_URL_ROOT + '/sharedassets/includes/swf/player.swf';

function ThisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

function SendEvent(typ, prm) {
	ThisMovie('ply').sendEvent(typ, prm);
}

function NewPage(url) {
	SendEvent('pause');
	window.location = url;
}

function LoadVideo(obj, videofile, imagefile, width, height, flversion, onbkcolor, offbkcolor, stretching, videoselector, arrVideoselectors, autostart) {
	var swf = new SWFObject(PLAYER,'ply',width,height,flversion,offbkcolor);

	swf.addParam('allowfullscreen','true');
	swf.addParam('allowscriptaccess','always');
	swf.addParam('wmode','opaque');

	swf.addParam('flashvars','file=' + VIDEO_URL_ROOT + videofile + '&image=' + HTTP_URL_ROOT + imagefile +'&controlbar=over&fullscreen=false&stretching=' + stretching + '&skin=' + HTTP_URL_ROOT + '/sharedassets/includes/swf/simple.swf&autostart=' + autostart);

	swf.write(obj);

	// --- reset library selector background colors
	for (var i=0; i<arrVideoselectors.length; i++) {
		$(arrVideoselectors[i]).style.backgroundColor = offbkcolor;
		// --- contrast copy in selected item against background
		$(arrVideoselectors[i]).style.color = onbkcolor;
	}

	// --- set selected item back color to hightlighted
	videoselector.style.backgroundColor = onbkcolor;
	// --- contrast copy in selected item against background
	videoselector.style.color = offbkcolor;
}

function LoadCategoryHeaderVideo(obj, videofile, imagefile, width, height, flversion, offbkcolor, stretching, autostart) {
	var swf = new SWFObject(PLAYER,'ply',width,height,flversion,offbkcolor);

	swf.addParam('allowfullscreen','true');
	swf.addParam('allowscriptaccess','always');
	swf.addParam('wmode','opaque');

	swf.addParam('flashvars','file=' + VIDEO_URL_ROOT + videofile + '&image=' + HTTP_URL_ROOT + imagefile + '&controlbar=over&fullscreen=false&stretching=' + stretching + '&skin=' + HTTP_URL_ROOT + '/sharedassets/includes/swf/simple.swf&autostart=' + autostart);

	swf.write(obj);
}


function LoadLinkedVideo(obj, videofile, imagefile, logofile, link, width, height, flversion, bkcolor, stretching, autostart, skin) {
	var swf = new SWFObject(PLAYER,'ply',width,height,flversion,bkcolor);
	var flashvars;

	swf.addParam('allowfullscreen','true');
	swf.addParam('allowscriptaccess','always');
	swf.addParam('wmode','opaque');
	
	flashvars = 'file=' + videofile;
	flashvars = flashvars + '&abouttext=Shop';
	flashvars = flashvars + '&aboutlink=/';
	flashvars = flashvars + '&controlbar=over';
	flashvars = flashvars + '&fullscreen=false';
	flashvars = flashvars + '&screencolor=' + bkcolor;
	flashvars = flashvars + '&volume=100';
	flashvars = flashvars + '&icons=false';
	 

	if (imagefile != '') {flashvars = flashvars + '&image=' + HTTP_URL_ROOT + imagefile;}
	if (logofile != '') {flashvars = flashvars + '&logo=' + logofile;}
	if (link != '') {flashvars = flashvars + '&linktarget=_self&displayclick=link&link=' + link;}
	if (autostart != '') {flashvars = flashvars + '&autostart=' + autostart;}

	if (stretching != '') {
		flashvars = flashvars + '&stretching=' + stretching;
	} else {
		flashvars = flashvars + '&stretching=fill';
	}

	if (skin != '') {
		flashvars = flashvars + '&skin=' + HTTP_URL_ROOT + '/sharedassets/includes/swf/' + skin + '.swf';
	} else {
		flashvars = flashvars + '&skin=' + HTTP_URL_ROOT + '/sharedassets/includes/swf/simple.swf';
	}

	swf.addParam('flashvars', flashvars);
	swf.write(obj);
}


function LoadLinkedVideoPlaylist(obj, playlistfile, imagefile, logofile, link, width, height, flversion, bkcolor, stretching, autostart, skin) {
	var swf = new SWFObject(PLAYER,'ply',width,height,flversion,bkcolor);
	var flashvars;

	//--- set some basic swf parameters
	swf.addParam('allowfullscreen','true');
	swf.addParam('allowscriptaccess','always');
	swf.addParam('wmode','opaque');

	//--- build the movie variables
	flashvars = 'file=' + playlistfile;
	flashvars = flashvars + '&abouttext=Shop';
	flashvars = flashvars + '&aboutlink=/';
	flashvars = flashvars + '&controlbar=over';
	flashvars = flashvars + '&fullscreen=false';
	flashvars = flashvars + '&screencolor=' + bkcolor;
	flashvars = flashvars + '&volume=100';
	flashvars = flashvars + '&icons=false';

	flashvars = flashvars + '&repeat=list'; // so the player advances to the next track
	flashvars = flashvars + '&shuffle=false'; // so the playlist doesn't get shuffled
	flashvars = flashvars + '&linkfromdisplay=true';
	flashvars = flashvars + '&rotatetime=99'; // so the player deosn't rotate to the next item on the playlist too soon.
	flashvars = flashvars + '&enablejs=true'; 

	//--- if pre-load still image spec'd, use it
	if (imagefile != '') {flashvars = flashvars + '&image=' + HTTP_URL_ROOT + imagefile;}

	//--- if logo image spec'd, use it
	if (logofile != '') {flashvars = flashvars + '&logo=' + logofile;}

	//--- if destination link spec'd, use it
	if (link != '') {flashvars = flashvars + '&linktarget=_self&displayclick=link&link=' + link;}

	//--- if auto play spec'd, use it
	if (autostart != '') {flashvars = flashvars + '&autostart=' + autostart;}

	if (stretching != '') {
		//--- if video stretching mode spec'd, use it
		flashvars = flashvars + '&stretching=' + stretching;
	} else {
		///-- else use fill mode
		flashvars = flashvars + '&stretching=fill';
	}

	if (skin != '') {
		//--- if player skin spec'd, use it
		flashvars = flashvars + '&skin=' + HTTP_URL_ROOT + '/sharedassets/includes/swf/' + skin + '.swf';
	} else {
		///-- else use default skin
		flashvars = flashvars + '&skin=' + HTTP_URL_ROOT + '/sharedassets/includes/swf/simple.swf';
	}


	//--- add the movie variables to the parameters list of the swf
	swf.addParam('flashvars', flashvars);

	//--- write the swf to the spec'd page element
	swf.write(obj);
}


function SetupSocialNetworkLinks() {
	addthis_pub = divisionDomain;  //-- use lowercase division to ID account name
	if (divisionID == "EB") addthis_pub = "elderbeerman";  //-- for Elder-Beerman, hardcode ID without dash for AddThis.com account

	addthis_brand = divisionName;
	addthis_logo = "http://www.bonton.com/images/en_US/global/globalnav/" + divisionDomain + "_logo01.gif";

//		var obj = document.getElementById('emailanchor');
	var obj = $('emailanchor');

	obj.setAttribute("href", "mailto:?subject=Victor%20by%20Victor%20Alfaro%20at%20" + divisionName + "&body=Introducing%20Victor%20by%20Victor%20Alfaro%20at%20" + divisionName + ":%20%20http://www." + divisionDomain + ".com/category/id/102391.do");

}

