// Copyright Paid On Results.


var PORisOpera = (navigator.userAgent.indexOf('Opera') != -1);
var PORisIE = (!PORisOpera && navigator.userAgent.indexOf('MSIE') != -1)

var ElementWidths = new Array;
var ElementHeights = new Array;

var porMouseY = 0;
var porMouseX = 0;

var currentPage = 1;
var no_pages = 0;

var rowStates = new Array;

function OverviewReport(session, period) {

window.location = "/cgi-bin/overview.pl?session=" + session + "&merchants=" + popupMenuMerchantID + "&period=" + period;

}

function CreativeReport(session, period) {

window.location = "/cgi-bin/creative.pl?session=" + session + "&merchants=" + popupMenuMerchantID + "&period=" + period;

}

function MerchantWebsite(session){
window.open('/cgi-bin/visit-merchant.pl?session=' + session + '&site_id=' + popupMenuMerchantID);
}

function MerchantProfile(session, period) {

window.location = "/cgi-bin/view-merchant.pl?session=" + session + "&site_id=" + popupMenuMerchantID;

}

function ChangeTableLayout(layoutID, scriptURL, width, height, session, tableName){

if (layoutID == 'new'){
var url = "/cgi-bin/customise-table.pl?session=" + session + "&table_id=" + tableName + "&scriptURL=" + scriptURL;
popwin(url,"", width, height, 'scroll');
return;
}

window.location = scriptURL + '&table_layout=' + layoutID;

}

function ChangeSortField(sortField, scriptURL) {

window.location = scriptURL + '&sortField=' + sortField;

}

function MerchantSearch(searchValue, session){

if (typeof searchValue == ''){
LoadMenu('start', session);
} else {

if (searchValue != ''){
eval("rExp = /^" + searchValue + "/gi;");
}

var html = '<table border="0" cellpadding="3" cellspacing="0">';

for (siteID in Merchants){

if (Merchants[siteID].search(rExp) < 0){
continue;
}

html += '<tr><td  class="normlink">&nbsp;&nbsp;<a href="/cgi-bin/pickup-links.pl?session=' + session +'&site_id=' + siteID + '">' + Merchants[siteID] + '</td></tr>';

}

html += '</table>';

document.getElementById('merchantList').innerHTML = html; 

}

}

function LoadMenu(movePage, session) {

if (movePage == 'next'){
currentPage = currentPage + 1;
} else if (movePage == 'back'){
currentPage = currentPage - 1;
} else if (movePage == 'start'){
currentPage = 1;
}

if (currentPage > no_pages){
currentPage = 1;
} else if (currentPage < 1){
currentPage = no_pages;
}

searchValue = document.browseMenu.keyword.value;

if (searchValue != ''){
eval("rExp = /^" + searchValue + "/gi;");
}

var html = '<table border="0" cellpadding="3" cellspacing="0">';

var pos = 0;
var got_merchant = 0;

var show_from = ((currentPage * 16) - 16) + 1;
var show_to = (show_from + 16) - 1;

if (document.browseMenu.sortMethod.value == 'name'){

for (siteID in Merchants){

got_merchant = 1;

if (searchValue != ''){
if (Merchants[siteID].search(rExp) < 0){
continue;
}
}

pos = pos + 1;
if (pos >= show_from && pos <= show_to){
html += '<tr><td  class="normlink">&nbsp;&nbsp;<a href="/cgi-bin/pickup-links.pl?session=' + session +'&site_id=' + siteID + '">' + Merchants[siteID] + '</td></tr>';
}
}

} else if (document.browseMenu.sortMethod.value == 'joined'){

for (var x= 0; x < dateJoined.length; x++) {

if (typeof Merchants[dateJoined[x]] == 'undefined'){
continue;
}

if (searchValue != ''){
if (Merchants[dateJoined[x]].search(rExp) < 0){
continue;
}
}

pos = pos + 1;
if (pos >= show_from && pos <= show_to){
html += '<tr><td  class="normlink">&nbsp;&nbsp;<a href="/cgi-bin/pickup-links.pl?session=' + session + '&site_id=' + dateJoined[x] + '">' + Merchants[dateJoined[x]] + '</td></tr>';
}
}

}

if (pos == 0){ 
if (got_merchant == 0){
html += '<tr><td  class="normlink">You have yet to join any Merchant, please click Browse Merchant on the menu to visit our Merchant Directory</td></tr>';
} else {
html += '<tr><td  class="normlink">Sorry no Merchants can be found, please refine your search.</td></tr>';
}
}

html += '</table>';

no_pages = Math.round(pos / 16);

if ((pos - (no_pages * 16)) > 0){
no_pages = no_pages + 1;
}

document.getElementById('merchantList').innerHTML = html; 

}

