﻿// JScript File
var sPopUpWin ;
var sPopUpListen ;
function load_binary_resource(url) {
    var req;
    var blnreq=false;
    try 
    {
        req = new XMLHttpRequest(); /* e.g. Firefox */
        blnreq=true
    } catch(e){}

    if (!blnreq)
    {
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP");  /* some versions IE */
            blnreq=true
        } catch (e) {}
    }

    if (!blnreq)
    {                    
        try {
            req = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
        } catch (E) 
        {req = false;}
    }                      

    req.open('GET',url,false);
    //XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com]
    //req.overrideMimeType('text/plain; charset=x-user-defined');
    req.send(null);
    if (req.status != 200) return '';
    return req.responseText;
}
function fnGetDate()
{
     // Get today's current date.
            var now = new Date();
            // Array list of days.
            var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
            // Array list of months.
            var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
            // Calculate the number of the current day in the week.
            var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
            // Calculate four digit year.
            function fourdigits(number)	{
	            return (number < 1000) ? number + 1900 : number;
								            }
            // Join it all together
            today =  days[now.getDay()] + ", " +
                     months[now.getMonth()] + " " +
                     date + ", " +
                     (fourdigits(now.getYear())) ;
            var sMonthDay = months[now.getMonth()] + "_" + date
            var wikkilink = "http://en.wikipedia.org/wiki/" + sMonthDay + "?TB_iframe=true&amp;height=500&amp;width=750"
            // Print out the data.
            var aTag = "<a href='" + wikkilink + "' title='Today in History' class='smoothbox'>" + today + "</a>"
            //alert(aTag)
            return aTag
}
function ListenLive() 
{
      myleft = (screen.width)?(screen.width-520)/2:100;mytop=(screen.height)?(screen.height-278)/2:100;
      settings = 'top=' + mytop + ',left=' + myleft + ',width=520,height=278,location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,fullscreen=no,channelmode=0,directories=0,fullscreen=0,location= 0,menubar=0,resizable=0,scrollbars=0,status=0,titl ebar=0,toolbar=0'
      sPopUpListen = window.open('http://www.addate.com/SpiceRadio/listenlive.aspx','sPopUpListen', settings);
      sPopUpListen.focus();
}

function fnGotoEventURL(sVal1)
{
    
    if (sVal1=='' || sVal1=='0')
    {
        var sVal = document.getElementById("selKeyWord").selectedIndex;
        sVal1 = document.getElementById("selKeyWord").options[sVal].value;
        //alert(sVal1)
    }
    
    myleft = (screen.width)?(screen.width-300)/2:100;mytop=(screen.height)?(screen.height-200)/2:100;
    settings = 'top=0,left=0,location=no,directories=yes,menubar=yes,toolbar=yes,status=yes,scrollbars=yes,maximized=yes,resizable=yes,fullscreen=no'
    
    document.getElementById("selKeyWord").selectedIndex=0;
    if(sVal1 == "ADD")
    {
        var sURL = "http://www.addate.com/setupadsbyaddate/srAddNewKeyword.aspx?.fw=sr" ;
        //document.location.href = strURL ;
        sPopUpWin = window.open(sURL,"sPopUpWin",settings);
        sPopUpWin.focus();
    }
    else
    {
        sURL = "http://www.addate.com/setupadsbyaddate/ShowSearchURL.aspx?.ki=" + sVal1 + "&.fw=sr";
        if (sVal1 != 'none')
        {
            sPopUpWin = window.open(sURL,"sPopUpWin",settings);
            sPopUpWin.focus();
        }
        else
            return;
    }
}
function fnSearchKey(object1,object2)
{
    //alert("object2 :" + object2)
    var keypressed;
    if(object1 != null)
    {
        keypressed = object1 ;
    }
    if(object2 != null)
    {
        keypressed = object2;
    }
    
    //return;
    //var keypressed = event.keyCode;    
    var sKeyword = document.getElementById("txtSearch").value
    if(keypressed == 13)
    {
        //alert(sKeyword)
        var sformid=''
        try{sformid=document.forms(0).id;}catch(err){sformid=''};
        if (sformid=='frmSearchKeywords')
            frmSearchKeywords.submit();
        else
        {
            var sURL = "SearchResult.aspx?.kw=" + sKeyword ;
            window.location.href = sURL
        }
    }
    else
        return;
}

