// fail gracefully, ie: do nothing if used incorrectly
var urlcaller = window.location;

// grab the localhost variable
var localhost = window.powerdash_localhost;
if ( localhost > 0 ) {
  	var baseurl = 'http://localhost:8080/powerdash-embed/';
 }
else {
	var baseurl = 'http://embed.powerdash.com/';
}
// grab the width variable
var width = window.powerdash_width;
if ( width ) {
  width = unescape( width.toString() );
  width = width.replace(/</g, '&lt;');
  width = width.replace(/>/g, '&gt;');
 }
else {
	var width = '730';
}
// calculate the height variable
var height = (Math.round(width/1.6) + 32);
// grab the systemid variable
var sysid = window.powerdash_systemid;
if ( sysid ) {
  sysid = unescape( sysid.toString() );
  sysid = sysid.replace(/</g, '&lt;');
  sysid = sysid.replace(/>/g, '&gt;');
 }
  // grab the lang variable
var langiso = window.powerdash_lang;
if ( langiso ) {
  langiso = unescape( langiso.toString() );
  langiso = langiso.replace(/</g, '&lt;');
  langiso = langiso.replace(/>/g, '&gt;');
 }
 // grab the color_bg variable
var color_bg = window.powerdash_color_bg;
if ( color_bg ) {
  color_bg = unescape( color_bg.toString() );
  color_bg = color_bg.replace(/</g, '&lt;');
  color_bg = color_bg.replace(/>/g, '&gt;');
 }
  // grab the color_text variable
var color_text = window.powerdash_color_text;
if ( color_text ) {
  color_text = unescape( color_text.toString() );
  color_text = color_text.replace(/</g, '&lt;');
  color_text = color_text.replace(/>/g, '&gt;');
 }
  // grab the color_link variable
var color_link = window.powerdash_color_link;
if ( color_link ) {
  color_link = unescape( color_link.toString() );
  color_link = color_link.replace(/</g, '&lt;');
  color_link = color_link.replace(/>/g, '&gt;');
 }
 
var randomnum=Math.floor(Math.random()*1000000000000);

   // send our output along
  document.write('<iframe name=\"powerdashFrame\" id=\"powerdashFrame\" src=\"' + baseurl + 'v1/systems/charts.html?rnd=' + randomnum + '&amp;sysid=' + sysid + '&amp;width=' + width + '&amp;langiso=' + langiso + '&amp;color_bg=' + color_bg + '&amp;color_text=' + color_text + '&amp;color_link=' + color_link + '\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\" style=\"overflow:hidden;height:' + height + 'px;width:' + width + 'px;\"></iframe>');