function PromptCustomiseTable(fieldName) {

findObjectPos_POR(document.getElementById(fieldName));

leftPos = curleft - (parseInt(document.getElementById('customiseTableMenu').style.width) - parseInt(document.getElementById(fieldName).style.width)) - 2;
topPos = curtop + parseInt(document.getElementById(fieldName).style.height);

document.getElementById('customiseTableMenu').style.left = leftPos + "px";
document.getElementById('customiseTableMenu').style.top = topPos + "px";
document.getElementById('customiseTableMenu').style.visibility = "visible";

setTimeout("menuOff('"+fieldName+"', '" + 'customiseTableMenu' +"');",1000);

}

function startExport() {

findObjectPos_POR(document.getElementById('tableID1'));

leftPos = curleft - (parseInt(document.getElementById('exportDataLayer').style.width) - parseInt(document.getElementById('tableID1').clientWidth)) - 2;
topPos = curtop + parseInt(document.getElementById('exportTable').style.height);

document.getElementById('exportDataLayer').style.left = leftPos + "px";
document.getElementById('exportDataLayer').style.top = topPos + "px";
document.getElementById('exportDataLayer').style.visibility = "visible";

setTimeout("menuOff('"+'exportTable'+"', '" + 'exportDataLayer' +"');",1000);

try
{
CustomExportOn()
}
catch(err)
{

}

}


function ShowMenu(menuName, menuHTML, offsetLeft) {

if (offsetLeft == ''){
offsetLeft = 55;
}

//if (offsetRight == '' or typeof offsetRight == 'undefined'){
offsetRight = 0;
//}

findObjectPos_POR(document.getElementById(menuName));

leftPos = curleft + offsetLeft;
topPos = curtop - offsetRight;

getPageHeight_POR();

scrollHeight = getScrollHeight_POR();

myHeight = myHeight + scrollHeight;

if ((topPos + parseInt(document.getElementById(menuHTML).style.height)) > myHeight){
topPos = myHeight - 5 - parseInt(document.getElementById(menuHTML).style.height);
}

document.getElementById(menuHTML).style.left = leftPos + "px";
document.getElementById(menuHTML).style.top = topPos + "px";
document.getElementById(menuHTML).style.visibility = "visible";

setTimeout("menuOff('"+menuName+"', '" + menuHTML +"');",2000);

}

var mouseCursorInMenu = 0;

function menuOff(menuName, menuHTML) {

scrollHeight = getScrollHeight_POR();
scrollWidth = getScrollWidth_POR();

truePORMouseY = porMouseY;
truePORMouseX = porMouseX;

if (PORisIE){
truePORMouseY += scrollHeight;
truePORMouseX += scrollWidth;
}

findObjectPos_POR(document.getElementById(menuName));

curtopParent = curtop;
curleftParent = curleft;

findObjectPos_POR(document.getElementById(menuHTML));

boxTop = curtopParent;
boxRight = parseInt(document.getElementById(menuName).style.width) + curleftParent;
boxBottom = curtopParent + document.getElementById(menuName).clientHeight; 

if ((truePORMouseX >= curleftParent && truePORMouseX <= boxRight && truePORMouseY >= boxTop && truePORMouseY <= boxBottom) || mouseCursorInMenu == 1){
setTimeout("menuOff('"+menuName+"', '" + menuHTML +"');",1000); 
} else {

boxTop = curtop;
boxRight = parseInt(document.getElementById(menuHTML).style.width) + curleft;
boxBottom = curtop + document.getElementById(menuHTML).clientHeight;

if (truePORMouseX >= curleft && truePORMouseX <= boxRight && truePORMouseY >= boxTop && truePORMouseY <= boxBottom){
setTimeout("menuOff('"+menuName+"', '" + menuHTML +"');",1000);
} else {
document.getElementById(menuHTML).style.visibility = "hidden"; 
document.getElementById(menuHTML).style.top = "0px";
document.getElementById(menuHTML).style.left = "0px";
mouseCursorInMenu = 0;
}

}

if (document.getElementById(menuHTML).style.visibility == 'hidden'){

if (menuHTML == 'exportDataLayer'){
try
{
CustomExportOff()
}
catch(err)
{

}
}

}

}

