﻿var useragent = navigator.userAgent.toLowerCase();
var isIE = ((useragent.indexOf('msie') != -1) && (useragent.indexOf('opera') == -1) && (useragent.indexOf('webtv') == -1));
if(useragent.indexOf('gecko') != -1)
{
    HTMLElement.prototype.click = function() {
        var evt = this.ownerDocument.createEvent('MouseEvents');
        evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
        this.dispatchEvent(evt);
    }
}
function getEvent()
{
    if(document.all)return window.event;        
    var func=getEvent.caller;            
    while(func!=null){    
        var arg0=func.arguments[0];
            if(arg0){
                if((arg0.constructor==Event || arg0.constructor ==MouseEvent)
                 || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){    
                    return arg0;
                }
            }
        func=func.caller;
    }
}
function addEvent(obj,evt,fun)
{   
    if(!obj||typeof(fun)!="function")return;
    if (isIE)obj.attachEvent("on"+evt, fun);
    else obj.addEventListener(evt, fun, false);
}

function username(txtBox)
{
    if(txtBox.value == '')
    {
        txtBox.value = 'Email Address';
    }
    else if(txtBox.value == 'Email Address')
    {
        txtBox.value = '';
    }
}
function password(txtBox)
{
    if(txtBox.value == '')
    {
        txtBox.value = 'Password';
    }
    else if(txtBox.value == 'Password')
    {
        txtBox.value = '';
    }
}
function search(txtBox)
{
    if(txtBox.value == '')
    {
        txtBox.value = 'Search';
    }
    else if(txtBox.value == 'Search')
    {
        txtBox.value = '';
    }
}
function stockquote(txtBox)
{
    if(txtBox.value == '')
    {
        txtBox.value = 'Stock Code';
    }
    else if(txtBox.value == 'Stock Code')
    {
        txtBox.value = '';
    }
}

function OpenNewWindowStockQuote(quote, stock){
    var url = "/Stock-Watch/Market Price.aspx?S={0}&E={1}";
    var stockQuote = document.getElementById(quote);
    var dplStock = document.getElementById(stock);
    if(stockQuote != null && dplStock != null){
        window.location.replace(url.replace("{0}",stockQuote.value.replace("Stock Code","")).replace("{1}","ASX"));   
    }    
    return false;
}