﻿function OpenPage(obj,intPType)
{
    var searchWord = new String();
    searchWord = obj.value;
    if(searchWord != "" && searchWord.toLowerCase() != "search")
    {
        switch(intPType)
        {
            case "0":
                window.open('SearchResult.aspx?searchText='+ searchWord,'_top');
                break;
            case "1":
                window.open('SitePages/SearchResult.aspx?searchText='+ searchWord,'_top');
                break;
        }
        
    }
    else
    {
    alert("Please enter one or more search word.");
    }    
}

function CheckSearchWord(obj)
{
    var searchWord = new String();
    searchWord = obj.value;
    if(searchWord == "")
    {
        alert("Please enter one or more search word.");
    }
    else if(searchWord.toLowerCase() == "search")
    {
        alert("Please enter one or more search word.");
    }
}

function remove(object)
{
    if(object.value.toLowerCase() == "search")
    {
        object.value = "";
    }        
}

function replace(object)
{
    if(object.value == "")
    {
        object.value = "Search";
    }
}

function doenter(obj,intPType)
{
    if(event.keyCode == 13)
    {
        OpenPage(obj,intPType);
    }
}    

function Email_Page_Link(location,title)
{
    var strLocation = location;
    mail_str = "Send_E_Mail.aspx?subject= Recommended Link: " + title;
    mail_str += "&body= {USER} has recommended you to visit this page on Singapore Mercantile Exchange site (http://www.smx.com.sg) ";
    mail_str += " Tip -- " + title;
    mail_str += ". You should check this out at, " + escape(strLocation);
    window.showModalDialog(mail_str,window,"dialogWidth:582px;dialogHeight:240px;scroll:no;help:no;resizable:no;status:no",false);
}

///***********************************************
//* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
//* This notice MUST stay intact for legal use
//* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
//***********************************************/
//
///* Modified to support Opera */
//function bookmarksite(title,url)
//{
//    if (window.sidebar) // firefox
//	    window.sidebar.addPanel(title, url, "");
//    else if(window.opera && window.print)
//    { // opera
//	    var elem = document.createElement('a');
//	    elem.setAttribute('href',url);
//	    elem.setAttribute('title',title);
//	    elem.setAttribute('rel','sidebar');
//	    elem.click();
//    } 
//    else if(document.all)// ie
//	    window.external.AddFavorite(url, title);
//}

function rss(intPType)
{
    switch(intPType)
        {
            case "0":
                window.open('RssLink.htm','','left=100,top=100,right=0,width=600,height=400,scrollbars=1,resizable=yes'); 
                break;
             case "1":
                window.open('SitePages/RssLink.htm','','left=100,top=100,right=0,width=600,height=400,scrollbars=1,resizable=yes'); 
                break;
             case "2":
                window.open('../SitePages/RssLink.htm','','left=100,top=100,right=0,width=600,height=400,scrollbars=1,resizable=yes'); 
                break;
        }
}