function LogActiveMenu(mouseStatus) {
mouseCursorInMenu = mouseStatus;
}

function popwin(aPage, aTarget, w, h, var1, var2){
popup=window.open(aPage,aTarget,'status=yes,scrollbars=' +((var1=='scroll' || var2=='scroll')? 'yes' : 'no')+ ',resizable=' +((var1=='resize' || var2=='resize')? 'yes' : 'no')+ ',width='+w+',height='+h);
x = parseInt(window.screen.width) / 2 - (w/2);
y = parseInt(window.screen.height) / 2 - (h/2);
popup.moveTo(x,y);
if (popup.opener == null) popup.opener = self;
}

function addMouseMoveEvent(fnc){

  if ( typeof document.addEventListener != "undefined" )
    document.addEventListener( "mousemove", fnc, false );
  else if ( typeof document.attachEvent != "undefined" ) {
    document.attachEvent( "onmousemove", fnc );
  }
  else {
    if ( window.onmousemove != null ) {
      var oldOnmousemove = window.onmousemove;
      window.onmousemove = function ( e ) {
        oldOnmousemove( e );
        window[fnc]();
      };
    }
    else 
      window.onmousemove = fnc;
  }

}

function porTrackMouse(e) {

if (!e) var e = window.event;

if (typeof e.pageY == 'number'){
porMouseY = e.pageY;
porMouseX = e.pageX;
} else{
porMouseY = e.clientY;
porMouseX = e.clientX;
}

}

function ResetTable(scriptURL, type, form){

var sort_field2 = "";
var table_layout = "";

if (type == 'layout'){
if (form.table_layout2){
var table_layout = form.table_layout2.value;
}
}

if (type == 'sort'){
if (form.sort_field2){
var sort_field2 = form.sort_field2.value;
}
}

if (table_layout == 'new'){
var url = document.optionform.custom_url.value + "&url=" + scriptURL;
popwin(url,"", 735, 440, 'scroll');
return;
}

window.location = scriptURL + '&table_layout=' + table_layout + '&sort_field=' + sort_field2;

}

var bottomReached  = 0;
var headerCount = 2;

function getPageHeight_POR() {

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

}

function getScrollWidth_POR()
{
   var w = window.pageXOffset ||
           document.body.scrollLeft ||
           document.documentElement.scrollLeft;
           
   return w ? w : 0;
} 

function getScrollHeight_POR()
{
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
           
   return h ? h : 0;
}

var removeRow = new Array;

for (var tableID = 0; tableID < 5; tableID++) {
removeRow[tableID] = 0;
}