function showToolTip(e,text){
	if(document.all)e = event;
	
	var obj = document.getElementById('bubble_tooltip');
	var obj2 = document.getElementById('bubble_tooltip_content');

	obj2.innerHTML = text;
	obj.style.display = 'block';

	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	var leftPos = e.clientX - 100;
	if (screen.width==1280)
	leftPos = e.clientX - 278;
	if (screen.width==1024)
	leftPos = e.clientX - 150;
	
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos + 'px';
	obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
	//obj.style.top = e.clientY + 20 -1 + st + 'px';
	//obj.style.width='600px'
}	

function hideToolTip()
{
	document.getElementById('bubble_tooltip').style.display = 'none';
	
}

function fnRestrictUserInput(sID,length,sSpanId)
{
    /*************************************************************************************
    // Input : sID : Name of the textarea(HTML control) or multiline textbox(server control)
    // length : Length allowed to be entered in the textbox.
    *************************************************************************************/
    // 1. Get the value stored in the textarea
    var sText = document.getElementById(sID).value;
    
    // 2. Get the max length to be entered in the textbox
    var sMaxLength = new Number(length);
    
   /*************************************************************************************
    // 3.Clear the span innerhtml for any other values.Also works to clear the message 
    // when text overflows and then the message displayed is cleared when user presses 
    // delete key(again function is called on keypress event.
    *************************************************************************************/
    if (sSpanId != '')
    {
        document.getElementById(sSpanId).innerHTML = "";
    }
    
    /*************************************************************************************
    //Check if the length of the text in control is greater than the specified length
    *************************************************************************************/
    if(sText.length > sMaxLength)
    {
        /*************************************************************************************
        //If condition is true then,store only a length of maxlenngth characters in the control
        *************************************************************************************/
        //document.getElementById(sID).value = sText.substring(0,sMaxLength);
        
        event.returnValue = false;
        return false;
        //alert("Please enter only " + length + " charaters")
        /*************************************************************************************
        // Display appropriate error message in the span
        *************************************************************************************/
        if(sSpanId != '')
        {
            document.getElementById(sSpanId).innerHTML = "<font size=2 color=red class=LableFont>Please enter only " + length + " charaters</font>"
        }
    }
}

function LTrim(str) 
{
	for (var i=0; str.charAt(i)==" "; i++);
	return str.substring(i,str.length);
}
        	
function RTrim(str) 
{
	for (var i=str.length-1; str.charAt(i)==" "; i--);
	return str.substring(0,i+1);
}

function Trim(str)
{
	return LTrim(RTrim(str));
}	

function copy_clip(meintext)
{

if (meintext=='') return false;
if (window.clipboardData)
{

// the IE-manier
window.clipboardData.setData("Text", meintext);

// waarschijnlijk niet de beste manier om Moz/NS te detecteren;
// het is mij echter onbekend vanaf welke versie dit precies werkt:
}
else if (window.netscape)
{

// dit is belangrijk maar staat nergens duidelijk vermeld:
// you have to sign the code to enable this, or see notes below
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

// maak een interface naar het clipboard
var clip = Components.classes['@mozilla.org/widget/clipboard;1']
.createInstance(Components.interfaces.nsIClipboard);
if (!clip) return;

// maak een transferable
var trans = Components.classes['@mozilla.org/widget/transferable;1']
.createInstance(Components.interfaces.nsITransferable);
if (!trans) return;

// specificeer wat voor soort data we op willen halen; text in dit geval
trans.addDataFlavor('text/unicode');

// om de data uit de transferable te halen hebben we 2 nieuwe objecten
// nodig om het in op te slaan
var str = new Object();
var len = new Object();

var str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);

var copytext=meintext;

str.data=copytext;

trans.setTransferData("text/unicode",str,copytext.length*2);

var clipid=Components.interfaces.nsIClipboard;

if (!clip) return false;

clip.setData(trans,null,clipid.kGlobalClipboard);

}
//alert("Following info was copied to your clipboard:\n\n" + meintext);
return false;
}