window.onerror=function(){ return true; };

try{ var addMe=(document.location.href.indexOf('.go.com')==-1)?'tsdev-studio.online.disney.com':'bventertainment.go.com'; }
catch(add){var addMe='tsdev-studio.online.disney.com';}
var _proto='http://';
try{ if (window.location.protocol == "https:"){ _proto='https://'; } } catch(lockpee){}
var root=_proto+addMe+'/tv/buenavista/ebertandroeper';

try{ _gpn=/([\w-~]*)(\.htm|$|\?|\#|\.cgi)/i.exec(location.href)[1]; } catch(pn){ _gpn='index'; } if (_gpn==""){_gpn="index";}
try{ _submlc=new RegExp("ebertandroeper(2|)(.*|)/"+_gpn,"i").exec(location.href)[2]; } catch(m){ _submlc=''; }
var _gmlc="/TVPlex/EbertAndRoeper"+_submlc;
var _gacct="DM510312C3MA38EN3;DM51030813MR38EN3;DM5103083LCA38EN3";


document.writeln('<scr'+'ipt language="javascript" src="'+_proto+'global.go.com/secure/studio/chrome.js"><\/scr'+'ipt>');
document.writeln('<scr'+'ipt language="javascript" src="'+_proto+'global.go.com/detect/scripts/master_flash_light.js"><\/scr'+'ipt>');

styles=[
[".subheader","background:#2b0301; font-family:arial; font-size:14px; color:#e4c498; font-weight:bold;"],
[".stateheader","color:#fcebd2; font-family:arial; font-size:16px; font-weight:bold;"],
[".even","background:#650a00;"],
[".odd","background:#3f0600;"],
[".text","font-family: verdana, helvetica; font-size:14px; font-weight:bold; color:#e4c498;"],
[".listing","font-family: verdana, helvetica; font-size:12px; font-weight:bold; color:#ffffff; padding:5px 0 5px 0;"],
[".padleft","padding-left:5px;"],
[".padright","padding-right:5px;"],
["a, a:link","color:#c88100;"],
[".footer","font-family: verdana, helvetica; font-size:9px; color:#9a6c41;"],
["input.field","font-family: verdana, helvetica; font-size:12px; color:#000000; width:140px;"]
];

document.writeln('<style>');  for (sty in styles){ document.writeln(styles[sty][0]+'{ '+styles[sty][1]+' }'); }  document.writeln('</style>');

function params(wut,qp,dflt){ dflt=(dflt==null)?'':dflt; try{r=unescape(wut.replace(new RegExp("&amp;","gi"),"&").match(new RegExp(qp+"=+([^&;]*)"))[1]);}catch(qp){r=dflt;} return r; }
function addZero(vNumber){ return ((vNumber<10)?"0":"")+vNumber; }
function gid(_id){ return document.getElementById(_id); }
function inner(_gid,_text){ gid(_gid).innerHTML=_text; }

function centerIt(popW,popH,urlToCenter,centeredWinName){
leftPos=(screen.availWidth-popW)/2; topPos=(screen.availHeight-popH)/2;
return window.open(urlToCenter,centeredWinName,"width="+popW+",height="+popH+",left="+leftPos+",top="+topPos+",statusbar=0,scrollbars=0")
}

function writePositioned(_code,_left,_top,_width,_height,_id){
document.writeln('<div style="position:relative; height:1px; overflow:visible;">\
<div style="position:absolute; left:'+_left+'px; top:'+_top+'px; width:'+_width+'px; height:'+_height+'px; overflow:hidden;" '+((_id==null)?'':'id="'+_id+'"')+'>'+_code+'</div></div>');
}

// link disclaimer
function popDisclaimer(url){
	win = window.open('disclaimer.html?'+ url, 'disclaimer', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=270');
	win.focus();
}
// end link disclaimer

//$flash({ movie:'topflash.swf', w:'100%', h:'163' }).render();
function $flash(ef){ //{ movie:'', w:'', h:'', bgcolor:'', base:'', vars:'' }
ef.w=(ef.w==null)?'590':ef.w; ef.h=(ef.h==null)?'450':ef.h;
sendback={}
flashstr='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+_proto+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ef.w+'" height="'+ef.h+'"><param name="movie" value="'+ef.movie+'"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent"><param name="scale" value="noscale"><param name="allowScriptAccess" value="always">';
if (ef.base!=null){flashstr+='<param name="base" value="'+ef.base+'">'; }
if (ef.bgcolor!=null){flashstr+='<param name="bgcolor" value="'+ef.bgcolor+'">'; }
if (ef.vars!=null){flashstr+='<param name="flashvars" value="'+ef.vars+'">'; }
flashstr+='<embed src="'+ef.movie+((ef.vars!=null)?'?'+ef.vars:'')+'" menu="false" quality="high" pluginspage="'+_proto+'www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ef.w+'" height="'+ef.h+'" swLiveConnect="true" wmode="transparent" scale="noscale" allowScriptAccess="always"';
if (ef.base!=null){flashstr+=' base="'+ef.base+'"'; }
if (ef.bgcolor!=null){flashstr+=' bgcolor="'+ef.bgcolor+'"'; }
if (ef.vars!=null){flashstr+=' FlashVars="'+ef.vars+'"'; }
flashstr+='></embed></object>';
sendback.toString=function(){ return flashstr; }
sendback.render=function(){ document.writeln(flashstr); }
sendback.inner=function(targetgid){ gid(targetgid).innerHTML=flashstr; }
return sendback;
}

var today=new Date(); var _xml=''; var _timeflip=false;
function getToday(){
if (params(location.search,'time','')!=''){
today=new Date(params(location.search,'time')); document.cookie='time='+today+'; path=/;';
document.writeln('<div style="position:absolute; top:0px; left:0px; width:250px; height:16px; font:bold 11px arial; color:white; background:#072B5E; border:1px solid white; overflow:hidden; z-index:100;">&nbsp; time: '+today.toString()+'</div>');
} else if (params(document.cookie,'time','')!=''){ today=new Date(params(document.cookie,'time'));
document.writeln('<div style="position:absolute; top:0px; left:0px; width:250px; height:16px; font:bold 11px arial; color:white; background:#072B5E; border:1px solid white; overflow:hidden; z-index:100;">&nbsp; time: '+today.toString()+'</div>');
} else { document.writeln('<scr'+'ipt language="javas'+'cript" src="http://dolutils.go.com/dolutils/tv/funct'+'ions?vars=today"></scr'+'ipt>'); }
}

function writeHeader(hdr){
hvars='';
if (hdr!=null){
if (hdr.p!=null && hdr.p!=''){ hvars+="p="+hdr.p+"&"; }
if (hdr.t!=null && hdr.t!=''){ hvars+="t="+hdr.t+"&"; }
if (hdr.current_page!=null && hdr.current_page!=''){ hvars+="current_page="+hdr.current_page+"&"; }
if (hdr.s!=null){
hvars+="s="+hdr.s.replace(/<b>/gi,'').replace(/<\/b>/gi,'')+"&";
bstart=hdr.s.indexOf('<b>');
if (bstart!=-1){ bstop=hdr.s.replace(/<b>/gi,'').indexOf('</b>'); if (bstop!=-1){ hvars+="b="+bstart+"&e="+bstop; }}
}}
new $flash({ movie:root+'/topflash.swf', w:'100%', h:'163', base:root+"/", vars:hvars }).render();
}

function doTimeShift(){ //USAGE= doTimeShift(["July 4, 2005","alert('whatever')"], ["July 5, 2005","alert(today)"], ["July 6, 2005","alert('6th')"]);
offset=(today.toString().match(/(DT|Daylight|700)/gi)!=null)?7:8;
for (tim=doTimeShift.arguments.length-1; tim>=0; tim--){
thistime=new Date(doTimeShift.arguments[tim][0]+" GMT-0"+offset+"00");
if (today>=thistime){ eval(doTimeShift.arguments[tim][1]); _timeflip=true; break; }
}}

function flipCSS(){
styles=[ ["#SHOWER, #OLDER","display:none;"],["#STEALTH, #NEWER","display:block;"] ];
document.writeln('<style>');  for (sty in styles){ document.writeln(styles[sty][0]+'{ '+styles[sty][1]+' }'); }  document.writeln('</style>');
}

function setShowHide(dt,id,act){ //setShowHide("February 11, 2006 0:01","RERUNS","hide")
notyet='none'; nowisok='block'; try{ if (act.match(/(0|hid|none)/gi)!=null){ notyet='block'; nowisok='none'; }}catch(ssh){}
document.writeln('<style>#'+id+'{ display:'+((today<new Date(dt))?notyet:nowisok)+' }</style>');
}

function setScrollColor(_facecolor,_id){
faceup=''; facedown=''; _facecolor=_facecolor.replace(/\#/g,'');
R=parseInt(_facecolor.substring(0,2),16); G=parseInt(_facecolor.substring(2,4),16); B=parseInt(_facecolor.substring(4,6),16);
if(R<240){R+=16;} else if(R<255){R=255;} R=R.toString(16); R=(R.length==1)?R='0'+R:R;
if(G<240){G+=16;} else if(G<255){G=255;} G=G.toString(16); G=(G.length==1)?G='0'+G:G;
if(B<240){B+=16;} else if(B<255){B=255;} B=B.toString(16); B=(B.length==1)?B='0'+B:B;
faceup=''+R+G+B;
R=parseInt(_facecolor.substring(0,2),16); G=parseInt(_facecolor.substring(2,4),16); B=parseInt(_facecolor.substring(4,6),16);
if(R>15){R-=16;} else if(R>0){R=0;} R=R.toString(16); R=(R.length==1)?R='0'+R:R;
if(G>15){G-=16;} else if(G>0){G=0;} G=G.toString(16); G=(G.length==1)?G='0'+G:G;
if(B>15){B-=16;} else if(B>0){B=0;} B=B.toString(16); B=(B.length==1)?B='0'+B:B;
facedown=''+R+G+B;
document.writeln('<style>'+((_id==null)?'body':_id)+'{ scrollbar-shadow-color:#000000; scrollbar-track-color:#666666; scrollbar-3dlight-color:#666666; scrollbar-arrow-color:#ffffff; scrollbar-base-color:#000000; scrollbar-highlight-color:#'+faceup+'; scrollbar-darkshadow-color:#'+facedown+'; scrollbar-face-color:#'+_facecolor+'; }</style>');
}

function DoFlashDetection(){
CreateInterface(); DetectFlash("8",root+"/noflash.html");
}

var copyright = '&copy; Disney * ABC Domestic Television. All rights reserved.'

function writePrivacy(elcolor,txtcolor){
elcolor=(elcolor==null)?'#c88100':elcolor;
document.writeln('<span style="font:11px verdana; color:'+((txtcolor==null)?'#fff':txtcolor)+'">');
writeNBFooterSmall(null,null,elcolor);
}

function writeCopyright(elcolor,txtcolor){
elcolor=(elcolor==null)?'#c88100':elcolor;
document.writeln('<span style="font:11px verdana; color:'+((txtcolor==null)?'#fff':txtcolor)+'">');
document.writeln('<div align="center">'+ copyright +'</div>');
}

alwaysHideAds=false;
function writeBannerAd(){
if (window.location.protocol=="file:" || alwaysHideAds){
document.writeln('<img src="'+root+'/images/spacer.gif" width="728" height="90" border="0" alt=""><br>');
} else {
document.writeln('<a href="'+root+'/index.html"><img src="'+root+'/ads/728x90_rk-redesign.gif" width="728" height="90" border="0" alt="Check it out!  We redesigned our website! The new liveregisandkelly.com is here!"></a><br>');
}
}

function writeSkyscraperAd(){
if (window.location.protocol=="file:" || alwaysHideAds){
document.writeln('<img src="'+root+'/images/spacer.gif" width="160" height="600" border="0" alt=""><br>');
} else {

skyscraperads=[
'<a href="'+root+'/show_idea.html"><img src="'+root+'/ads/160x600_great-idea-for-show.gif" width="160" height="600" border="0" alt="Have a great idea for the show? Click here to tell us about it."></a>',
'<a href="'+root+'/hostchat.html"><img src="'+root+'/ads/160x600_great-live-moments.gif" width="160" height="600" border="0" alt="Great Live Moments - Relive them today! Host Chat Central!"></a>'
];

try{ adindy=(location.href.match(/(get_tickets|local_listings|recipes)/gi)!=null)?0:1; }catch(ai){ adindy=0; }
document.writeln(skyscraperads[adindy]+'<br><br><br>');

}
}

function writeSquareAd(){
if (window.location.protocol=="file:" || alwaysHideAds){
document.writeln('<img src="'+root+'/images/spacer.gif" width="300" height="250" border="0" alt=""><br>');
} else {

squareads=[
'<a href="'+root+'/show_idea.html"><img src="'+root+'/ads/300x250_great-idea-for-show.gif" width="300" height="250" border="0" alt="Have a great idea for the show? Click here to tell us about it."></a>',
'<a href="'+root+'/hostchat.html"><img src="'+root+'/ads/300x250_great-live-moments.gif" width="300" height="250" border="0" alt="Great Live Moments - Relive them today! Host Chat Central!"></a>',
'<a href="http://disneyparks.disney.go.com/" target="_blank"><img src="'+root+'/ads/300x250-disneyparks-family.gif" width="300" height="250" border="0" alt="Discover your dream. DisneyParks.com"></a>',
'<a href="http://disneyparks.disney.go.com/" target="_blank"><img src="'+root+'/ads/300x250-disneyparks-woody.gif" width="300" height="250" border="0" alt="Discover your dream. DisneyParks.com"></a>',
'<a href="javascript:recipes();"><img src="'+root+'/ads/300x250_recipe-archive.gif" width="300" height="250" border="0" alt="Recipe Archive - Click here to see what\'s cookin\'"></a>'
];

try{
if (location.href.match(/(regis\.|room=regis|kelly_trivia)/gi)!=null){ adindy=3; }
else if (location.href.match(/(kelly\.|room=kelly|regis_trivia|regis_music)/gi)!=null){ adindy=2; }
else { adindy=4; }
}catch(ai){ adindy=4; }
document.writeln(squareads[adindy]);

}
}

states=["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming" ];
daysOfWeek=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
monthsOfYear=["January","February","March","April","May","June","July","August","September","October","November","December"];


function boxIt(_id,_shade,_wide){

_shade=(_shade==null)?'dark':_shade;  _bgcolor=(_shade=='dark')?((_wide)?'#EDEDED':'#f0f1f1'):'#f9f9f9'; _width=(_wide)?'712':'445';

output='<table width="100%" border="0" cellspacing="0" cellpadding="0">\
<tr><td colspan="3"><img src="'+root+'/images/'+_shade+'-box'+((_wide)?'-wide':'')+'_top.gif" alt="" border="0"></td></tr>\
<tr><td style="background:url('+root+'/images/'+_shade+'-box'+((_wide)?'-wide':'')+'_left.gif) repeat-y; width:10px;"><spacer/></td><td bgcolor="'+_bgcolor+'" width="'+_width+'">';
output+=gid(_id).innerHTML;
output+='</td><td style="background:url('+root+'/images/'+_shade+'-box'+((_wide)?'-wide':'')+'_right.gif) repeat-y; width:10px;"><spacer/></td></tr>\
<tr><td colspan="3"><img src="'+root+'/images/'+_shade+'-box'+((_wide)?'-wide':'')+'_bottom.gif" alt=""></td></tr></table>';
inner(_id,output);

}


function rollins(e){ /*---ROLLOVER FUNCTIONS---*/
if (window.event) { thislink = window.event.srcElement; } else if (e.target) { thislink = e.target; } else { return; }
for (j=0;j<myArraySet.length;j++){ if (myArraySet[j][0]==thislink.id+'_over'){document.getElementById(thislink.id).src=myArraySet[j][1].src; break;}}}
function unrollins(e){
if (window.event) { thislink = window.event.srcElement; } else if (e.target) { thislink = e.target; } else { return; }
for (k=0;k<myArraySet.length;k++){ if (myArraySet[k][0]==thislink.id){ document.getElementById(thislink.id).src=myArraySet[k][1].src; break;}}}
function rolloverInit(){
myArraySet=new Array(); myImages=new Array(); count=-1;
for (i=0;i<document.links.length;i++){
elk=document.links[i];
if (elk.id!=""){
bob=document.getElementById('i'+elk.id); unName=bob.src; count++;
c3=bob.src.replace(/_off\./gi,'_ovr.').replace(/_on\./gi,'_ovr.').replace(/-off\./gi,'-on.');
thisImage=new Image(); thisImage.src=c3; myArraySet[count]=new Array(bob.id+'_over',thisImage);
elk.onmouseover=rollins; count++; thisImage=new Image(); thisImage.src=unName; myArraySet[count]=new Array(bob.id,thisImage);elk.onmouseout=unrollins;
bob.src=c3; bob.src=unName; //FLIP REAL QUICK TO PRELOAD
}}}


/* FROM INDEX.HTML */
function $brightcove(br){
	br.w=(br.w!=null)?br.w:300;
	br.h=(br.h!=null)?br.h:361;
	br.ads=(br.ads!=null)?br.ads:true;
	br.banner=(br.banner!=null)?br.banner:true;
	br.autoStart=(br.autoStart!=null)?br.autoStart:false;
	if (br.ads==true){
	flashVars="adURLBase=http://bventertainment.go.com/brightcove/&pwidth="+br.w+"&pheight="+br.h+"&autoStart="+br.autoStart+"&wmode=transparent&playerId="+br.playerId+"&videoId="+br.videoId+"&banner="+br.banner;
	new $flash({ movie:"http://bventertainment.go.com/brightcove/brightcove-player.swf", w:br.w, h:br.h, vars:flashVars }).render();
	} else {
	new $flash({ movie:"http://services.brightcove.com/services/viewer/federated/"+br.playerId, w:br.w, h:br.h, vars:"continuousPlay=false&wmode=transparent&playerId="+br.playerId+"&viewerSecureGatewayURL=https://services.brightcove.com/services/amfgateway&servicesURL=http://services.brightcove.com/services&cdnURL=http://admin.brightcove.com&domain=embed&autoStart="+br.autoStart, base:"http://admin.brightcove.com" }).render();
	}
}

var playerIndex;
var flashId;
function createExperience(config, flashVersion) {
   // default version to 7 for backwards compatability
   if (flashVersion == undefined) var flashVersion = 7;
   // Config parameters to pass into the SWF file.
   var servicesURL = "http://bventertainment.go.com/brightcove/";
   var viewerSecureGatewayURL = "https://console.brightcove.com/services/amfgateway";
   var cdnURL = "http://bventertainment.go.com/brightcove/";

   var bgcolor = config["preloadBackColor"];
   var externalAds = (typeof(playAd) != "undefined");
   var sendReports = (typeof(reportEvent) != "undefined");

   var width = config["width"];
   var height = config["height"];
   if (width == null) {
    width = "100%";
   }
   if (height == null) {
    height = "100%";
   }
  //specify version required Flash version
  if (config["requireFlash8"] || flashVersion == 8){
    requiredMajorVersion = 8;
  } else{
	//mac requires flash 8
	requiredMajorVersion = 7;
	var isMac = navigator.appVersion.toLowerCase().indexOf("mac") > 0;
	if (isMac) requiredMajorVersion = 8;
  }
  var requiredMinorVersion = 0;
  var requiredRevision = 0;

  var hasRightVersion = DetectFlashVer(requiredMajorVersion,requiredMinorVersion,requiredRevision);
  if(hasRightVersion) {

	var pid = getParameter("bcpid");
	if(pid.length < 1  || (pid == config["playerId"]))  {
		var titleParam = getParameter("bctid");
		if (titleParam.length > 0) {
		  config["videoId"] = titleParam;
		  config["autoStart"] = true;
		  config["fromLink"] = true;
		}
		var lineupParam = getParameter("bclid");
		if (lineupParam.length > 0) {
		  config["lineupId"] = lineupParam;
		}
	}

    if (playerIndex == undefined){
		playerIndex = 0;
	}else{
		playerIndex++;
	}

    if (config["flashId"] == undefined) {
      flashId = "flashObj" + playerIndex;
    } else {
      flashId = escapeValue(config["flashId"]) + playerIndex;
    }

    var configItems = "";
    for (var i in config) {
       if (i == "flashId") continue;
       if (typeof(config[i]) == "function" || typeof(config[i]) == "object") continue;

       configItems += "&" + i + "=" + escapeValue(config[i]);
    }

    // Hook for Internet Explorer.
    if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub ' + flashId + '_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call onFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
    }

    var swfFile = "brightcove-player.swf";
    if (flashVersion == 8) {
      swfFile = "brightcove-player.swf";
    }

    var file = cdnURL + swfFile + "?flashId="+flashId+
         "&adURLBase="+escapeValue(servicesURL)+
         "&pwidth="+escapeValue(width)+
		 "&pheight="+escapeValue(height)+
         configItems;

    if (!DetectFlashVer(8,0,0)) {
      file += "&domain=" + getDomain();
    }

    wmode = config["wmode"];
	if (wmode == null) wmode = "window";

    version = "7,0,0,0"; // why write 7 always??
    quality = "high";
    document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + version + "\" id=\""+flashId+"\" width=\""+width+"\" height=\""+height+"\">");
    document.write("  <param name=\"allowScriptAccess\" value=\"always\"/>");
    document.write("  <param name=\"allowFullScreen\" value=\"true\"/>");
    document.write("  <param name=\"movie\" value=\""+file+"\"/>");
    document.write("  <param name=\"wmode\" value=\""+wmode+"\"/>");
    document.write("  <param name=\"quality\" value=\""+quality+"\"/>");
    document.write("  <param name=\"bgcolor\" value=\"" + bgcolor + "\"/>");
    document.write("  <param name=\"SeamlessTabbing\" value=\"false\"/>");
    document.write("  <embed src=\""+file+"\" base=\""+cdnURL+"\" quality=\""+quality+"\" bgcolor=\""+bgcolor+"\" allowScriptAccess=\"always\" name=\""+flashId+"\" width=\""+width+"\" height=\""+height+"\" wmode=\""+wmode+"\" seamlesstabbing=\"false\" type=\"application/x-shockwave-flash\" swLiveConnect=\"true\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>");
    document.write("</object>");

  } else {  // flash is too old or we can't detect the plugin
    document.write("<table width='" + width + "' height='" + height + "' border='0' bgcolor='"+bgcolor+"'>");
    document.write("<tr><td align='center' valign='middle'>");
    document.write("<a href='http://www.adobe.com/go/getflash/' target='_blank'><img src='"+cdnURL+"/viewer/upgrade_flash_player.gif' alt='Get Flash Player' width='314' height='200' border='0'></a>");
    document.write("</td></tr></table>");
   }

   return flashId;
}

function escapeValue(str) {
  return encodeURIComponent(str);
}

function getDomain() {
  var domain = window.location.href;
  if (domain.substring(0, 7) == "http://") {
    domain = domain.substring(7, domain.length);
  }
  var i = domain.indexOf("/");
  if (i != -1) {
    domain = domain.substring(0, i);
  }
  i = domain.indexOf(":");
  if (i != -1) {
    domain = domain.substring(0, i);
  }
  return domain;
}
var ID_DELIM = "|||";

function onFSCommand(command, args) {
  if (command == "eval"){
    eval(args);
    return;
  }
  if (this[command] == null) return;
  var obj = convertToObject(unescape(args));
  if (obj != null) {
    var callback = obj.callback;
    var flashId = obj.flashId;
    if (obj.flashId != null && callback != null) {
      callback = obj.flashId + ID_DELIM + callback;
    }
    if (obj.args == null) {
      eval(command + "(callback);");
    } else {
      eval(command + "(obj.args, callback);");
    }
  } else {
    eval(command + "();");
  }
}

var flashCallback;
var flashCallbacks = [];
function setAPICallback(id, callback) {
  flashCallback = callback;
  flashCallbacks[id] = callback;
}

function callFlash() {
  var method = arguments[0];
  var params = [];
  for (var i = 1; i < arguments.length; i++) {
    params.push(arguments[i]);
  }
  callbackFlash(flashCallback, {method:method, params:params});
}

function callFlashInstance() {
  var flashId = arguments[0];
  var method = arguments[1];
  var params = [];
  for (var i = 2; i < arguments.length; i++) {
    params.push(arguments[i]);
  }
  var callback = flashCallbacks[flashId];
  callbackFlash(callback, {method:method, params:params});
}

function callbackFlash(callback, returnValue) {
  var flashId = "flashObj";

  var arry = callback.split(ID_DELIM);

  if (arry.length > 1) {
    if (arry[0].length > 0) {
      flashId = arry[0];
    }
    callback = arry[1];
  }

  var fo = document[flashId];
  if (fo == null) fo = document.embeds[flashId];
  if (fo == null) fo = document.getElementById(flashId);

  if (fo[callback] != null) {
    return fo[callback](convertToXML(returnValue, "js2flash"));
  } else {
    try {
      fo.SetVariable(callback, convertToXML(returnValue, "js2flash"));
    } catch (e) {}
  }
}


function convertToXML(obj, rootName) {
	if (obj instanceof Function) return "";
  	var type = getType(obj);
  	var xml = "<"+type.name+rootName+">";

	if(type.sub) {
  		for (var i in obj) {
 		  xml += convertToXML(obj[i], i);
    	}
	}
	else if (type.name == "str") {
		obj = replaceEntities(obj);
		xml += obj;
	}
	else {
		  xml += obj;
	}
	xml += "</"+type.name+rootName+">";
	return xml;
}

function replaceEntities(obj) {
	obj = obj.replace("&", "&amp;");
	obj = obj.replace("<", "&lt;");
	obj = obj.replace(">", "&gt;");
	return obj;
}

var s_xml_types = new Array();
s_xml_types.push({name:"str",type:String,sub:false});
s_xml_types.push({name:"boo",type:Boolean,sub:false});
s_xml_types.push({name:"num", type:Number,sub:false});
//s_xml_types.push({name:"date", type:Date,sub:false});
s_xml_types.push({name:"arr", type:Array,sub:true});
s_xml_types.push({name:"cda", type:CData, sub:false});
s_xml_types.push({name:"obj", type:Object,sub:true});

function getType(obj) {
        switch (typeof(obj)) {
		case "boolean":
			return {name:"boo",type:Boolean,sub:false};
		case "string":
			return {name:"str",type:String,sub:false};
		case "number":
			return {name:"num",type:Number,sub:false};
	}
	for (var i = 0; i < s_xml_types.length; i++) {
	  if (obj instanceof s_xml_types[i].type) {
	    return s_xml_types[i];
	  }
	}
	return {name:"obj", type:Object,sub:true};
}
function getTypeClass(name) {
  if (name == null) return null;

  name = name.toLowerCase();
	for (var i = 0; i < s_xml_types.length; i++) {
	  if (name == s_xml_types[i].name) {
	    return s_xml_types[i].type;
	  }
	}
	return null;
}

function convertToObject(node) {
//  try {
    if (node == null) {
      return;
    }

    if (node.substring != null) {
      node = parseXML(node);
    }

	  if (node == null || node.childNodes == null || node.childNodes.length == 0) {
	    return null;
	  }

	  var type = getTypeClass(node.nodeName.substring(0,3));
	  if (type == null) {
	    type = Object;
	  }

		if (node.firstChild.nodeType == 3 || node.firstChild.nodeType == 4) {
			return getObjectForNode(type, node);

		} else {

  		var obj = new type();
	  	var children = node.childNodes;
		  for (var i = 0; i < children.length; i++) {
		    var name = children[i].nodeName;
		    name = name.substring(3, name.length);
			  obj[name] = convertToObject(children[i]);
	  	}
		  return obj;
		}
//	} catch (e) {
//    alert("Error creating object:" + e.message);
//	  return null;
//	}
}

function getObjectForNode(type, node) {
	if (type == Boolean) {
		if (node.firstChild.nodeValue == "true") {
			return new Boolean(1);
		}
		else {
			return new Boolean(0);
		}
	}
	else {
		return new type(node.firstChild.nodeValue);
	}
}

function parseXML(str) {
  if (window.ActiveXObject) {
    var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
    try {
      xmldoc.setProperty("SelectionLanguage", "XPath");
    } catch (e) {} // i.e. 5 doesn't like setting the selection language
    xmldoc.async = false;

    xmldoc.loadXML(str);
    return xmldoc.documentElement;
  } else if (DOMParser) {

    var parser = new DOMParser();
    var doc = parser.parseFromString(str, "text/xml");

    return doc.firstChild;

  } else {
    return makeXMLNode(str);
  }
}


function makeXMLNode(str) {
  var node = {};
  var nodeName = node.nodeName = getNodeName(str);
  node.nodeType = 1;
  node.childNodes = [];
  node.firstChild = null;
  var startTagEndIndex = nodeName.length + 2;
  var endTagIndex = str.lastIndexOf("</" + nodeName);
  var nodeData = str.substring(startTagEndIndex, endTagIndex);
  if (nodeData.substring(0, 9) == "<![CDATA[") {
    var child = {};
    child.nodeName = null;
    child.nodeType = 4;
    child.nodeValue = getCDATA(nodeName, str.substring(startTagEndIndex, str.length));
    node.childNodes = [child];
  } else if (nodeData.indexOf("<") > -1) {
    node.childNodes = getChildNodes(nodeData);
  } else if (nodeData.length == 0) {
    //do nothing, we want 0 children here
  } else {
    var child = {};
    child.nodeName = null;
    child.nodeType = 3;
    child.nodeValue = getNodeValue(nodeName, nodeData);
    node.childNodes = [child];
  }
  if (node.childNodes.length > 0) {
    node.firstChild = node.childNodes[0];
  }
  return node;
}

function getNodeName(str) {
  return str.substring(str.indexOf("<")+1, str.indexOf(">"));
}

function getChildNodes(nodeData) {
  var childNodes = [];
  var nodeName;
  var nextIndex;
  var endIndex;
  var dataLength;
  var nameLength;
  var startNodesArray;
  var endNodesArray;
  var startNodesLength;
  var endNodesLength;
  var endNodes;
  var startNodes;
  var endNode;
  var i;
  var j;
  while (nodeData.length > 0) {
    nodeName = getNodeName(nodeData);
    nameLength = nodeName.length;
    nextIndex = nodeData.indexOf("<"+nodeName, nameLength);
    endIndex = nodeData.indexOf("</"+nodeName, nameLength);
    if (endIndex < 0) return childNodes;
    if (nextIndex < 0 || endIndex < nextIndex) {
      dataLength = endIndex+nodeName.length+3;
      childData = nodeData.substr(0, dataLength);
      nodeData = nodeData.substr(dataLength);
      childNodes.push(makeXMLNode(childData));
    } else {
      endNodes = 0;
      startNodes = 0;
      startNodesArray = nodeData.split("<" + nodeName + ">");
      startNodesLength = startNodesArray.length;
      endNode = "</" + nodeName + ">";
      for (i = 0; i < startNodesLength; i++) {
        startNodes++;
        startNodesStr = startNodesArray[i];
        if (startNodesStr.indexOf(endNode) > -1) {
          endNodesArray = startNodesStr.split("</" + nodeName + ">");
          endNodesLength = endNodesArray.length;
          for (j = 0; j < endNodesLength; j++) {
            if (++endNodes == startNodes) {
              childData = startNodesArray.slice(0, startNodes).join("");
              dataLength = childData.length;
              nodeData = nodeData.substr(dataLength);
              childNodes.push(makeXMLNode(childData));
              return childNodes;
            }
          }
        }
      }
      childNodes.push(makeXMLNode(nodeData));
      nodeData = "";
    }
  }
  return childNodes;
}

function getCDATA(nodeName, nodeData) {
  var endCDATA = nodeData.indexOf("]]>", 9);
  if (endCDATA < 0) {
    return null;
  } else {
    return getNodeValue(nodeName, nodeData.substring(9, endCDATA));
  }
}

function getNodeValue(nodeName, nodeValue) {
  switch (nodeName.substr(0, 3)) {
    case "boo":
      return (nodeValue=="true");
    case "num":
      return Number(nodeValue);
    case "str":
      return String(nodeValue);
    default:
      return nodeValue;
  }
}

function CData(str) {
  this.data = str;
}

CData.prototype.toString = function() {
  return "<![CDATA[" + this.data + "]]>";
}

/*
var chunks = {}
function chunkCall(id, total, index, chunk) {
  if (chunks[id] == undefined) chunks[id] = [];
  chunks[id][index] = chunk;
  if (index == total) {
    eval(chunks[id].join(""));
    delete chunks[id];
  }
}
*/
//Flash Detection
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1 && /opera/i.test(navigator.userAgent) == false) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	} else {
			flashVer = -1;
		}
	}
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else {
		flashVer = -1;
	}
	return flashVer;
}
// If called with no parameters this function returns a floating point value
// which should be the version of the Flash Player or 0.0
// ex: Flash Player 7r14 returns 7.14
// If called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
   	for (i=25;i>0;i--) {
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);
		}
		if (versionStr == -1 ) {
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");
			} else {
				versionArray      = versionStr.split(".");
			}
			versionMajor      = versionArray[0];
			versionMinor      = versionArray[1];
			versionRevision   = versionArray[2];

			versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			versionNum        = parseFloat(versionString);
    		if ( versionMajor > reqMajorVer ) {
				return true;
			} else {
				return ((versionMajor == reqMajorVer && versionMinor >= reqMinorVer) ? true : false );
			}
		}
	}
	return (reqVer ? false : 0.0);
}