function porFloatHeader(){

getPageHeight_POR();
scrollHeight = getScrollHeight_POR();

for (var tableID = 1; tableID < 5; tableID++) {

tableName = "floatTable" + tableID;

if (! document.getElementById(tableName)){
continue;
}

findObjectPos_POR(document.getElementById(tableName));

if (((curtop+52) - scrollHeight) >= 0){

if (removeRow[tableID] > 0){

for (deleteRow=1; deleteRow<=headerCount; deleteRow++){
document.getElementById(tableName).deleteRow(removeRow[tableID]);
}

removeRow[tableID] = 0;

}

continue;
}

if (document.getElementById(tableName).clientHeight < (myHeight+50)){
continue;
}

tableTop = (scrollHeight - curtop);

rowCount = 2;
for (Pos=0; Pos<=tableTop; (Pos=Pos+22)){
if (Pos >= 22){
rowCount ++;
}
}

if (removeRow[tableID] > 0){

for (deleteRow=1; deleteRow<=headerCount; deleteRow++){
document.getElementById(tableName).deleteRow(removeRow[tableID]);
}

removeRow[tableID] = 0;

}

removeRow[tableID] = rowCount;

mytable = document.getElementById(tableName);

mytablebody = mytable.getElementsByTagName("tbody")[0];

if (mytablebody.getElementsByTagName("tr").length <= rowCount){
removeRow[tableID] = 0;
continue;
}

for (trCount=0; trCount<=(headerCount-1); trCount++){

myrow = mytablebody.getElementsByTagName("tr")[trCount];

if (myrow){

var x=document.getElementById(tableName).insertRow(rowCount);
rowCount ++;

for (tdPos=0; tdPos<=myrow.getElementsByTagName("td").length; tdPos++){
if (myrow.getElementsByTagName("td")[tdPos]){

mycel       = myrow.getElementsByTagName("td")[tdPos];

var rowtmp = x.insertCell(tdPos); 
rowtmp.colSpan= mycel.colSpan;
rowtmp.rowSpan= mycel.rowSpan;
rowtmp.width= mycel.width;

rowtmp.style.padding= mycel.style.padding;
rowtmp.bgColor= mycel.bgColor;

//if (headerCount == 3){

rowtmp.style.border= mycel.style.border;
rowtmp.style.borderBottom= mycel.style.borderBottom;
rowtmp.style.borderRight= mycel.style.borderRight;
rowtmp.style.borderLeft= mycel.style.borderLeft;
rowtmp.style.borderTop= mycel.style.borderTop;
rowtmp.style.backgroundColor= mycel.style.backgroundColor;

//}

if (mycel.innerHTML != ''){
//rowtmp.className= "test";
rowtmp.align = mycel.align;
rowtmp.vAlign = mycel.vAlign; 
rowtmp.innerHTML= mycel.innerHTML;
}

}
}

}

}



}

}

window.onscroll = porFloatHeader;

function GetRemoteData(Session, scriptURL, fieldName, fieldValue, updateField) {

if (fieldValue == ''){
return;
}

eval("formField = document.forms[0]."+updateField+";");

  var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

var url=scriptURL + "?session=" + Session + "&" + fieldName + "=" + fieldValue;

    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            

var temp = new Array();
temp = self.xmlHttpReq.responseText.split('\n');

var count = 0;

for (var j = 0; j < temp.length; j++) {

if (! temp[j] == ""){

returnData = temp[j].split('|');

returnValue = returnData[0];
returnDisplay = returnData[1];



if (! doneAffiliates[returnValue]){
doneAffiliates[returnValue] = 1;
formField.options[formField.options.length] = new Option(returnDisplay, returnValue);
}

count = count + 1;

}

}

if (count == "0"){
alert('Sorry no data found.');
}

        }
    }

self.xmlHttpReq.open("GET", url , true) 
self.xmlHttpReq.send(null);

}

function ZoomLayer(fieldName) {

if (! ElementWidths[fieldName] || typeof ElementWidths[fieldName] == 'undefined'){
ElementHeights[fieldName] = document.getElementById(fieldName).clientHeight;
ElementWidths[fieldName] = document.getElementById(fieldName).clientWidth;
}

if (document.getElementById(fieldName).style.visibility == 'hidden'){
document.getElementById(fieldName).style.width = ElementWidths[fieldName] + "px";
document.getElementById(fieldName).style.height = 1 + "px";
LayerSwitch(fieldName, 'on');
setTimeout("expand('"+fieldName+"');",30);
} else {
setTimeout("unexpand('"+fieldName+"');",40);
}


}

function unexpand(fieldName) {

if (parseInt(document.getElementById(fieldName).style.height) > 0){

if ((parseInt(document.getElementById(fieldName).style.height)-30) > 0){
document.getElementById(fieldName).style.height = parseInt(document.getElementById(fieldName).style.height) - 30 + "px";
setTimeout("unexpand('"+fieldName+"');",40);
} else {
document.getElementById(fieldName).style.height = 0 + "px";
LayerSwitch(fieldName, 'off');
}

}

}

