﻿// JScript File

$(function($) {
	var options = {
		format: '%B %d, %Y&nbsp;&nbsp;|&nbsp;&nbsp;%H:%M'
	}
	$('.jclock').jclock(options);
});

$(function(){
	$.superbox.settings = {
		boxId: "superbox", // Id attribute of the "superbox" element
		boxClasses: "", // Class of the "superbox" element
		overlayOpacity: .2, // Background opaqueness
		boxWidth: "600", // Default width of the box
		boxHeight: "400", // Default height of the b7ox
		loadTxt: "Loading...", // Loading text
		closeTxt: "Close", // "Close" button text
		prevTxt: "News", // "Previous" button text
		nextTxt: "Previous" // "Next" button text
	};
	$.superbox();
});


///// RADEDITOR
function ShowImageDialog(editor, textbox) { 
	if(editor) {
		editor.Fire('ImageManager', function(result) {
			if (result && result.imagePath) { 
				document.getElementById(textbox).value = result.imagePath;
			}		
		});
	}
}

function ShowDocumentDialog(editor, textbox) { 
	if(editor) {
		editor.Fire('DocumentManager', function(result) {
			if (result && result.href) { 
				document.getElementById(textbox).value = result.href;
			}		
		});
	}
}

/************** AM CHARTS *****************/
var timeout;
function amGetZoom(chart_id, from, to) {
	window.clearTimeout(timeout);
	timeout = window.setTimeout("loadStageToolData('"+ from + "', '" + to +"')", 100);
}

/********************************
*load stage tool data for given time period
*********************************/
function loadStageToolData(from, to) {
	$.post(generateStageToolDataUrl(from, to),
		function(data) {
			if((data != null) && (data != "") && (data != "NODATA")) {
				var splittedData = data.split(";");
				if(splittedData.length > 0) {
					var cssClass = "negative";
					if(splittedData[0].substr(0,1) == "+") {
						cssClass = "positive";
					}
					$("#StageToolIndexDataPerformance").html("<span class=\"" + cssClass + "\">" + splittedData[0] + "</span>");
					$("#StageToolIndexDataVolatility").html(splittedData[1]);
				}
				if(splittedData.length > 2) {
					var cssClass = "negative";
					if(splittedData[2].substr(0,1) == "+") {
						cssClass = "positive";
					}
					$("#StageToolIndexCompareDataPerformance").html("<span class=\"" + cssClass + "\">" + splittedData[2] + "</span>");
					$("#StageToolIndexCompareDataVolatility").html(splittedData[3]);
				}
			}
		}
	);
}

/********************************
*	Genartes the url using to load stage tool data
*********************************/
function generateStageToolDataUrl(from, to) {
	url = "/Export/StageToolDataProvider.ashx?from=" + from + "&to=" + to + "&isin=" + stageToolISIN;
	if(typeof(stageToolCompareISIN) != "undefined") {
		url += "&compare=" + stageToolCompareISIN;
	}
	return url;
}

/*********************************
* Renders the flash movie
**********************************/
function renderHomeFlashTeaser(flashContainerID) {
    $(flashContainerID).flash({
        src: 'swf/DB_Flash_Home_V3.swf',
        width: 845,
        height: 280,
        wmode: 'transparent',
        flashvars: {
            DAX:'index.aspx?pageID=25&isin=DE0008467440',
            TecDAX:'index.aspx?pageID=25&ISIN=DE0007203283',
            DAXplus:'index.aspx?pageID=32',
            DAXglobal:'index.aspx?pageID=33',
            RentenIndices:'index.aspx?pageID=34',
            CustomizedIndices:'index.aspx?pageID=16',
            iNav:'index.aspx?pageID=17',
            OekoDAX:'index.aspx?pageID=25&ISIN=DE000A0MEU42',
            LevDAXx2:'index.aspx?pageID=25&ISIN=DE000A0C4B34',
            ShortDAXx2:'index.aspx?pageID=25&ISIN=DE000A0SNAK2',
            CX_Commodity:'index.aspx?pageID=25&ISIN=DE000A0JZKQ1',
            DAXplusExportStrategy:'index.aspx?pageID=25&ISIN=DE000A0C4BW6',
            DAXplus_ShortDAX:'index.aspx?pageID=25&ISIN=DE000A0C4CT0',
            DAXglobal_InternationalIndices:'index.aspx?pageID=33',
            DAXplus_StrategyIndices:'index.aspx?pageID=32',
            DAXplus_MaxSharpeRatioUSA:'index.aspx?pageID=25&ISIN=DE000A0MEUW7',
            DAXglobal_Russia:'index.aspx?pageID=25&ISIN=DE000A0C4CW4',
            DAX_International100:'index.aspx?pageID=25&ISIN=DE000A0S3CB2',
            DAXglobal_AlternativeEnergy:'index.aspx?pageID=25&ISIN=DE000A0C4B75',
            DAXglobal_NuclearEnergy:'index.aspx?pageID=25&ISIN=DE000A0ME7D4',
            DAXglobal_Shipping:'index.aspx?pageID=25&ISIN=DE000A0X7NU3 ',
            DAXglobal_Afrika:'index.aspx?pageID=25&ISIN=DE000A0S3DF1',
            DAXglobal_GCC:'index.aspx?pageID=25&ISIN=DE000A0S3DW6',
            DBIX_India:'index.aspx?pageID=25&ISIN=DE000A0C4CC6',
            DAXglobal_China:'index.aspx?pageID=25&ISIN=DE000A0S2903 ',
            DAXglobal_Asia:'index.aspx?pageID=25&ISIN=DE000A0LLPW4',
            DAXglobal_LatinAmerica:'index.aspx?pageID=25&ISIN=DE000A0S3DQ8'
        }
    },
    {
        version: 8
   });
}


/******
*
*********/
$(document).ready(function($){ 
  $("a.tooltip").tooltip({cssClass:"tooltip-borderless",opacity : 20});
});