/**
 * $RCSfile: generic.js,v $
 * @version $Source: /cvs/piaweb-live/javascript/generic.js,v $, $Revision: 1.5 $, $Date: 2010/05/17 12:02:37 $, $State: Exp $
 */

// Open Pop Up Window

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var Popup = {
  open: function(options)
  {
    this.options = {
      url: '#',
      width: 400,
      height: 380,
      name:"_blank",
      location:"no",
      menubar:"no",
      toolbar:"no",
      status:"no",
      scrollbars:"no",
      resizable:"no",
      left:"",
      top:"",
      normal:false
    }
    Object.extend(this.options, options || {});

    if (this.options.normal){
        this.options.menubar = "yes";
        this.options.status = "yes";
        this.options.toolbar = "yes";
        this.options.location = "yes";
    }

    this.options.width = this.options.width < screen.availWidth?this.options.width:screen.availWidth;
    this.options.height=this.options.height < screen.availHeight?this.options.height:screen.availHeight;
    var openoptions = 'width='+this.options.width+',height='+this.options.height+',location='+this.options.location+',menubar='+this.options.menubar+',toolbar='+this.options.toolbar+',scrollbars='+this.options.scrollbars+',resizable='+this.options.resizable+',status='+this.options.status
    if (this.options.top!="")openoptions+=",top="+this.options.top;
    if (this.options.left!="")openoptions+=",left="+this.options.left;
    return window.open(this.options.url, this.options.name,openoptions ); // BLACKPIG: return the opened window
    //return false;
  }
}

// Detail Performance Tip
function bpToolTip(attach, content){
	new Tip(attach,
					$(content).innerHTML,
					{className: 'dannas-tooltip',
						closeButton: false,
						showOn: 'mouseover',
						fixed: true,
						hideOn: 'mouseout',
						hideOthers: true,
						delay: 0,
						title: false,
						offset: {x:35, y:0}} );
}

/***
Event.observe(window, 'load', function()
	{
		var oTotal = $('amounts');
		var m = $('fxmajors');
		
		if(oTotal && m) { // there is an AMOUNTS element
			bpAsset();
		}
	}
);
***/

function bpAsset() {
	var m = $('fxmajors');
	var c = $('fxcrosses');
	var f = $('fixedincome');
	var i = $('stockindicies');
	var y = $('yearly');
	var q = $('quarterly');
	var p = (y && y.checked ? 'Y' : 'Q');

    if(m) {
        new Ajax.Updater('amounts', 'ajax.php', {
						parameters: { fxmajors: m.checked?m.value:'',
									fxcrosses: c.checked?c.value:'',
									fixedincome: f.checked?f.value:'',
									equityindicies: i.checked?i.value:'',
									payment: p }
						}
					);
    }
}

function bpAsset2() {
	var md = $('fxmajors1');
    var mw = $('fxmajors2');
	var cd = $('fxcrosses1');
    var cw = $('fxcrosses2');
	//var fd = $('fixedincome1');
    //var fw = $('fixedincome2');
	var id = $('equityindicies1');
    var iw = $('equityindicies2');
    //
	var y = $('yearly');
	var q = $('quarterly');
    var s = $('sixmonth');
	var p = (y && y.checked ? 'Y' : (s && s.checked ? 'S' : 'Q'));

    if(md) {
        new Ajax.Updater('amounts', 'ajax2.php', {
						parameters: { fxmajors1: md.checked?md.value:'',
                                    fxmajors2: mw.checked?mw.value:'',
									fxcrosses1: cd.checked?cd.value:'',
                                    fxcrosses2: cw.checked?cw.value:'',
									//fixedincome1: fd.checked?fd.value:'',
                                    //fixedincome2: fw.checked?fw.value:'',
									equityindicies1: id.checked?id.value:'',
                                    equityindicies2: iw.checked?iw.value:'',
									payment: p }
						}
					);
    }
}

Event.observe(window, 'load', function() {
    var subs = $('subscribe');
    var subs2 = $('subscribe2');

    if(subs) {
        bpAsset();
    }
    if(subs2) {
        bpAsset2();
    }
});

// ENDS