function expand(fieldName) {

if (parseInt(document.getElementById(fieldName).style.height) < ElementHeights[fieldName]){

if ((parseInt(document.getElementById(fieldName).style.height)+30) < ElementHeights[fieldName]){
document.getElementById(fieldName).style.height = parseInt(document.getElementById(fieldName).style.height) + 30 + "px";
setTimeout("expand('"+fieldName+"');",30);
} else {
document.getElementById(fieldName).style.height = parseInt(document.getElementById(fieldName).style.height) + (ElementHeights[fieldName] - parseInt(document.getElementById(fieldName).style.height)) + "px";
}

}

}

var selectedGraphID = 0;
var graphSelectedOptions = new Array;

function CustomiseGraph(graphID) {

if (graphsEnabled[graphID] == '' || typeof graphsEnabled[graphID] == 'undefined'){
alert('Sorry this graph has not finished loading yet.');
return;
}

selectedGraphID = graphID;

linkKey = "linkOpt" + graphID;

findObjectPos_POR(document.getElementById(linkKey));

getPageHeight_POR();

scrollHeight = getScrollHeight_POR();

browserBottom = myHeight + scrollHeight;

testHeight = curtop + parseInt(document.getElementById('customiseGraphMenu').style.height);

if (testHeight > browserBottom){
topPos = curtop - (testHeight - browserBottom);
} else {
topPos = curtop;
}

testWidth = curleft + parseInt(document.getElementById(linkKey).style.width) + 5 + parseInt(document.getElementById('customiseGraphMenu').style.width);

if (testWidth > myWidth){
leftPos = curleft - (parseInt(document.getElementById('customiseGraphMenu').style.width) );
} else {
leftPos = curleft + parseInt(document.getElementById(linkKey).style.width) + 5;
}

for (i in graphSelectedOptions){
eval("document.opt"+i+".src = 'http://affiliates2.paidonresults.com/images/inv-5x5px.gif';");
}

graphSelectedOptions = [];

dataURL = graphOptions[graphID].split('?');

queryString = dataURL[1].split('&');

for( var x = 0; x < queryString.length; x++ ){

queryPair = queryString[x].split('=');

if (queryPair[0] != 'session' && queryPair[0] != 'period' && queryPair[0] != 'graph_id'){
eval("if (document.opt"+queryPair[1]+"){document.opt"+queryPair[1]+".src = 'http://affiliates.paidonresults.com/images/12pt-tick.gif';graphSelectedOptions['"+queryPair[1]+"']=1;}");
}

}

document.getElementById('customiseGraphMenu').style.left = leftPos + "px";
document.getElementById('customiseGraphMenu').style.top = topPos + "px";
document.getElementById('customiseGraphMenu').style.visibility = "visible";

setTimeout("menuOff('"+linkKey+"', '" + 'customiseGraphMenu' +"');",1000);

}

function ChangeGraphPlotValue(plotName, plotCaption) {

document.getElementById('customiseGraphMenu').style.visibility = "hidden"; 
document.getElementById('customiseGraphMenu').style.top = "0px";
document.getElementById('customiseGraphMenu').style.left = "0px";

graphOptions[selectedGraphID] = ChangeGraphSetting(graphOptions[selectedGraphID], 'plot_value', plotName);

chartID = "chart" + selectedGraphID + "Id";

var chartObj = getChartFromId(chartID);

chartObj.setDataURL(graphOptions[selectedGraphID]); 

captionID = "caption" + selectedGraphID;

if (document.getElementById(captionID)){
document.getElementById(captionID).innerHTML = plotCaption;
}

}

function ReloadGraph(graphID) {

chartID = "chart" + graphID + "Id";

var chartObj = getChartFromId(chartID);

chartObj.setDataURL(graphOptions[graphID]); 

}

