﻿// JScript File


function mover(which)
{
	if(which != CurrentItem)
	{
		var obj;
		obj = document.getElementById('ob' + which);
		if(obj == null)
		    return;
		obj.style.visibility = 'visible';
		obj = document.getElementById('cb' + which);
		obj.style.visibility = 'visible';
		obj = document.getElementById('ctl00_lnk' + which);
		obj.style.color = '#71BD1F';
	}
}

function mout(which)
{
	if(which != CurrentItem)
	{
		var obj;
		obj = document.getElementById('ob' + which);
		if(obj == null)
		    return;			
		obj.style.visibility = 'hidden';
		obj = document.getElementById('cb' + which);
		obj.style.visibility = 'hidden';
		obj = document.getElementById('ctl00_lnk' + which);
		obj.style.color = 'green';
	}
}

function moverFooter(which)
{
	if(which != CurrentItem)
	{
		var obj;
		obj = document.getElementById('ob' + which);
		if(obj == null)
		    return;			
		obj.style.visibility = 'visible';
		document.body.style.cursor = 'hand';
		obj = document.getElementById('cb' + which);
		obj.style.visibility = 'visible';
		obj = document.getElementById('lnk' + which);
		//obj.style.fontWeight = 'bold';
		obj.style.color = '#71BD1F';
	}
}

function moutFooter(which)
{
	if(which != CurrentItem)
	{
		var obj;
		obj = document.getElementById('ob' + which);
		if(obj == null)
		    return;			
		obj.style.visibility = 'hidden';
		document.body.style.cursor = 'default';
		obj = document.getElementById('cb' + which);
		obj.style.visibility = 'hidden';
		obj = document.getElementById('lnk' + which);
		//obj.style.fontWeight = 'normal';
		obj.style.color = 'green';
	}
}	

function findBaseSite()
{
    var url, index, base, i;
    url = document.URL;		
    index = url.search("SliceWebSite");
    if(index != -1)
    {            
        //We're in development environment
        base = url.substr(0, (index + 12));
    }
    else
    {            
        index = -1;
        for(i = 0; i < 3; i++)
            index = url.indexOf("/", index + 1);
        base = url.substr(0, index);
    }
    return (base);
}

function PopUp(path, width, height, left, top)
{
	options = 'location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,'
	window.open(findBaseSite() + path,'_blank', options + 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
	return;
}
    
function SubValidate()
{        
    var base = findBaseSite();                           
    var textboxes, word = "";
    textboxes = FindElementByIdTag("txtSearch", "input");
    word = textboxes.value;
    if (word.length <= 0)
    {            
        ModalDialogShow('Please enter a search criteria<br/>', base + '/PopUps/Alert.aspx', 'width=208,height=100,left=600,top=300','');
        return(false);
    }
    else
    {            
        window.location = base + '/Admin/SubscriberSearch.aspx?Keyword=' + word;
        return(true);
    }
}

function FindElementByIdTag(id, tag)
{
    var i, tempid;
    var obj, col, found = false;
    obj = document.getElementById(id);
    if(obj != null)
        return(obj);
    
    if(tag == null)
        return(null);
    
    col = document.getElementsByTagName(tag);
    
    obj = null;
    for(i=0; i < col.length; i++)
    {
        tempid = col[i].id;
        tempid = tempid.substr(tempid.lastIndexOf('_') + 1);
        if(tempid == id)
            obj = col[i];
    }
    return(obj);
}

function onKey() 
{                
    if (window.event.keyCode == 13)
    {             
        SubValidate();                       
        event.returnValue = false;
        event.cancel = true;
    }         
}