// Visual basic helper required to detect Flash Player ActiveX control version information
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('Function VBGetSwfVer(i)\n');
	document.write('  on error resume next\n');
	document.write('  Dim swControl, swVersion\n');
	document.write('  swVersion = 0  \n');
	document.write('  set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))\n');
	document.write('  if (IsObject(swControl)) then\n');
	document.write('    swVersion = swControl.GetVariable("$version")\n');
	document.write('  end if\n');
	document.write('  VBGetSwfVer = swVersion\n');
	document.write('End Function\n');
	document.write('</script\>\n');
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub flashObj_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call onFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}
// Functions to parse query string parameters
// version: 1.0
// written by Kevin Langdon


// #############################################
// function returns the query string part of url
// everything followed by the '?'
function getQueryString() {
    var urlStr = document.location.href;
    var i = urlStr.indexOf("?");
    if (i != -1) {
        return urlStr.substring(i, urlStr.length - 1);
    }
    return null;
}


// #############################################
// function parses the query string and returns each
// parameter and value seperated by '&'
function getParameter(name, defaultValue) {
    if (defaultValue == null) {
        defaultValue = "";
    }

    var url = document.location.href;
    var i = url.indexOf(name + "=");
    if (i != -1) {
        var valuestart = i+name.length+1;
        var valueend = url.length;

        i = url.indexOf("&", valuestart)
        if (i != -1) {
            valueend = i;
        }

        return unescape(url.substring(valuestart, valueend));
    }
    return defaultValue;
}