function ChangeGraphType(swfFile, optionID) {

graphFilename = "/graphs/" + swfFile + ".swf";

chartID = "chart" + selectedGraphID + "Id";

graphDIV = "graphDiv" + selectedGraphID;

document.getElementById('customiseGraphMenu').style.visibility = "hidden"; 
document.getElementById('customiseGraphMenu').style.top = "0px";
document.getElementById('customiseGraphMenu').style.left = "0px";

graphOptions[selectedGraphID] = ChangeGraphSetting(graphOptions[selectedGraphID], 'graph', swfFile);

graphWidth = parseInt(document.getElementById(graphDIV).style.width);
graphHeight = parseInt(document.getElementById(graphDIV).style.height);

var myChart = new FusionCharts(graphFilename, chartID, graphWidth, graphHeight, "0", "1"); 
myChart.setDataURL(graphOptions[selectedGraphID]);
myChart.setTransparent(true);
myChart.render(graphDIV);

}


function ChangeGraphSetting(currentURL, name, value) {

url = currentURL.split('?');

queryString = url[1].split('&');

url[1] = "";

for (var i=0; i<queryString.length; i++) {

pair = queryString[i].split('=');

if (pair[0] == name){
pair[1] = value;
}

if (url[1] == ""){
url[1] = pair[0] + "=" + pair[1];
} else {
url[1] += "&" + pair[0] + "=" + pair[1];
}

}

currentURL = url[0] + "?" + url[1];

return currentURL;

}

function PrintGraph() {

document.getElementById('customiseGraphMenu').style.visibility = "hidden"; 
document.getElementById('customiseGraphMenu').style.top = "0px";
document.getElementById('customiseGraphMenu').style.left = "0px";

chartID = "chart" + selectedGraphID + "Id";

var chartToPrint = getChartFromId(chartID);
chartToPrint.print();

}

function SaveGraphSettings(sessionID) {

document.getElementById('customiseGraphMenu').style.visibility = "hidden"; 
document.getElementById('customiseGraphMenu').style.top = "0px";
document.getElementById('customiseGraphMenu').style.left = "0px";

graphDiv = "graphDiv" + selectedGraphID;

graphMessage(graphDiv, "Saving your Settings", "Spinning_POR_logo_loader.gif", 180, 180);

url = graphOptions[selectedGraphID].split('?');

queryString = url[1].split('&');

url = "/cgi-bin/graph-data/store-settings.pl?session=" + sessionID + "&graph_id=" + selectedGraphID + "&script_key=" + graphScriptKey;

for (var i=0; i<queryString.length; i++) {

queryPair = queryString[i].split('=');

if (queryPair[0] != 'session' && queryPair[0] != 'period' && queryPair[0] != 'graph_id'){
url += "&" + queryPair[0] + "=" + queryPair[1];
}

}

  var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {

if (self.xmlHttpReq.responseText == 'OK'){
graphMessage(graphDiv, "Your Settings have been Saved", "tick_25x25.jpg", 25, 25);
} else {
graphMessage(graphDiv, "Unable to save your settings", "cross_25x25.jpg", 25, 25);
}

setTimeout("hideGraphMessage();",2000);

        }
    }

self.xmlHttpReq.open("GET", url, true) 
self.xmlHttpReq.send(null);

}

function GetGraphType(graphID) {

url = graphOptions[graphID].split('?');

graphType = "";

queryString = url[1].split('&');

for (var i=0; i<queryString.length; i++) {

pair = queryString[i].split('=');

if (pair[0] == 'graph'){
graphType = pair[1];
break;
}

}

return graphType;

}

function hideGraphMessage() {
document.getElementById('saveSettingsBackground').style.left = 0 + "px";
document.getElementById('saveSettingsBackground').style.top = 0 + "px";
document.getElementById('saveSettingsBackground').style.visibility = "hidden";
document.getElementById('saveSettingsMessage').style.left = 0 + "px";
document.getElementById('saveSettingsMessage').style.top = 0 + "px";
document.getElementById('saveSettingsMessage').style.visibility = "hidden";
}

function graphMessage(graphDiv, msgText, imageFilename, imageWidth, imageHeight) {

if (! document.getElementById('saveSettingsMessage')){

var head = document.getElementsByTagName('body')[0];

if (navigator.appName == "Microsoft Internet Explorer"){
var imageOver = document.createElement('<div id="saveSettingsMessage" name="saveSettingsMessage" style="position:absolute;visibility:hidden;left:0px;top:0px;z-index:110;"></div>');
head.appendChild(imageOver);
} else {
var imageOver2 = document.createElement('div');
imageOver2.setAttribute('name', 'saveSettingsMessage');
imageOver2.setAttribute('id', 'saveSettingsMessage');
imageOver2.setAttribute('style', 'position:absolute;visibility:hidden;left:0px;top:0px;z-index:110;');
head.appendChild(imageOver2);
}

if (navigator.appName == "Microsoft Internet Explorer"){
var imageOver = document.createElement('<div id="saveSettingsBackground" name="saveSettingsBackground" style="position:absolute;visibility:hidden;left:0px;top:0px;z-index:109;background-color:#ffffff;border:1px solid #000000;"></div>');
head.appendChild(imageOver);
} else {
var imageOver2 = document.createElement('div');
imageOver2.setAttribute('name', 'saveSettingsBackground');
imageOver2.setAttribute('id', 'saveSettingsBackground');
imageOver2.setAttribute('style', 'position:absolute;visibility:hidden;left:0px;top:0px;z-index:109;background-color:#ffffff;border:1px solid #000000;');
head.appendChild(imageOver2);
}

if (! document.getElementById('saveSettingsMessage')){
return;
}

}

document.getElementById('saveSettingsMessage').innerHTML = '<Table border="0" cellpadding="0" cellspacing="0"><Tr><td align="center"><img src="http://affiliates.paidonresults.com/images/' + imageFilename +'" width="'+imageWidth+'" height="'+imageHeight+'"></td></tr><Tr><td><img src="http://affiliates.paidonresults.com/images/inv-5x5px.gif" width="4" height="5"></td></tr><tr><td class="blue_16" align="center"><strong>'+msgText+'</td></tr></table>';

findObjectPos_POR(document.getElementById(graphDiv));

document.getElementById('saveSettingsBackground').style.width = document.getElementById(graphDiv).style.width;
document.getElementById('saveSettingsBackground').style.height = (parseInt(document.getElementById(graphDiv).style.height) - 10) + "px";

document.getElementById('saveSettingsBackground').style.left = curleft + "px";
document.getElementById('saveSettingsBackground').style.top = curtop + "px";
document.getElementById('saveSettingsBackground').style.visibility = "visible";

leftPos = Math.round(curleft + ((document.getElementById(graphDiv).clientWidth - document.getElementById('saveSettingsMessage').clientWidth) / 2));
topPos = Math.round(curtop + (((document.getElementById(graphDiv).clientHeight - 10) - document.getElementById('saveSettingsMessage').clientHeight) / 2));

document.getElementById('saveSettingsMessage').style.left = leftPos + "px";
document.getElementById('saveSettingsMessage').style.top = topPos + "px";
document.getElementById('saveSettingsMessage').style.visibility = "visible";

}

function hideGraphMessage() {

document.getElementById('saveSettingsBackground').style.left = 0 + "px";
document.getElementById('saveSettingsBackground').style.top = 0 + "px";
document.getElementById('saveSettingsBackground').style.visibility = "hidden";

document.getElementById('saveSettingsMessage').style.left = 0 + "px";
document.getElementById('saveSettingsMessage').style.top = 0 + "px";
document.getElementById('saveSettingsMessage').style.visibility = "hidden";

}

function ExportGraphAsImage() {

document.getElementById('customiseGraphMenu').style.visibility = "hidden"; 
document.getElementById('customiseGraphMenu').style.top = "0px";
document.getElementById('customiseGraphMenu').style.left = "0px";

chartID = "chart" + selectedGraphID + "Id";

var chartToSave = getChartFromId(chartID);
chartToSave.saveAsImage();

}

var graphsEnabled = new Array;

function FC_Rendered(DOMId){
DOMId = DOMId.substring(5,DOMId.length-2);
graphsEnabled[DOMId] = 1;
}

function ShowTabStatus(statusMessage) {
document.getElementById('tab_status').innerText = statusMessage;
}

addMouseMoveEvent(porTrackMouse);
