﻿var numOfCols = 2;
var colPBId = 'dvContainer';
var imagesLoc = '';
var loadingGif = 'sortie-loading.gif';
var closeGif = 'close-sortie.gif';
var refreshGif = 'refresh.gif';
var addSortiePopup = false;
var addSortCon = null;
var sortieCounter = 0;
var autoScrollSpeed = 4;
var dObjBordWidth = 1;
var nameOfCookie = 'myLot_index_sorties';
var sortieObjects = new Array();
var columnParentBox;
var aObjs = new Array();
var boxIndex = 0;
var atoScrlActv = false;
var dBAry = new Array();
var ddCntr = -1;
var dObj = false;
var dObjNxtSib = false;
var dObjPrnt = false;
var dstObj = false;
var mouse_x;
var mouse_y;
var el_x;
var el_y;
var rctDiv;
var okToMove = true;
var docHght = false;
var docScrollHght = false;
var opera = navigator.userAgent.toLowerCase().indexOf('opera')>=0?true:false;

function docelm(str){
    return document.getElementById(str);
}

function setCookie(name, value, days)
{
    if(days) {
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name)
{
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function saveBoxes()
{
    var divColumn1 = docelm("dvColumn1");
    var divColumn2 = docelm("dvColumn2");
    var tmpCT = "";
    
    var rowCount = 0;
    
    for(var i = 0; i < divColumn1.childNodes.length; i++)
    {
        rowCount++;
        var id = divColumn1.childNodes[i].id.replace(/[^0-9]/g,'');
        if(id)
        {
            tmpCT += dBAry[id]['boxType'] + ",";
            tmpCT += "1,";
            tmpCT += rowCount + ",";
            tmpCT += dBAry[id]['contentType'] + ",";
            tmpCT += dBAry[id]['numRows'] + ",";
            tmpCT += dBAry[id]['numRows2'] + ",";
            tmpCT += dBAry[id]['numRows3'] + "#";
            
        }
    }
    rowCount = 0;
    for(var i = 0; i < divColumn2.childNodes.length; i++)
    {
        rowCount++;
        var id = divColumn2.childNodes[i].id.replace(/[^0-9]/g,'');
        if(id)
        {
            tmpCT += dBAry[id]['boxType'] + ",";
            tmpCT += "2,";
            tmpCT += rowCount + ",";
            tmpCT += dBAry[id]['contentType'] + ",";
            tmpCT += dBAry[id]['numRows'] + ",";
            tmpCT += dBAry[id]['numRows2'] + ",";
            tmpCT += dBAry[id]['numRows3'] + "#";
            
        }
    }
    if(tmpCT.length > 0)
	    tmpCT = tmpCT.substring(0,tmpCT.length-1);
	
	var tmpPostData = tmpCT.replace(/,/g, ':');
	tmpPostData = tmpPostData.replace(/#/g,',');
	
	saveUserInfo(tmpPostData);
	setCookie(nameOfCookie, tmpCT, 365);
}

function saveUserInfo(postData)
{
    var aIndx = aObjs.length;
    aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/savesettings.aspx';
	aObjs[aIndx].setVar("theParams", postData);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
}

function autoScroll(direction,yPos)
{
	if(document.documentElement.scrollHeight>docScrollHght && direction>0)return;
	if(opera)return;
	window.scrollBy(0,direction);
	if(!dObj)return;

	if(direction<0){
		if(document.documentElement.scrollTop>0) dObj.style.top = (el_y - mouse_y + yPos + document.documentElement.scrollTop) + 'px';
		else atoScrlActv = false;
	}else{
		if(yPos>(docHght-50)) dObj.style.top = (el_y - mouse_y + yPos + document.documentElement.scrollTop) + 'px';
		else atoScrlActv = false;
	}
	if(atoScrlActv)setTimeout('autoScroll('+direction+',' + yPos + ')',5);
}

function initDragDropBox(e)
{
	ddCntr = 1;
	if(document.all)e = event;

	if (e.target) source = e.target;
		else if (e.srcElement) source = e.srcElement;
		if (source.nodeType == 3) // defeat Safari bug
			source = source.parentNode;

	if(source.tagName.toLowerCase()=='img' || source.tagName.toLowerCase()=='a' || source.tagName.toLowerCase()=='input' || source.tagName.toLowerCase()=='td' || source.tagName.toLowerCase()=='tr' || source.tagName.toLowerCase()=='table')return;

	mouse_x = e.clientX;
	mouse_y = e.clientY;
	var numericId = this.id.replace(/[^0-9]/g,'');
	if(numericId == ""){
	    for(var i = 1; i < dBAry.length; i++)
	    {
	        if(dBAry[i]['menuHeaderId'] == this.id){
	            numericId = i;
	            break;
	        }
	    }
	}
	el_x = getLeftPos(this.parentNode)/1;
	el_y = getTopPos(this.parentNode)/1 - document.documentElement.scrollTop;

	dObj = this.parentNode;

	docScrollHght = document.documentElement.scrollHeight + 100 + dObj.offsetHeight;

	if(dObj.nextSibling){
		dObjNxtSib = dObj.nextSibling;
		if(dObjNxtSib.tagName!='DIV'){
		    dObjNxtSib = dObjNxtSib.nextSibling;
		}
	}
	dObjPrnt = dBAry[numericId]['parentObj'];

	ddCntr = 0;
	initDragDropBoxTimer();
	return false;
}

function initDragDropBoxTimer()
{
	if(ddCntr>=0 && ddCntr<10){
		ddCntr++;
		setTimeout('initDragDropBoxTimer()',10);
		return;
	}
	if(ddCntr==10){
		//mouseoutBoxHeader(false,dObj);
	}
}

function moveDragableElement(e){
	if(document.all)e = event;
	if(ddCntr<10)return;

	if(document.all && e.button!=1 && !opera){
		stop_dragDropElement();
		return;
	}

	if(document.body!=dObj.parentNode){
	    if(dObj.parentNode != columnParentBox) {
		    dObj.style.width = (dObj.offsetWidth - (dObjBordWidth*2)) + 'px';
		    dObj.style.position = 'absolute';
		    dObj.style.textAlign = 'left';
			dObj.style.filter = 'alpha(opacity=60)';
			dObj.style.opacity = '0.6';
		    dObj.parentNode.insertBefore(rctDiv,dObj);
		    rctDiv.style.display='';
		    rctDiv.style.backgroundColor = '#dedede';
		    rctDiv.style.padding = '5px';
		    document.body.appendChild(dObj);

		    rctDiv.style.width = dObj.style.width;
		    rctDiv.style.height = (dObj.offsetHeight - (dObjBordWidth*2)) + 'px';
		}
	}
	
	if(e.clientY<50 || e.clientY>(docHght-50)){
		if(e.clientY<50 && !atoScrlActv){
			atoScrlActv = true;
			autoScroll((autoScrollSpeed*-1),e.clientY);
		}

		if(e.clientY>(docHght-50) && document.documentElement.scrollHeight<=docScrollHght && !atoScrlActv){
			atoScrlActv = true;
			autoScroll(autoScrollSpeed,e.clientY);
		}
	}else{
		atoScrlActv = false;
	}		
	var leftPos = e.clientX;
	var topPos = e.clientY + document.documentElement.scrollTop;

	dObj.style.left = (e.clientX - mouse_x + el_x) + 'px';
	dObj.style.top = (el_y - mouse_y + e.clientY + document.documentElement.scrollTop) + 'px';
	
	if(!okToMove)return;
	okToMove = false;

	dstObj = false;	
	rctDiv.style.display = 'none'; 
	
	var objFound = false;
	var tmpParentArray = new Array();
	
	if(!objFound){
		for(var no=1;no<dBAry.length;no++){
			if(dBAry[no]['obj']==dObj)continue;
			tmpParentArray[dBAry[no]['obj'].parentNode.id] = true;
			if(!objFound){
				var tmpX = getLeftPos(dBAry[no]['obj']);
				var tmpY = getTopPos(dBAry[no]['obj']);

				if(leftPos>tmpX && leftPos<(tmpX + dBAry[no]['obj'].offsetWidth) && topPos>(tmpY-20) && topPos<(tmpY + (dBAry[no]['obj'].offsetHeight/2))){
					dstObj = dBAry[no]['obj'];
					dstObj.parentNode.insertBefore(rctDiv,dBAry[no]['obj']);
					rctDiv.style.display = 'block';
					objFound = true;
					break;
				}

				if(leftPos>tmpX && leftPos<(tmpX + dBAry[no]['obj'].offsetWidth) && topPos>=(tmpY + (dBAry[no]['obj'].offsetHeight/2)) && topPos<(tmpY + dBAry[no]['obj'].offsetHeight)){
					objFound = true;
					if(dBAry[no]['obj'].nextSibling){
						dstObj = dBAry[no]['obj'].nextSibling;
						if(!dstObj.tagName){
						    if(dstObj.tagName != 'HR')dstObj = dstObj.nextSibling;
						    }
						if(dstObj!=rctDiv)dstObj.parentNode.insertBefore(rctDiv,dstObj);
					}else{
						dstObj = dBAry[no]['obj'].parentNode;
						dBAry[no]['obj'].parentNode.appendChild(rctDiv);
					}
					rctDiv.style.display = 'block';
					break;
				}

				if(!dBAry[no]['obj'].nextSibling && leftPos>tmpX && leftPos<(tmpX + dBAry[no]['obj'].offsetWidth)
				&& topPos>topPos>(tmpY + (dBAry[no]['obj'].offsetHeight))){
					dstObj = dBAry[no]['obj'].parentNode;
					dBAry[no]['obj'].parentNode.appendChild(rctDiv);
					rctDiv.style.display = 'block';
					objFound = true;
				}
			}
		}
	}

	if(!objFound){
		for(var no=1;no<=numOfCols;no++){
			if(!objFound){
				var obj = docelm('dvColumn' + no);

				var left = getLeftPos(obj)/1;

				var width = obj.offsetWidth;
				if(leftPos>left && leftPos<(left+width)){
					dstObj = obj;
					obj.appendChild(rctDiv);
					rctDiv.style.display='block';
					objFound=true;
				}
			}
		}
	}
	setTimeout('okToMove=true',5);
}

function stop_dragDropElement()
{
	if(ddCntr<10){
		ddCntr = -1
		return;
	}
	ddCntr = -1;
	dObj.style.filter = null;
	dObj.style.opacity = null;
	dObj.style.position = 'static';
	dObj.style.width = null;
	var numericId = dObj.id.replace(/[^0-9]/g,'');
	if(numericId == ""){
	    for(var i = 1; i < dBAry.length; i++)
	    {
	        if(dBAry[i]['obj'].id == dObj.id){
	            numericId = i;
	            break;
	        }
	    }
	}
	if(dstObj && dstObj.id!=dObj.id){
		if(dstObj.id.indexOf('dvColumn')>=0){
			dstObj.appendChild(dObj);
			dBAry[numericId]['parentObj'] = dstObj;
		}else{
			dstObj.parentNode.insertBefore(dObj,dstObj);
			dBAry[numericId]['parentObj'] = dstObj.parentNode;
		}						
	}else{
		if(dObjNxtSib){
			dObjPrnt.insertBefore(dObj,dObjNxtSib);
		}else{
			dObjPrnt.appendChild(dObj);
		}
	}
		
	atoScrlActv = false;
	rctDiv.style.display = 'none';
	dObj = false;
	dObjNxtSib = false;
	dstObj = false;
	
	setTimeout('saveBoxes()',100);

	docHght = document.documentElement.clientHeight;
}

function cancelSelectionEvent(e)
{
	if(document.all)e = event;
	
	if (e.target) source = e.target;
		else if (e.srcElement) source = e.srcElement;
		if (source.nodeType == 3) // defeat Safari bug
			source = source.parentNode;
	if(source.tagName.toLowerCase()=='input')return true;

	if(ddCntr>=0)return false; else return true;
}

function cancelEvent()
{
	return false;
}

function initEvents()
{
	document.body.onmousemove = moveDragableElement;
	document.body.onmouseup = stop_dragDropElement;
	document.body.onselectstart = cancelSelectionEvent;
	document.body.ondragstart = cancelEvent;
	docHght = document.documentElement.clientHeight;
}

function mouseoverBoxHeader()
{
	if(ddCntr==10)return;
	var id = this.id.replace(/[^0-9]/g,'');
	var span = docelm("spnEdit" + id);
	var refreshImg = docelm("imgRefresh" + id);
	var imgClose = docelm("imgClose" + id);
	if(span) {
	    span.style.display = '';
	    if(span.innerHTML == 'close edit'){
	        if(refreshImg)refreshImg.style.display = 'none';
	        var tmpImg = docelm("imgClose_" + id);
	        if(tmpImg){
	            if(tmpImg.style.display == ''){
	                if(span)span.style.display = 'none';
	            }
	        }
	    }else {
	        if(refreshImg)refreshImg.style.display = '';
	        if(imgClose)imgClose.style.display = '';
	    }
	}
}
function mouseoutBoxHeader(e,obj)
{
	if(!obj)obj=this;
	var id = obj.id.replace(/[^0-9]/g,'');
	var span = docelm("spnEdit" + id);
	if(span) if(span.innerHTML == 'edit')span.style.display = 'none';
	
	var refreshImg = docelm("imgRefresh" + id);
	if(refreshImg) refreshImg.style.display = 'none';

	var imgClose = docelm("imgClose" + id);
	if(imgClose) imgClose.style.display = 'none';
	
	if(span){
	    if(span.innerHTML == 'close edit'){
	        var tmpImg = docelm("imgClose_" + id);
	        if(tmpImg){
                if(tmpImg.style.display == ''){
                    if(span)span.style.display = 'none';
                }
            }
	    }
	}
}

function mouseoverBox()
{
	if(ddCntr==10)return;
	var id = this.id.replace(/[^0-9]/g,'');
	var span = docelm("plusMinus" + id);
	if(span) span.style.display = '';

	var span2 = docelm("plusMinus2_" + id);
	if(span2) span2.style.display = '';
}
function mouseoutBox(e,obj)
{
	if(!obj)obj=this;
	var id = obj.id.replace(/[^0-9]/g,'');
	var span = docelm("plusMinus" + id);
	if(span) span.style.display = 'none';

	var span2 = docelm("plusMinus2_" + id);
	if(span2) span2.style.display = 'none';
}

function getTopPos(inputObj)
{
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
  }
  return returnValue;
}

function getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
}

function reloadSortie(tmpIndex)
{
    switch(dBAry[tmpIndex]['boxType']) {
        case 1:
            rldWthrData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], false);
            break;
        case 2:
            rldAPData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], false);
            break;
        case 3:
            rldDiscData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], false);
    	    break;
        case 4:
            rldBlgData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], dBAry[tmpIndex]['numRows2'], false);
    	    break;
        case 5:
            rldIntCmboData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], dBAry[tmpIndex]['numRows2'], false);
    	    break;
        case 6:
            rldSprtCmbData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], dBAry[tmpIndex]['numRows2'], dBAry[tmpIndex]['numRows3'], false);
    	    break;
    	case 7:
    	    rldPvtMsgData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], false);
    	    break;
        }
}

function closeSortie(tmpIndex)
{
    var value = confirm('Do you wish to remove this sortie from your customized page?');
    
    if(value == true)
    {
        var obj = dBAry[tmpIndex]['obj'];
        obj.parentNode.removeChild(obj);
	    dBAry[tmpIndex]['boxState'] = 0;
        sortieCounter--;
        setTimeout('saveBoxes()',1000);
    }
}

function makeHeader(headText, editText, tmpIndex)
{
    var theHead = "";
    theHead += "<h6 style=\"float:left;\"><span id=\"spnHeaderText" + tmpIndex + "\">" + headText + "</span>&nbsp;<span id=\"imgLoad" + tmpIndex + "\" style=\"width:15px; height:15px;\" class=\"loadingHidden\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></h6>";
    theHead += "<div style=\"float:right;\"><img id=\"imgRefresh" + tmpIndex + "\" src=\"" + imagesLoc + refreshGif + "\" style=\"width:15px; height:15px; cursor:pointer; display:none;\" onclick=\"reloadSortie(" + tmpIndex + ")\" alt=\"refresh content\">&nbsp;&nbsp;";
    theHead += "<span id=\"spnEdit" + tmpIndex + "\" class=\"addedit2\" style=\" cursor:pointer; display:none;\" onclick=\"toggleEdit(" + tmpIndex + ", " + true + ");\">" + editText + "</span>&nbsp;&nbsp;";
    theHead += "<img id=\"imgClose" + tmpIndex + "\" src=\"" + imagesLoc + closeGif + "\" style=\"width:15px; height:15px; cursor:pointer; display:none;\" onclick=\"closeSortie(" + tmpIndex + ")\" alt=\"close sortie\"><img id=\"imgClose_" + tmpIndex + "\" src=\"" + imagesLoc + closeGif + "\" style=\"width:15px; height:15px; cursor:pointer; display:none;\" onclick=\"closeSortie(" + tmpIndex + ")\" alt=\"close sortie\"></div>";
    theHead += "<hr style=\"clear: both; visibility: hidden; height:0px;\"/>";
    
    return theHead;
}


function makeHeader2(headText, editText, tmpIndex)
{
    var theHead = "";
    theHead += "<h6 style=\"float:left;\"><span id=\"spnHeaderText" + tmpIndex + "\">" + headText + "</span>&nbsp;<span id=\"imgLoad" + tmpIndex + "\" style=\"width:15px; height:15px;\" class=\"loadingHidden\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></h6>";
    theHead += "<div style=\"float:right;\"><img id=\"imgRefresh" + tmpIndex + "\" src=\"" + imagesLoc + refreshGif + "\" style=\"width:15px; height:15px; cursor:pointer; display:none;\" onclick=\"reloadSortie(" + tmpIndex + ")\" alt=\"refresh content\">&nbsp;&nbsp;";
    theHead += "<span id=\"spnEdit" + tmpIndex + "\" class=\"addedit2\" style=\" cursor:pointer; display:none;\" onclick=\"editInterests(" + tmpIndex + ", " + true + ");\">" + editText + "</span>&nbsp;&nbsp;";
    theHead += "<img id=\"imgClose" + tmpIndex + "\" src=\"" + imagesLoc + closeGif + "\" style=\"width:15px; height:15px; cursor:pointer; display:none;\" onclick=\"closeSortie(" + tmpIndex + ")\" alt=\"close sortie\"><img id=\"imgClose_" + tmpIndex + "\" src=\"" + imagesLoc + closeGif + "\" style=\"width:15px; height:15px; cursor:pointer; display:none;\" onclick=\"closeSortie(" + tmpIndex + ")\" alt=\"close sortie\"></div>";
    theHead += "<hr style=\"clear: both; visibility: hidden; height:0px;\"/>";
    
    return theHead;
}

function makeHeaderStatic(headText, tmpIndex)
{
    var theHead = "";
    theHead += "<h6 style=\"float:left;\"><span id=\"spnHeaderText" + tmpIndex + "\">" + headText + "</span>&nbsp;<span id=\"imgLoad" + tmpIndex + "\" style=\"width:15px; height:15px;\" class=\"loadingHidden\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></h6>";
    theHead += "<div style=\"float:right;\"><img id=\"imgRefresh" + tmpIndex + "\" src=\"" + imagesLoc + refreshGif + "\" style=\"width:15px; height:15px; cursor:pointer; display:none;\" onclick=\"reloadSortie(" + tmpIndex + ")\" alt=\"refresh content\">&nbsp;&nbsp;";
    theHead += "</div>";
    theHead += "<hr style=\"clear: both; visibility: hidden; height:0px;\"/>";
    
    return theHead;
}

function editInterests(tmpIndex, doReload)
{
	closeEditSortie(tmpIndex);
//	switch(dBAry[tmpIndex]['boxType']) {
//        case 5:
//            rldIntCmboData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], dBAry[tmpIndex]['numRows2'], true);
//	        break;
//        case 6:
//            rldSprtCmbData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], dBAry[tmpIndex]['numRows2'], dBAry[tmpIndex]['numRows3'], false);
//	        break;
//        }
}

function toggleEdit(tmpIndex, doReload, showClose)
{
    var contentDiv = docelm("dvContent" + tmpIndex);
    var editDiv = docelm("dvEdit" + tmpIndex);
    var editSpan = docelm("spnEdit" + tmpIndex);
    var headerTextSpan = docelm("spnHeaderText" + tmpIndex);
    
    if(editDiv.style.display == '') {
        contentDiv.style.display = '';
        editDiv.style.display = 'none';
        var tmpImg = docelm("imgClose_" + tmpIndex);
        if(tmpImg) tmpImg.style.display = 'none';
        var tmpHeader = docelm("listFullName" + tmpIndex);
        if(tmpHeader) {
            var tmp = tmpHeader.value;
            tmpHeader.value = headerTextSpan.innerHTML;
            headerTextSpan.innerHTML = tmp;
        }
        if(doReload == true){
            editSpan.innerHTML = 'edit';
            contentDiv.innerHTML = 'loading...';
            switch(dBAry[tmpIndex]['boxType']) {
            case 1:
                rldWthrData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], true);
                break;
            case 2:
                rldAPData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], true);
                break;
            case 3:
                rldDiscData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], true);
    	        break;
            case 4:
                rldBlgData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], dBAry[tmpIndex]['numRows2'], true);
    	        break;
            case 5:
                rldIntCmboData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], dBAry[tmpIndex]['numRows2'], true);
    	        break;
            case 6:
                rldSprtCmbData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], dBAry[tmpIndex]['numRows2'], dBAry[tmpIndex]['numRows3'], false);
    	        break;
            }
        }
    }else {
        var tmpHeader = docelm("listFullName" + tmpIndex);
        if(tmpHeader) {
            var tmp = tmpHeader.value;
            tmpHeader.value = headerTextSpan.innerHTML;
            headerTextSpan.innerHTML = tmp;
        }
        if(dBAry[tmpIndex]['boxType'] == 6)
        {
            headerTextSpan.innerHTML = 'sports teams I cheer for';
        }
        contentDiv.style.display = 'none';
        editDiv.style.display = '';
        editSpan.innerHTML = 'close edit';
        editSpan.style.display = '';
        var refreshImg = docelm("imgRefresh" + tmpIndex);
	    if(refreshImg)refreshImg.style.display = 'none';
	    var imgClose = docelm("imgClose" + tmpIndex);
	    if(imgClose)imgClose.style.display = 'none';
        if(showClose) {
            if(showClose == true){
            var imgClose = docelm('imgClose_' + tmpIndex);
            if(imgClose) imgClose.style.display = '';
            editSpan.style.display = 'none';
            }
        }
    }
}

function updateNews(tmpIndex)
{
    var selectNews = docelm("selectNews" + tmpIndex);
    dBAry[tmpIndex]['contentType'] = selectNews.options[selectNews.selectedIndex].value;
    toggleEdit(tmpIndex, true);
}

function updateBlogs(tmpIndex)
{
    var selectBlogs = docelm("selectBlogs" + tmpIndex);
    dBAry[tmpIndex]['contentType'] = selectBlogs.options[selectBlogs.selectedIndex].value;
    toggleEdit(tmpIndex, true);
}

function updateDiscussions(tmpIndex)
{
    var selectDiscussions = docelm("selectDiscussions" + tmpIndex);
    dBAry[tmpIndex]['contentType'] = selectDiscussions.options[selectDiscussions.selectedIndex].value;
    toggleEdit(tmpIndex, true);
}

function saveWeather(tmpIndex)
{
    var tmpPref = docelm("selectTemp" + tmpIndex);
    var citySelect = docelm("selectCity" + tmpIndex);
    
    var aIndx = aObjs.length;
	aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/saveweather.aspx';
	aObjs[aIndx].onCompletion = function(){ toggleEdit(tmpIndex, true); };
	aObjs[aIndx].setVar("theParams", 'cc:' + citySelect.options[citySelect.selectedIndex].value + ',cn:' + citySelect.options[citySelect.selectedIndex].text + ',tp:' + tmpPref.options[tmpPref.selectedIndex].value);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
}

function showWeatherCountryData(aIndx,tmpIndex)
{
    var dvWeatherState = docelm("dvWeatherState" + tmpIndex);
    if(dvWeatherState){
        dvWeatherState.innerHTML = aObjs[aIndx].response;
        dvWeatherState.style.display = '';
    }
    var loadImage = docelm("imgLoad" + tmpIndex);
    if(loadImage) loadImage.className = 'loadingHidden';
}

function weatherStateChange(tmpIndex)
{
    var stateSelect = docelm("selectState" + tmpIndex);
    var countrySelect = docelm("selectCountry" + tmpIndex);
    var loadImage = docelm("imgLoad" + tmpIndex);
    if(loadImage) loadImage.className = 'loadingShow';
    
    var aIndx = aObjs.length;
	aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/getweathercountry.aspx';
	aObjs[aIndx].onCompletion = function(){ showWeatherCountryData(aIndx,tmpIndex); };
	aObjs[aIndx].setVar("theParams", 'cc:' + countrySelect.options[countrySelect.selectedIndex].value + ',st:' + stateSelect.options[stateSelect.selectedIndex].value + ',bx:' + tmpIndex);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
}

function weatherCountryChange(tmpIndex)
{
    var countrySelect = docelm("selectCountry" + tmpIndex);
    var loadImage = docelm("imgLoad" + tmpIndex);
    if(loadImage) loadImage.className = 'loadingShow';

    var aIndx = aObjs.length;
	aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/getweathercountry.aspx';
	aObjs[aIndx].onCompletion = function(){ showWeatherCountryData(aIndx,tmpIndex); };
	aObjs[aIndx].setVar("theParams", 'cc:' + countrySelect.options[countrySelect.selectedIndex].value + ',bx:' + tmpIndex);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
}

function rldWthrData(tmpIndex, contentType, numRows, saveBox)
{
	dBAry[tmpIndex]['numRows'] = numRows;
	dBAry[tmpIndex]['contentType'] = contentType;
    var loadImage = docelm("imgLoad" + tmpIndex);
    if(loadImage) loadImage.className = 'loadingShow';

	if(saveBox == true)setTimeout('saveBoxes()',1000);
	
    var aIndx = aObjs.length;
	aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/getweather.aspx';
	aObjs[aIndx].onCompletion = function(){ showWeatherData(aIndx,tmpIndex); };
	aObjs[aIndx].setVar("theParams", 'bx:' + tmpIndex);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
}

function showWeatherData(aIndx,tmpIndex)
{
    var boxDiv = dBAry[tmpIndex]['obj'];
    
    var obj = null;
    var objHead = null;
    var objEdit = null;
    objHead = boxDiv.childNodes[0];
    obj = boxDiv.childNodes[1];
    objEdit = boxDiv.childNodes[2];
    
    if(obj != null) {
	    var apData = aObjs[aIndx].responseXML;
	    
	    var currentCity = apData.getElementsByTagName('currentCity');
	    var weatherData = apData.getElementsByTagName('weatherData');
	    var configData = apData.getElementsByTagName('config');

	    obj.innerHTML = weatherData[0].firstChild.nodeValue;
	    
	    objEdit.innerHTML = configData[0].firstChild.nodeValue;
	    
	    if(objHead != null) objHead.innerHTML = makeHeader(currentCity[0].firstChild.nodeValue, "edit", tmpIndex);
	}
    dBAry[tmpIndex]['heightOfBox'] = boxDiv.clientHeight;
}

function showActivityData(aIndx,tmpIndex)
{
    var boxDiv = dBAry[tmpIndex]['obj'];
    
    var obj = null;
    var objHead = null;
    var objEdit = null;
    objHead = boxDiv.childNodes[0];
    obj = boxDiv.childNodes[1];
    objEdit = boxDiv.childNodes[2];
    
    if(obj != null) {
	    var apData = aObjs[aIndx].responseXML;
	    
	    var activityData = apData.getElementsByTagName('data');

	    obj.innerHTML = activityData[0].firstChild.nodeValue;
	    	    
	    if(objHead != null) objHead.innerHTML = makeHeaderStatic("activity", tmpIndex);
	}
    dBAry[tmpIndex]['heightOfBox'] = boxDiv.clientHeight;
}

function rldAPData(tmpIndex, contentType, numRows, saveBox)
{
	dBAry[tmpIndex]['numRows'] = numRows;
	dBAry[tmpIndex]['contentType'] = contentType;
    var loadImage = docelm("imgLoad" + tmpIndex);
    if(loadImage) loadImage.className = 'loadingShow';

	if(saveBox == true)setTimeout('saveBoxes()',1000);
	
    var aIndx = aObjs.length;
	aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/getap.aspx';
	aObjs[aIndx].onCompletion = function(){ showAPData(aIndx,tmpIndex); };
	aObjs[aIndx].setVar("theParams", 'cc:' + contentType + ',n:' + numRows + ',bx:' + tmpIndex);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
}

function showAPData(aIndx,tmpIndex)
{
    var boxDiv = dBAry[tmpIndex]['obj'];
    
    var obj = null;
    var objHead = null;
    var objEdit = null;
    objHead = boxDiv.childNodes[0];
    obj = boxDiv.childNodes[1];
    objEdit = boxDiv.childNodes[2];
    
    if(obj != null) {
	    var apData = aObjs[aIndx].responseXML;
	    
	    var apHeadlines = apData.getElementsByTagName('ap_headline');
	    
	    var list = "<ul class=\"apUL\">";
	    var apImage = "";
	    var plusMinus = "";
	    var newsCat = "";
	    var editText = "";
	    for(var i = 0; i < apHeadlines.length; i++)
	    {
	        var contentId = 0;
	        var headline = "";
	        var imageDiv = "";
	        var totalAns = 0;
	        
	        for(var j = 0; j < apHeadlines[i].childNodes.length; j++)
	        {
	            if(apHeadlines[i].childNodes[j].nodeName == "headline") {
	                headline = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "contentID") {
	                contentId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "imageDIV") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    imageDiv = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "ContentDescription") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    newsCat = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "config") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    editText = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "TotalAnswers") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    totalAns = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }
	        }
	        if(i == 0) if(imageDiv != "") apImage = imageDiv;
	        	        
	        if(i == 0){
	            if(objEdit != null) objEdit.innerHTML = editText;
	            list += "<li style=\"font-weight: bold; list-style-type:none;\"><a href=\"w/newsarticle/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	        }else list += "<li><a href=\"w/newsarticle/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	    }
	    list += "</ul>";
	    var itsCapped = false;
	    
	    if(apHeadlines.length < dBAry[tmpIndex]['numRows']) itsCapped = true;
	    if(apHeadlines.length > 1 && (apHeadlines.length < 25) && (!itsCapped))
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldAPData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']+1) + "," + true + ");\">+</span>&nbsp;<span style=\"cursor:pointer;\" onclick=\"rldAPData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']-1) + "," + true + ");\">-</span>";
	    }else if(apHeadlines.length == 1 && (apHeadlines.length < 25) && (!itsCapped))
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldAPData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']+1) + "," + true + ");\">+</span>";
	    }else
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldAPData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']-1) + "," + true + ");\">-</span>";
	    }
	    
	    var moreLink = '';
	    if(dBAry[tmpIndex]['contentType'] == 10001){
	        moreLink = "w/news/hotnews.aspx";
	    }else
	    {
	        moreLink = "w/news/recent.aspx?cat=" + dBAry[tmpIndex]['contentType'];
	    }
	    
	    obj.innerHTML ="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"width:90px;\" valign=\"top\" align=\"center\">" + apImage + "</td><td valign=\"top\"><div style=\"float:left;\">" + list + "</div></td></tr></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"height:16px;\" class=\"homemore\">»&nbsp;<a href=\"" + moreLink + "\">more " + newsCat + "</a></td><td class=\"arrows\" align=\"right\"><div id=\"plusMinus" + tmpIndex + "\" style=\"display:none;\">" + plusMinus + "</div></td></tr></table>";
	    if(objHead != null) {
	        objHead.innerHTML = makeHeader(newsCat, "edit", tmpIndex);
	    }
	}
    dBAry[tmpIndex]['heightOfBox'] = boxDiv.clientHeight;
}

function rldDiscData(tmpIndex, contentType, numRows, saveBox)
{
	dBAry[tmpIndex]['numRows'] = numRows;
	dBAry[tmpIndex]['contentType'] = contentType;
    var loadImage = docelm("imgLoad" + tmpIndex);
    if(loadImage) loadImage.className = 'loadingShow';

	if(saveBox == true) setTimeout('saveBoxes()',1000);
	
    var aIndx = aObjs.length;
	aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/getdiscussions.aspx';
	aObjs[aIndx].onCompletion = function(){ showDiscussionData(aIndx,tmpIndex); };
	aObjs[aIndx].setVar("theParams", 'dt:' + contentType + ',n:' + numRows + ',bx:' + tmpIndex);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
}

function rldPvtMsgData(tmpIndex, contentType, numRows, saveBox)
{
	dBAry[tmpIndex]['numRows'] = numRows;
	dBAry[tmpIndex]['contentType'] = contentType;
    var loadImage = docelm("imgLoad" + tmpIndex);
    if(loadImage) loadImage.className = 'loadingShow';

	if(saveBox == true) setTimeout('saveBoxes()',1000);
	
    var aIndx = aObjs.length;
	aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/getpm.aspx';
	aObjs[aIndx].onCompletion = function(){ showPrivateMessagesData(aIndx,tmpIndex); };
	aObjs[aIndx].setVar("theParams", 'n:' + numRows + ',bx:' + tmpIndex);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
}

function showPrivateMessagesData(aIndx,tmpIndex)
{
    var boxDiv = dBAry[tmpIndex]['obj'];
    
    var obj = null;
    var objHead = null;
    var objEdit = null;
    objHead = boxDiv.childNodes[0];
    obj = boxDiv.childNodes[1];
    objEdit = boxDiv.childNodes[2];
    
    if(obj != null) {
	    var newsCat = "";
	    var editText = "";
	    var newsCatLink = "";
	    
	    var apData = aObjs[aIndx].responseXML;
	    var apHeadlines = apData.getElementsByTagName('messages');
	    
	    var list = "<ul class=\"disUL\">";
	    var apImage = "";
	    var plusMinus = "";
	    var totalQuestions = 0;
	    for(var i = 0; i < apHeadlines.length; i++)
	    {
	        var contentId = 0;
	        var headline = "";
	        var imageDiv = "";
	        var totalAns = 0;
	        var userName = "";
	        
	        for(var j = 0; j < apHeadlines[i].childNodes.length; j++)
	        {
	            if(apHeadlines[i].childNodes[j].nodeName == "title") {
	                headline = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "id") {
	                contentId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "imageDIV") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    imageDiv = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "TotalAnswers") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    totalAns = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "totalQuestions") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    totalQuestions = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "username") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    userName = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }
	        }
	        if(i == 0) if(imageDiv != "") apImage = imageDiv;
	        
	        if(i == 0){
	            if(objEdit != null) objEdit.innerHTML = editText;
	            if(apHeadlines.length >=5) {
	                list += "<li style=\"font-weight: bold; list-style-type:none;\"><a href=\"nr/messagesview.aspx?id=" + contentId + "\">" + headline + "</a> (" + totalAns + ")</li>";
	            }else {
	                list += "<li style=\"font-weight: bold; list-style-type:none;\"><a href=\"/" + userName + "\">" + userName + "</a>:&nbsp;<a href=\"nr/messagesview.aspx?id=" + contentId + "\">" + headline + "</a> (" + totalAns + ")</li>";
	            }
	        }else list += "<li><a href=\"" + userName + "\">" + userName + "</a>:&nbsp;<a href=\"nr/messagesview.aspx?id=" + contentId + "\">" + headline + "</a> (" + totalAns + ")</li>";
	    }
	    list += "</ul>";
	    
	    if(totalQuestions > 25) totalQuestions = 25;
	    
	    if(apHeadlines.length > 1 && apHeadlines.length < totalQuestions)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldPvtMsgData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']+1) + "," + true + ");\">+</span>&nbsp;<span style=\"cursor:pointer;\" onclick=\"rldPvtMsgData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']-1) + "," + true + ");\">-</span>";
	    }else if(apHeadlines.length == 1 && apHeadlines.length < totalQuestions)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldPvtMsgData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']+1) + "," + true + ");\">+</span>";
	    }else if(apHeadlines.length > 0 && apHeadlines.length > 1)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldPvtMsgData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']-1) + "," + true + ");\">-</span>";
	    }
	    
	    if(totalQuestions != 0){
	        newsCat = "messages (" + totalQuestions + ")";
	    }else {
	        newsCat = "messages";
	        list = "You do not have any new private messages at this time."
	        boxDiv.style.display = 'none';
	    }
	    newsCatLink = "http://www.mylot.com/nr/messages.aspx?mv=5";
	    
	    obj.innerHTML ="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"width:90px;\" valign=\"top\" align=\"center\">" + apImage + "</td><td valign=\"top\"><div style=\"float:left;\">" + list + "</div></td></tr></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"height:16px;\" valign=\"bottom\" class=\"homemore\">»&nbsp;<a href=\"" + newsCatLink + "\">goto your messages</a></td><td align=\"right\" valign=\"bottom\"><div id=\"plusMinus" + tmpIndex + "\" class=\"arrows\" style=\"display:none;\">" + plusMinus + "</div></td></tr></table>";
	    if(objHead != null) objHead.innerHTML = makeHeaderStatic(newsCat + "&nbsp;<span class=\"homemore\"><a href=\"nr/newmessage.aspx\">new</a></span>", "", tmpIndex);
	}
    dBAry[tmpIndex]['heightOfBox'] = boxDiv.clientHeight;
}

function showDiscussionData(aIndx,tmpIndex)
{
    var boxDiv = dBAry[tmpIndex]['obj'];
    
    var obj = null;
    var objHead = null;
    var objEdit = null;
    objHead = boxDiv.childNodes[0];
    obj = boxDiv.childNodes[1];
    objEdit = boxDiv.childNodes[2];
    
    if(obj != null) {
	    var apData = aObjs[aIndx].responseXML;
	    
	    var apHeadlines = apData.getElementsByTagName('heading');
	    
	    var newsCat = "";
	    var editText = "";
	    var newsCatLink = "";
	    if(apHeadlines.length > 0)
	    {
	        for(var j = 0; j < apHeadlines[0].childNodes.length; j++)
	        {
	            if(apHeadlines[0].childNodes[j].nodeName == "discussionCat") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    newsCat = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[0].childNodes[j].nodeName == "discussionCatLink") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    newsCatLink = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[0].childNodes[j].nodeName == "config") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    editText = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }
	        }
	    }
	    
	    var apHeadlines = apData.getElementsByTagName('discussions');
	    
	    var list = "<ul class=\"disUL\">";
	    var apImage = "";
	    var plusMinus = "";
	    if(apHeadlines.length == 0 && (dBAry[tmpIndex]['contentType'] == 3 || dBAry[tmpIndex]['contentType'] == 9 )) boxDiv.style.display = 'none';
	    for(var i = 0; i < apHeadlines.length; i++)
	    {
	        var contentId = 0;
	        var headline = "";
	        var imageDiv = "";
	        var totalAns = 0;
	        var listId = 0;
	        var itemId = 0;
	        var itemName = "";
	        var friendName = "";
	        
	        for(var j = 0; j < apHeadlines[i].childNodes.length; j++)
	        {
	            if(apHeadlines[i].childNodes[j].nodeName == "Title") {
	                headline = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "ID") {
	                contentId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "imageDIV") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    imageDiv = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "TotalAnswers") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    totalAns = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "listID") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    listId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "itemID") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    itemId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "itemName") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    itemName = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "username") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    friendName = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }
	        }
	        if(i == 0) if(imageDiv != "") apImage = imageDiv;
	        
	        var interestLink = "";
	        if(i == 0){
				if(listId != 0) {
					interestLink = "<a href=\"w/lists/" + listId + "_" + itemId + "/default.aspx\">" + itemName + "</a> : ";
				}
	            list += "<li style=\"font-weight: bold; list-style-type:none;\">" + interestLink + "<a href=\"w/discussions/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	        }else
	        {
				var discType = dBAry[tmpIndex]['contentType'];
				if(parseInt(discType) == 9)
				{
					interestLink = "<a href=\"" + friendName + "\">" + friendName + "</a> : ";
				}
				if(listId != 0) {
					interestLink = "<a href=\"w/lists/" + listId + "_" + itemId + "/default.aspx\">" + itemName + "</a> : ";
				}
				list += "<li>" + interestLink + "<a href=\"w/discussions/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	        }
	    }
	    list += "</ul>";
	    if(apHeadlines.length > 1 && apHeadlines.length < 25)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldDiscData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']+1) + "," + true + ");\">+</span>&nbsp;<span style=\"cursor:pointer;\" onclick=\"rldDiscData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']-1) + "," + true + ");\">-</span>";
	    }else if(apHeadlines.length == 1 && apHeadlines.length < 25)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldDiscData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']+1) + "," + true + ");\">+</span>";
	    }else
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldDiscData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']-1) + "," + true + ");\">-</span>";
	    }
	    obj.innerHTML ="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"width:90px;\" valign=\"top\" align=\"center\">" + apImage + "</td><td valign=\"top\"><div style=\"float:left;\">" + list + "</div></td></tr></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"height:16px;\" valign=\"bottom\" class=\"homemore\">»&nbsp;<a href=\"" + newsCatLink + "\">more " + newsCat + "</a></td><td valign=\"bottom\" align=\"right\"><div id=\"plusMinus" + tmpIndex + "\" class=\"arrows\" style=\"display:none;\">" + plusMinus + "</div></td></tr></table>";
	    if(dBAry[tmpIndex]['contentType'] == 3){
	        if(objHead != null) objHead.innerHTML = makeHeader(newsCat + "&nbsp;<span class=\"homemore\"><a href=\"nr/selectinterest.aspx\">new</a></span>", "edit", tmpIndex);
	    }
	    else {
	        if(objHead != null) objHead.innerHTML = makeHeader(newsCat, "edit", tmpIndex);
	    }
	    if(objEdit != null) objEdit.innerHTML = editText;
	}
    dBAry[tmpIndex]['heightOfBox'] = boxDiv.clientHeight;
}

function rldBlgData(tmpIndex, contentType, numRows, numRows2, saveBox)
{
	dBAry[tmpIndex]['numRows'] = numRows;
	dBAry[tmpIndex]['numRows2'] = numRows2;
	dBAry[tmpIndex]['contentType'] = contentType;
    var loadImage = docelm("imgLoad" + tmpIndex);
    if(loadImage) loadImage.className = 'loadingShow';

	if(saveBox == true) setTimeout('saveBoxes()',1000);
	
    var aIndx = aObjs.length;
	aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/getblogs.aspx';
	aObjs[aIndx].onCompletion = function(){ showBlogData(aIndx,tmpIndex); };
	aObjs[aIndx].setVar("theParams", 'bt:' + contentType + ',n:' + numRows + ',bi:' + numRows2 + ',bx:' + tmpIndex);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
}

function showBlogData(aIndx,tmpIndex)
{
    var boxDiv = dBAry[tmpIndex]['obj'];
    
    var obj = null;
    var objHead = null;
    objHead = boxDiv.childNodes[0];
    obj = boxDiv.childNodes[1];
    objEdit = boxDiv.childNodes[2];
    if(obj != null) {
	    var apData = aObjs[aIndx].responseXML;
	    
	    var apHeadlines = apData.getElementsByTagName('heading');
	    
	    var newsCat = "";
	    var editText = "";
	    var newsCatLink = "";
	    if(apHeadlines.length > 0)
	    {
	        for(var j = 0; j < apHeadlines[0].childNodes.length; j++)
	        {
	            if(apHeadlines[0].childNodes[j].nodeName == "BlogTitle") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    newsCat = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[0].childNodes[j].nodeName == "config") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    editText = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[0].childNodes[j].nodeName == "linkto") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    newsCatLink = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }
	        }
	    }
	    if(objHead != null) objHead.innerHTML = makeHeader(newsCat, "edit", tmpIndex);
	    if(objEdit != null) objEdit.innerHTML = editText;

	    apHeadlines = apData.getElementsByTagName('discussions');
	    if(apHeadlines.length == 0 && dBAry[tmpIndex]['contentType'] == 1) boxDiv.style.display = 'none';
	    var list = "<ul class=\"apUL\">";
	    var apImage = "";
	    var plusMinus = "";
	    var totalQuestions = 0;
	    var totalAns = 0;
	    for(var i = 0; i < apHeadlines.length; i++)
	    {
	        var contentId = 0;
	        var headline = "";
	        var imageDiv = "";
	        var totalAns = 0;
	        var itemName = "";
	        var itemId = 0;
	        var listId = 0;
	        
	        for(var j = 0; j < apHeadlines[i].childNodes.length; j++)
	        {
	            if(apHeadlines[i].childNodes[j].nodeName == "Headline") {
	                headline = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "ContentID") {
	                contentId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "imageDIV") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    imageDiv = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "BlogTitleShort") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    itemName = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "BlogID") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    itemId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "TotalRecords") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    totalQuestions = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "TotalAnswers") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    totalAns = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }
	        }
	        if(i == 0) if(imageDiv != "")  apImage = imageDiv;
	        
	        if(i == 0) list += "<li style=\"font-weight: bold; list-style-type:none;\"><a href=\"w/blogshome/" + itemId + ".aspx\">" + itemName + "</a>: <a href=\"w/blogarticle/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	        else list += "<li><a href=\"w/blogshome/" + itemId + ".aspx\">" + itemName + "</a>: <a href=\"w/blogarticle/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	    }
	    list += "</ul>";
	    
	    if(totalQuestions > 25) totalQuestions = 25;
	    
	    if(apHeadlines.length > 1 && apHeadlines.length < totalQuestions)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldBlgData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']+1) + "," + dBAry[tmpIndex]['numRows2'] + "," + true + ");\">+</span>&nbsp;<span style=\"cursor:pointer;\" onclick=\"rldBlgData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']-1) + "," + dBAry[tmpIndex]['numRows2'] + "," + true + ");\">-</span>";
	    }else if(apHeadlines.length == 1 && apHeadlines.length < totalQuestions)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldBlgData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']+1) + "," + dBAry[tmpIndex]['numRows2'] + "," + true + ");\">+</span>";
	    }else if(apHeadlines.length > 0 && apHeadlines.length > 1)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldBlgData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']-1) + "," + dBAry[tmpIndex]['numRows2'] + "," + true + ");\">-</span>";
	    }
	    obj.innerHTML ="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"width:90px;\" valign=\"top\" align=\"center\">" + apImage + "</td><td valign=\"top\"><div style=\"float:left;\">" + list + "</div></td></tr></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"height:16px;\" class=\"homemore\">»&nbsp;<a href=\"" + newsCatLink + "\">more " + newsCat + "</a></td><td class=\"arrows\" align=\"right\"><div id=\"plusMinus" + tmpIndex + "\" style=\"display:none;\">" + plusMinus + "</div></td></tr></table>";
	}
    dBAry[tmpIndex]['heightOfBox'] = boxDiv.clientHeight;
}

function rldIntCmboData(tmpIndex, contentType, numRows, numRows2, saveBox)
{
	dBAry[tmpIndex]['numRows'] = numRows;
	dBAry[tmpIndex]['numRows2'] = numRows2;
	dBAry[tmpIndex]['contentType'] = contentType;
    var loadImage = docelm("imgLoad" + tmpIndex);
    if(loadImage) loadImage.className = 'loadingShow';
	
	if(saveBox == true) setTimeout('saveBoxes()',1000);
	
    var aIndx = aObjs.length;
	aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/getinterestsblock.aspx';
	aObjs[aIndx].onCompletion = function(){ showInterestsComboData(aIndx,tmpIndex); };
	aObjs[aIndx].setVar("theParams", 'iid:' + contentType + ',n:' + numRows + ',n2:' + numRows2 + ',bx:' + tmpIndex);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
}

function showInterestsComboData(aIndx,tmpIndex)
{
    var boxDiv = dBAry[tmpIndex]['obj'];
    
    var obj = null;
    var objHead = null;
    objHead = boxDiv.childNodes[0];
    obj = boxDiv.childNodes[1];
    objEdit = boxDiv.childNodes[2];
    if(obj != null) {
	    var apData = aObjs[aIndx].responseXML;
	    
	    var apHeadlines = apData.getElementsByTagName('heading');
	    
	    var newsCat = "";
	    var editText = "";
	    var newsCatFull = "";
	    var stayInEdit = 0;
	    if(apHeadlines.length > 0)
	    {
	        for(var j = 0; j < apHeadlines[0].childNodes.length; j++)
	        {
	            if(apHeadlines[0].childNodes[j].nodeName == "ListName") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    newsCat = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[0].childNodes[j].nodeName == "config") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    editText = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[0].childNodes[j].nodeName == "listFullName") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    newsCatFull = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[0].childNodes[j].nodeName == "moreInterests") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    stayInEdit = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }
	        }
	    }
	    if(objHead != null) objHead.innerHTML = makeHeader2(newsCat, "edit", tmpIndex);
	    if(objEdit != null) objEdit.innerHTML = editText + '<input type="hidden" id="listFullName' + tmpIndex + '" value="' + newsCatFull + '">';
	    
	    apHeadlines = apData.getElementsByTagName('discussions');
	    var list = "<ul class=\"apUL\">";
	    var apImage = "";
	    var plusMinus = "";
	    var totalQuestions = 0;
	    var totalAns = 0;
	    for(var i = 0; i < apHeadlines.length; i++)
	    {
	        var contentId = 0;
	        var headline = "";
	        var imageDiv = "";
	        var totalAns = 0;
	        var itemName = "";
	        var itemId = 0;
	        var listId = 0;
	        
	        for(var j = 0; j < apHeadlines[i].childNodes.length; j++)
	        {
	            if(apHeadlines[i].childNodes[j].nodeName == "Title") {
	                headline = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "ID") {
	                contentId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "imageDIV") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    imageDiv = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "itemname") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    itemName = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "itemid") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    itemId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "listid") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    listId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "TotalQuestions") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    totalQuestions = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "TotalAnswers") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    totalAns = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }
	        }
	        if(i == 0) if(imageDiv != "") apImage = imageDiv;
	        if(i == 0) list += "<li style=\"font-weight: bold; list-style-type:none;\"><a href=\"w/lists/" + listId + "_" + itemId + "/default.aspx\">" + itemName + "</a>: <a href=\"w/discussions/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	        else list += "<li><a href=\"w/lists/" + listId + "_" + itemId + "/default.aspx\">" + itemName + "</a>: <a href=\"w/discussions/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	    }
	    list += "</ul>";
	    
	    if(totalQuestions > 25) totalQuestions = 25;
	    
	    if(apHeadlines.length > 1 && apHeadlines.length < totalQuestions)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldIntCmboData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']+1) + "," + dBAry[tmpIndex]['numRows2'] + "," + true + ");\">+</span>&nbsp;<span style=\"cursor:pointer;\" onclick=\"rldIntCmboData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']-1) + "," + dBAry[tmpIndex]['numRows2'] + "," + true + ");\">-</span>";
	    }else if(apHeadlines.length == 1 && apHeadlines.length < totalQuestions)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldIntCmboData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']+1) + "," + dBAry[tmpIndex]['numRows2'] + "," + true + ");\">+</span>";
	    }else if(apHeadlines.length > 0 && apHeadlines.length > 1)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldIntCmboData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']-1) + "," + dBAry[tmpIndex]['numRows2'] + "," + true + ");\">-</span>";
	    }
	    obj.innerHTML ="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"width:90px;\" valign=\"top\" align=\"center\">" + apImage + "</td><td valign=\"top\"><div style=\"float:left;\">" + list + "</div></td></tr></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"height:16px;\" class=\"homemore\">»&nbsp;<a href=\"w/list/" + dBAry[tmpIndex]['contentType'] + ".aspx\">more " + newsCat + " discussions</a></td><td class=\"arrows\" align=\"right\"><div id=\"plusMinus" + tmpIndex + "\" style=\"display:none;\">" + plusMinus + "</div></td></tr></table>";
	    
	    // do content
	    apHeadlines = apData.getElementsByTagName('content');
	    
	    if(apHeadlines.length > 0){
	        list = "<ul class=\"apUL\">";
	        apImage = "";
	        plusMinus = "";
	        totalQuestions = 0;
	        totalAns = 0;
	        for(var i = 0; i < apHeadlines.length; i++)
	        {
	            var contentId = 0;
	            var headline = "";
	            var imageDiv = "";
	            var totalAns = 0;
	            var itemName = "";
	            var itemId = 0;
	            var listId = 0;
    	        
	            for(var j = 0; j < apHeadlines[i].childNodes.length; j++)
	            {
	                if(apHeadlines[i].childNodes[j].nodeName == "Headline") {
	                    headline = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }else if(apHeadlines[i].childNodes[j].nodeName == "ContentID") {
	                    contentId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }else if(apHeadlines[i].childNodes[j].nodeName == "imageDIV") {
	                    if(apHeadlines[i].childNodes[j].firstChild)
	                        imageDiv = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }else if(apHeadlines[i].childNodes[j].nodeName == "BlogTitle") {
	                    if(apHeadlines[i].childNodes[j].firstChild)
	                        itemName = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }else if(apHeadlines[i].childNodes[j].nodeName == "BlogId") {
	                    if(apHeadlines[i].childNodes[j].firstChild)
	                        itemId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }else if(apHeadlines[i].childNodes[j].nodeName == "TotalRecords") {
	                    if(apHeadlines[i].childNodes[j].firstChild)
	                        totalQuestions = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }else if(apHeadlines[i].childNodes[j].nodeName == "TotalAnswers") {
	                    if(apHeadlines[i].childNodes[j].firstChild)
	                        totalAns = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }
	            }
	            if(i == 0) if(imageDiv != "") apImage = imageDiv;
	            if(i == 0) list += "<li style=\"font-weight: bold; list-style-type:none;\"><a href=\"w/blogshome/" + itemId + ".aspx\">" + itemName + "</a>: <a href=\"w/blogarticle/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	            else list += "<li><a href=\"w/blogshome/" + itemId + ".aspx\">" + itemName + "</a>: <a href=\"w/blogarticle/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	        }
	        list += "</ul>";
    	    
	        if(totalQuestions > 25) totalQuestions = 25;
    	    
	        if(apHeadlines.length > 1 && apHeadlines.length < totalQuestions)
	        {
	            plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldIntCmboData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + dBAry[tmpIndex]['numRows'] + "," + (dBAry[tmpIndex]['numRows2']+1) + "," + true + ");\">+</span>&nbsp;<span style=\"cursor:pointer;\" onclick=\"rldIntCmboData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + dBAry[tmpIndex]['numRows'] + "," + (dBAry[tmpIndex]['numRows2']-1) + "," + true + ");\">-</span>";
	        }else if(apHeadlines.length == 1 && apHeadlines.length < totalQuestions)
	        {
	            plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldIntCmboData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + dBAry[tmpIndex]['numRows'] + "," + (dBAry[tmpIndex]['numRows2']+1) + "," + true + ");\">+</span>";
	        }else if(apHeadlines.length > 0 && apHeadlines.length > 1)
	        {
	            plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldIntCmboData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + dBAry[tmpIndex]['numRows'] + "," + (dBAry[tmpIndex]['numRows2']-1) + "," + true + ");\">-</span>";
	        }
	        obj.innerHTML +="<br /><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"width:90px;\" valign=\"top\" align=\"center\">" + apImage + "</td><td valign=\"top\"><div style=\"float:left;\">" + list + "</div></td></tr></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"height:16px;\" class=\"homemore\">»&nbsp;<a href=\"w/blogs/interest/" + dBAry[tmpIndex]['contentType'] + "/1.aspx\">more " + newsCat + " blog articles</a></td><td class=\"arrows\" align=\"right\"><div id=\"plusMinus2_" + tmpIndex + "\" style=\"display:none;\">" + plusMinus + "</div></td></tr></table>";
	    }
	}
    dBAry[tmpIndex]['heightOfBox'] = boxDiv.clientHeight;
    if(objEdit.style.display == '') toggleEdit(tmpIndex, false);
    if(stayInEdit == 1) toggleEdit(tmpIndex, false, true);
}

function rldSprtCmbData(tmpIndex, contentType, numRows, numRows2, numRows3, saveBox)
{
	dBAry[tmpIndex]['numRows'] = numRows;
	dBAry[tmpIndex]['numRows2'] = numRows2;
	dBAry[tmpIndex]['numRows3'] = numRows3;
	dBAry[tmpIndex]['contentType'] = contentType;
    var loadImage = docelm("imgLoad" + tmpIndex);
    if(loadImage) loadImage.className = 'loadingShow';
	
	if(saveBox == true) setTimeout('saveBoxes()',1000);
	
    var aIndx = aObjs.length;
	aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/getsports.aspx';
	aObjs[aIndx].onCompletion = function(){ showSportsComboData(aIndx,tmpIndex); };
	aObjs[aIndx].setVar("theParams", 'iid:' + contentType + ',n:' + numRows + ',n2:' + numRows2 + ',n3:' + numRows3 + ',bx:' + tmpIndex);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
}

function showSportsComboData(aIndx,tmpIndex)
{
    var boxDiv = dBAry[tmpIndex]['obj'];
    
    var obj = null;
    var objHead = null;
    objHead = boxDiv.childNodes[0];
    obj = boxDiv.childNodes[1];
    objEdit = boxDiv.childNodes[2];
    if(obj != null) {
	    var apData = aObjs[aIndx].responseXML;
	    
	    var apHeadlines = apData.getElementsByTagName('heading');
	    
	    var newsCat = "";
	    var editText = "";
	    var newsCatLink = "";
	    var stayInEdit = 0;
	    if(apHeadlines.length > 0)
	    {
	        for(var j = 0; j < apHeadlines[0].childNodes.length; j++)
	        {
	            if(apHeadlines[0].childNodes[j].nodeName == "ListName") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    newsCat = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[0].childNodes[j].nodeName == "config") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    editText = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[0].childNodes[j].nodeName == "sportsLink") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    newsCatLink = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[0].childNodes[j].nodeName == "moreInterests") {
	                if(apHeadlines[0].childNodes[j].firstChild)
	                    stayInEdit = apHeadlines[0].childNodes[j].firstChild.nodeValue;
	            }
	        }
	    }
	    if(objHead != null) objHead.innerHTML = makeHeader2(newsCat, "edit", tmpIndex);
	    if(objEdit != null) objEdit.innerHTML = editText;
	    
	    apHeadlines = apData.getElementsByTagName('scoreboard');
	    var totalRecords = 0;
	    var scoreBoard = "";
	    var plusMinus = "";
	    obj.innerHTML = "";
	    
	    for(var i = 0; i < apHeadlines.length; i++)
	    {
	        var hImage = "";
	        var vImage = "";
	        var gameInfo = "";
	        for(var j = 0; j < apHeadlines[i].childNodes.length; j++)
	        {
	            if(apHeadlines[i].childNodes[j].nodeName == "hImage") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    hImage = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "vImage") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    vImage = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "GameInfo") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    gameInfo = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "total") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    totalRecords = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }
	        }
	        scoreBoard += "<tr><td style=\"width:80px;vertical-align:bottom;\">" + hImage + "</td><td align=\"center\"><h3>vs</h3></td><td style=\"width:80px;vertical-align:bottom;\">" + vImage + "</td><td align=\"center\" valign=\"middle\"><strong>" + gameInfo + "</strong></td></tr>";
	    }
	    
	    if(totalRecords != 0){
	        if(totalRecords > 25) totalRecords = 25;
    	    
	        if(apHeadlines.length > 1 && apHeadlines.length < totalRecords)
	        {
	            plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldSprtCmbData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']+1) + "," + dBAry[tmpIndex]['numRows2'] + "," + dBAry[tmpIndex]['numRows3'] + "," + true + ");\">+</span>&nbsp;<span style=\"cursor:pointer;\" onclick=\"rldSprtCmbData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']-1) + "," + dBAry[tmpIndex]['numRows2'] + "," + dBAry[tmpIndex]['numRows3'] + "," + true + ");\">-</span>";
	        }else if(apHeadlines.length == 1 && apHeadlines.length < totalRecords)
	        {
	            plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldSprtCmbData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']+1) + "," + dBAry[tmpIndex]['numRows2'] + "," + dBAry[tmpIndex]['numRows3'] + "," + true + ");\">+</span>";
	        }else if(apHeadlines.length > 0 && apHeadlines.length > 1)
	        {
	            plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldSprtCmbData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + (dBAry[tmpIndex]['numRows']-1) + "," + dBAry[tmpIndex]['numRows2'] + "," + dBAry[tmpIndex]['numRows3'] + "," + true + ");\">-</span>";
	        }
	        obj.innerHTML = "<table width=\"100%\">" + scoreBoard + "<tr><td colspan=\"4\" style=\"height:16px;\" class=\"arrows\" align=\"right\"><div id=\"plusMinus" + tmpIndex + "\" style=\"display:none;\">" + plusMinus + "</div></td></tr></table><br />";
	    }
	    
	    apHeadlines = apData.getElementsByTagName('discussions');
	    var list = "<ul class=\"apUL\">";
	    var apImage = "";
	    var totalQuestions = 0;
	    var totalAns = 0;
	    for(var i = 0; i < apHeadlines.length; i++)
	    {
	        var contentId = 0;
	        var headline = "";
	        var imageDiv = "";
	        var totalAns = 0;
	        var itemName = "";
	        var itemId = 0;
	        var listId = 0;
	        
	        for(var j = 0; j < apHeadlines[i].childNodes.length; j++)
	        {
	            if(apHeadlines[i].childNodes[j].nodeName == "Title") {
	                headline = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "ID") {
	                contentId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "imageDIV") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    imageDiv = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "itemname") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    itemName = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "itemid") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    itemId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "listid") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    listId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "TotalQuestions") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    totalQuestions = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }else if(apHeadlines[i].childNodes[j].nodeName == "TotalAnswers") {
	                if(apHeadlines[i].childNodes[j].firstChild)
	                    totalAns = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	            }
	        }
	        if(i == 0) if(imageDiv != "") apImage = imageDiv;
	        if(i == 0) list += "<li style=\"font-weight: bold; list-style-type:none;\"><a href=\"w/lists/" + listId + "_" + itemId + "/default.aspx\">" + itemName + "</a>: <a href=\"w/discussions/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	        else list += "<li><a href=\"w/lists/" + listId + "_" + itemId + "/default.aspx\">" + itemName + "</a>: <a href=\"w/discussions/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	    }
	    list += "</ul>";
	    
	    if(totalQuestions > 25) totalQuestions = 25;
	    
	    if(apHeadlines.length > 1 && apHeadlines.length < totalQuestions)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldSprtCmbData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + dBAry[tmpIndex]['numRows'] + "," + (dBAry[tmpIndex]['numRows2']+1) + "," + dBAry[tmpIndex]['numRows3'] + "," + true + ");\">+</span>&nbsp;<span style=\"cursor:pointer;\" onclick=\"rldSprtCmbData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + dBAry[tmpIndex]['numRows'] + "," + (dBAry[tmpIndex]['numRows2']-1) + "," + dBAry[tmpIndex]['numRows3'] + "," + true + ");\">-</span>";
	    }else if(apHeadlines.length == 1 && apHeadlines.length < totalQuestions)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldSprtCmbData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + dBAry[tmpIndex]['numRows'] + "," + (dBAry[tmpIndex]['numRows2']+1) + "," + dBAry[tmpIndex]['numRows3'] + "," + true + ");\">+</span>";
	    }else if(apHeadlines.length > 0 && apHeadlines.length > 1)
	    {
	        plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldSprtCmbData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + dBAry[tmpIndex]['numRows'] + "," + (dBAry[tmpIndex]['numRows2']-1) + "," + dBAry[tmpIndex]['numRows3'] + "," + true + ");\">-</span>";
	    }
	    obj.innerHTML +="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"width:90px;\" valign=\"top\" align=\"center\">" + apImage + "</td><td valign=\"top\"><div style=\"float:left;\">" + list + "</div></td></tr></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"height:16px;\" class=\"homemore\">»&nbsp;<a href=\"" + newsCatLink + "\">more " + newsCat + " discussions</a></td><td class=\"arrows\" align=\"right\"><div id=\"plusMinus" + tmpIndex + "\" style=\"display:none;\">" + plusMinus + "</div></td></tr></table>";
	    
	    // do content
	    apHeadlines = apData.getElementsByTagName('content');
	    
	    if(apHeadlines.length > 0){
	        list = "<ul class=\"apUL\">";
	        apImage = "";
	        plusMinus = "";
	        totalQuestions = 0;
	        totalAns = 0;
	        for(var i = 0; i < apHeadlines.length; i++)
	        {
	            var contentId = 0;
	            var headline = "";
	            var imageDiv = "";
	            var totalAns = 0;
	            var itemName = "";
	            var itemId = 0;
	            var listId = 0;
    	        
	            for(var j = 0; j < apHeadlines[i].childNodes.length; j++)
	            {
	                if(apHeadlines[i].childNodes[j].nodeName == "Headline") {
	                    headline = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }else if(apHeadlines[i].childNodes[j].nodeName == "ContentID") {
	                    contentId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }else if(apHeadlines[i].childNodes[j].nodeName == "imageDIV") {
	                    if(apHeadlines[i].childNodes[j].firstChild)
	                        imageDiv = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }else if(apHeadlines[i].childNodes[j].nodeName == "BlogTitle") {
	                    if(apHeadlines[i].childNodes[j].firstChild)
	                        itemName = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }else if(apHeadlines[i].childNodes[j].nodeName == "BlogId") {
	                    if(apHeadlines[i].childNodes[j].firstChild)
	                        itemId = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }else if(apHeadlines[i].childNodes[j].nodeName == "TotalRecords") {
	                    if(apHeadlines[i].childNodes[j].firstChild)
	                        totalQuestions = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }else if(apHeadlines[i].childNodes[j].nodeName == "TotalAnswers") {
	                    if(apHeadlines[i].childNodes[j].firstChild)
	                        totalAns = apHeadlines[i].childNodes[j].firstChild.nodeValue;
	                }
	            }
	            if(i == 0) if(imageDiv != "") apImage = imageDiv;
	            if(i == 0) list += "<li style=\"font-weight: bold; list-style-type:none;\"><a href=\"w/blogshome/" + itemId + ".aspx\">" + itemName + "</a>: <a href=\"w/blogarticle/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	            else list += "<li><a href=\"w/blogshome/" + itemId + ".aspx\">" + itemName + "</a>: <a href=\"w/blogarticle/" + contentId + ".aspx\">" + headline + "</a> (" + totalAns + ")</li>";
	        }
	        list += "</ul>";

	        if (totalQuestions > 25) totalQuestions = 25;
    	    
	        if(apHeadlines.length > 1 && apHeadlines.length < totalQuestions)
	        {
	            plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldSprtCmbData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + dBAry[tmpIndex]['numRows'] + "," + dBAry[tmpIndex]['numRows2'] + "," + (dBAry[tmpIndex]['numRows3']+1) + "," + true + ");\">+</span>&nbsp;<span style=\"cursor:pointer;\" onclick=\"rldSprtCmbData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + dBAry[tmpIndex]['numRows'] + "," + dBAry[tmpIndex]['numRows2'] + "," + (dBAry[tmpIndex]['numRows3']-1) + "," + true + ");\">-</span>";
	        }else if(apHeadlines.length == 1 && apHeadlines.length < totalQuestions)
	        {
	            plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldSprtCmbData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + dBAry[tmpIndex]['numRows'] + "," + dBAry[tmpIndex]['numRows2'] + "," + (dBAry[tmpIndex]['numRows3']+1) + "," + true + ");\">+</span>";
	        }else if(apHeadlines.length > 0 && apHeadlines.length > 1)
	        {
	            plusMinus = "<span style=\"cursor:pointer;\" onclick=\"rldSprtCmbData(" + tmpIndex + "," + dBAry[tmpIndex]['contentType'] + "," + dBAry[tmpIndex]['numRows'] + "," + dBAry[tmpIndex]['numRows2'] + "," + (dBAry[tmpIndex]['numRows3']-1) + "," + true + ");\">-</span>";
	        }
	        obj.innerHTML +="<br /><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"width:90px;\" valign=\"top\" align=\"center\">" + apImage + "</td><td valign=\"top\"><div style=\"float:left;\">" + list + "</div></td></tr></table><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"height:16px;\" class=\"homemore\">»&nbsp;<a href=\"w/blogs/interest/" + dBAry[tmpIndex]['contentType'] + "/1.aspx\">more " + newsCat + " blog articles</a></td><td class=\"arrows\" align=\"right\"><div id=\"plusMinus2_" + tmpIndex + "\" style=\"display:none;\">" + plusMinus + "</div></td></tr></table>";
	    }
	}
    dBAry[tmpIndex]['heightOfBox'] = boxDiv.clientHeight;
    if(objEdit.style.display == '') toggleEdit(tmpIndex, false);
    if(stayInEdit == 1) toggleEdit(tmpIndex, false, true);
}

function createSortie(sortieType, columnIndex, contentType, numRows, numRows2, numRows3)
{
	boxIndex++;
	var tmpIndex = boxIndex;
	
	var maindiv = document.createElement('DIV');
	maindiv.className = 'sContainer';
	maindiv.id = 'dvBox' + boxIndex;
	
	maindiv.onmouseover = mouseoverBox;
	maindiv.onmouseout = mouseoutBox;
	
	var div = document.createElement('DIV');
	div.className='sHeader';
	div.id = 'dvHeader' + boxIndex;
	div.innerHTML = makeHeader("loading sortie", "", tmpIndex);
	
	div.onmouseover = mouseoverBoxHeader;
	div.onmouseout = mouseoutBoxHeader;
	maindiv.appendChild(div);
	
	var innerDiv = document.createElement('DIV');
	innerDiv.id = "dvContent" + boxIndex;
	innerDiv.innerHTML = "loading...";
	maindiv.appendChild(innerDiv);
	
	var editDiv = document.createElement('DIV');
	editDiv.id = "dvEdit" + boxIndex;
	editDiv.style.display = 'none';
	maindiv.appendChild(editDiv);
	
	var obj = docelm("dvColumn" + columnIndex);
	var subs = obj.getElementsByTagName('DIV');
	if(subs.length>0) obj.insertBefore(maindiv, subs[subs.length-1].nextSibling);
	else obj.appendChild(maindiv);
	
	var dvHead = maindiv.firstChild;
	
	dvHead.onmousedown = initDragDropBox;
	dvHead.style.cursor = 'move';
	
	var aIndx = aObjs.length;
	var ajaxRequestFile = "";
	var ajaxRequestParams = "";
	var ajaxOnComplete = function() { };
	
	switch(sortieType) {
        case 1:
            ajaxRequestFile = 'o/ajax/getweather.aspx';
            ajaxRequestParams = 'bx:' + tmpIndex;
            ajaxOnComplete = function(){ showWeatherData(aIndx,tmpIndex); };
	        break;
	    case 2:
            ajaxRequestFile = 'o/ajax/getap.aspx';
            ajaxRequestParams = 'cc:' + contentType + ',n:' + numRows + ',bx:' + tmpIndex;
            ajaxOnComplete = function(){ showAPData(aIndx,tmpIndex); };
	        break;
	    case 3:
            ajaxRequestFile = 'o/ajax/getdiscussions.aspx';
            ajaxRequestParams = 'dt:' + contentType + ',n:' + numRows + ',bx:' + tmpIndex;
            ajaxOnComplete = function(){ showDiscussionData(aIndx,tmpIndex); };
	        break;
	    case 4:
            ajaxRequestFile = 'o/ajax/getblogs.aspx';
            ajaxRequestParams ='bt:' + contentType + ',n:' + numRows + ',bi:' + numRows2 + ',bx:' + tmpIndex;
            ajaxOnComplete = function(){ showBlogData(aIndx,tmpIndex); };
	        break;
	    case 5:
            ajaxRequestFile = 'o/ajax/getinterestsblock.aspx';
            ajaxRequestParams = 'iid:' + contentType + ',n:' + numRows + ',n2:' + numRows2 + ',bx:' + tmpIndex;
            ajaxOnComplete = function(){ showInterestsComboData(aIndx,tmpIndex); };
	        break;
	    case 6:
            ajaxRequestFile = 'o/ajax/getsports.aspx';
            ajaxRequestParams = 'iid:' + contentType + ',n:' + numRows + ',n2:' + numRows2 + ',n3:' + numRows3 + ',bx:' + tmpIndex;
            ajaxOnComplete = function(){ showSportsComboData(aIndx,tmpIndex); };
	        break;
	    case 7:
            ajaxRequestFile = 'o/ajax/getpm.aspx';
            ajaxRequestParams = 'n:' + numRows + ',bx:' + tmpIndex;
            ajaxOnComplete = function(){ showPrivateMessagesData(aIndx,tmpIndex); };
	        break;
	    case 8:
            ajaxRequestFile = 'o/ajax/getactivity.aspx';
            ajaxRequestParams = 'bx:' + tmpIndex + ',n:' + numRows;
            ajaxOnComplete = function(){ showActivityData(aIndx,tmpIndex); };
	        break;
	}
	
	dBAry[boxIndex] = new Array();
	dBAry[boxIndex]['obj'] = maindiv;
	dBAry[boxIndex]['parentObj'] = maindiv.parentNode;
	dBAry[boxIndex]['uniqueIdentifier'] = null;
	dBAry[boxIndex]['heightOfBox'] = div.clientHeight;
	dBAry[boxIndex]['boxState'] = 1;
	dBAry[boxIndex]['contentType'] = contentType;
	dBAry[boxIndex]['numRows'] = numRows;
	dBAry[boxIndex]['numRows2'] = numRows2;
	dBAry[boxIndex]['numRows3'] = numRows3;
	dBAry[boxIndex]['boxType'] = sortieType;
	
	var loadImage = docelm("imgLoad" + tmpIndex);
    if(loadImage) loadImage.className = 'loadingShow';
	
	aObjs[aIndx] = new sack();
	aObjs[aIndx].method = "POST";
	aObjs[aIndx].requestFile = ajaxRequestFile;
	aObjs[aIndx].onCompletion = ajaxOnComplete;
	aObjs[aIndx].setVar("theParams", ajaxRequestParams);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
	
	return boxIndex;
}

function loadBoxesFromCookie(cookieData)
{
    var theBoxes = cookieData.split('#');
    
    for(var i = 0; i < theBoxes.length; i++)
    {
        sortieCounter++;
        var boxInfo = theBoxes[i].split(',');
        createSortie(parseInt(boxInfo[0]),parseInt(boxInfo[1]),parseInt(boxInfo[3]),parseInt(boxInfo[4]),parseInt(boxInfo[5]),parseInt(boxInfo[6]));
    }
}

function loadBoxesFromArray(arrayData)
{
    var tempCookieInfo = "";
    for(var j = 0; j < arrayData.length; j++)
    {
        sortieCounter++;
        tempCookieInfo += arrayData[j][2] + "," + arrayData[j][3] + "," + arrayData[j][4] + "," + arrayData[j][5] + "," + arrayData[j][6] + "," + arrayData[j][7] + "," + arrayData[j][8];
        tempCookieInfo += "#";
        createSortie(arrayData[j][2],arrayData[j][3],arrayData[j][5],arrayData[j][6],arrayData[j][7],arrayData[j][8]);
    }
    tempCookieInfo = tempCookieInfo.substring(0,tempCookieInfo.length-1);
	
    setCookie(nameOfCookie, tempCookieInfo, 365);
}

function initDragableBoxesScript()
{
    rctDiv = document.createElement('DIV');
	rctDiv.id='rctDiv';
	rctDiv.style.display='none';
	document.body.appendChild(rctDiv);

	columnParentBox = docelm(colPBId);

	initEvents();

	var loadFromCookie = false;
	if(sortieObjects.length > 0) if(sortieObjects[0][0] != sortieObjects[0][1]) if(sortieObjects[0][1] == -1) loadFromCookie = true;
	// check for cookie.
	var tempCookieInfo = "";
	
	if(loadFromCookie) {
	    tempCookieInfo = readCookie(nameOfCookie);
		
	    if(tempCookieInfo) loadBoxesFromCookie(tempCookieInfo);
	    else  loadBoxesFromArray(sortieObjects);
	}else loadBoxesFromArray(sortieObjects);

	addSortCon = docelm("modalOverlay");

	if (typeof leftMenuTribalDivId != 'undefined' && typeof leftMenuTribalIframeAdCode != 'undefined')
		if (leftMenuTribalDivId != "" && leftMenuTribalIframeAdCode != "")
			document.getElementById(leftMenuTribalDivId).innerHTML = leftMenuTribalIframeAdCode;

	if (typeof searchMenuTribalDivId != 'undefined' && typeof searchMenuTribalIframeAdCode != 'undefined')
		if (searchMenuTribalDivId != "" && searchMenuTribalIframeAdCode != "")
			document.getElementById(searchMenuTribalDivId).innerHTML = searchMenuTribalIframeAdCode;
}

function rldSorties(aIndx)
{
    var apData = aObjs[aIndx].responseXML;
    
    var sortieData = apData.getElementsByTagName('sortieData');

    loadBoxesFromCookie(sortieData[0].firstChild.nodeValue);
    setTimeout('saveBoxes()',1000);
}


function resetSorties()
{
    var value = confirm('Do you wish to reset your customized page?');
    
    if(value == true)
    {
        for(var i = 1; i < dBAry.length; i++ )
        {
            if(dBAry[i]['boxState'] == 1) {
                var obj = dBAry[i]['obj'];
                obj.parentNode.removeChild(obj);
	            dBAry[i]['boxState'] = 0;
            }
        }
        
        // reset counters, and array
        boxIndex = 0;
        sortieCounter = 0;
        dBAry = new Array();

        // get defaults from db, then call load
        var aIndx = aObjs.length;
	    aObjs[aIndx] = new sack();
	    aObjs[aIndx].requestFile = 'o/ajax/getsortiedefaults.aspx';
	    aObjs[aIndx].onCompletion = function(){ rldSorties(aIndx); };
	    aObjs[aIndx].runAJAX();		// Execute AJAX function
    }
}

function getContentConfig()
{
    var selectSortie = docelm("selectAddSortie");
    var sortieType = selectSortie.options[selectSortie.selectedIndex].value;
    if(sortieType > 0) {
        var obj = docelm("dvSortieConfig");
	    obj.style.display = '';
        obj.innerHTML = "<img style=\"width:15px; height:15px;\" src=\"" + imagesLoc + loadingGif + "\">";
        var aIndx = aObjs.length;
	    aObjs[aIndx] = new sack();
	    aObjs[aIndx].requestFile = 'o/ajax/addsortie.aspx';
	    aObjs[aIndx].onCompletion = function(){ showSortieConfigData(aIndx); };
        aObjs[aIndx].setVar("theParams", 'ct:' + sortieType);
	    aObjs[aIndx].runAJAX();		// Execute AJAX function
    }else {
        var obj = docelm("dvSortieConfig");
        obj.style.display = 'none';
    }
}

function showSortieConfigData(aIndx)
{	    
    var obj = docelm("dvSortieConfig");
    
    if(obj != null) {
	    var apData = aObjs[aIndx].responseXML;
	    
	    var sortieData = apData.getElementsByTagName('sortieData');
	    obj.innerHTML = sortieData[0].firstChild.nodeValue;
	}
}

function insertAddSortieData(aIndx)
{	    
    obj = addSortCon.childNodes[0];
    
    if(obj != null) {
	    var apData = aObjs[aIndx].responseXML;
	    
	    var sortieData = apData.getElementsByTagName('sortieData');
	    obj.innerHTML = sortieData[0].firstChild.nodeValue;
	}
}

function deleteInterests(boxNum)
{
    var items = document.getElementsByName("chkItems" + boxNum);
    var delString = "";
    
    if(items) {
        for(var i = 0; i < items.length; i++)
        {
            if(items[i].checked == true){
                delString += items[i].value + ",";
            }
        }
    }
    if(delString != ""){
        var span = docelm('btnDelItems' + boxNum);
        if(span) span.style.display = 'none';
        var imgLoad = docelm('delLoading' + boxNum);
        if(imgLoad) imgLoad.style.display = '';
        delString = delString.substring(0,delString.length-1);
        var aIndx = aObjs.length;
	    aObjs[aIndx] = new sack();
	    aObjs[aIndx].requestFile = 'o/ajax/addeditlists.aspx';
	    if(dBAry[boxNum]['boxType'] == 6)
	    {
	        aObjs[aIndx].onCompletion = function(){ rldSprtCmbData(boxNum, dBAry[boxNum]['contentType'], dBAry[boxNum]['numRows'], dBAry[boxNum]['numRows2'], dBAry[boxNum]['numRows3'], false) };
	    }else
	    {
	        aObjs[aIndx].onCompletion = function(){ rldIntCmboData(boxNum, dBAry[boxNum]['contentType'], dBAry[boxNum]['numRows'], dBAry[boxNum]['numRows2'], false); };

	    }
        aObjs[aIndx].setVar("theParams", 'aet:1,bx:' + boxNum );
        aObjs[aIndx].setVar("theItems", delString);
	    aObjs[aIndx].runAJAX();		// Execute AJAX function
    }
}

function addInterests(boxNum)
{
    var newItems = docelm("txtItems" + boxNum);
    var addString = "";
    if(newItems) {
        addString = newItems.value;
    }
    if(addString != ""){
        var span = docelm('btnAddItems' + boxNum);
        if(span) span.style.display = 'none';
        var imgLoad = docelm('addLoading' + boxNum);
        if(imgLoad) imgLoad.style.display = '';
        var aIndx = aObjs.length;
	    aObjs[aIndx] = new sack();
	    aObjs[aIndx].requestFile = 'o/ajax/addeditlists.aspx';
	    if(dBAry[boxNum]['boxType'] == 6)
	    {
	        aObjs[aIndx].onCompletion = function(){ rldSprtCmbData(boxNum, dBAry[boxNum]['contentType'], dBAry[boxNum]['numRows'], dBAry[boxNum]['numRows2'], dBAry[boxNum]['numRows3'], false) };
	    }else
	    {
	        aObjs[aIndx].onCompletion = function(){ rldIntCmboData(boxNum, dBAry[boxNum]['contentType'], dBAry[boxNum]['numRows'], dBAry[boxNum]['numRows2'], false); };
	    }
        aObjs[aIndx].setVar("theParams", 'aet:2,iid:' + dBAry[boxNum]['contentType'] + ',bx:' + boxNum );
        aObjs[aIndx].setVar("theItems", addString);
	    aObjs[aIndx].runAJAX();		// Execute AJAX function
    }
}

function addSortie()
{
    var selectSortie = docelm("selectAddSortie");
    var selectSortieColumn = docelm("selectAddSortieColumn");
    var selectAddSortieContent = docelm("selectAddSortieContent");
    var num1 = 5;
    var num2 = 5;
    var num3 = 5;
    
    var sortieType = selectSortie.options[selectSortie.selectedIndex].value;
    var columnIndex = selectSortieColumn.options[selectSortieColumn.selectedIndex].value;
    var contentType = -1;
    if(selectAddSortieContent) contentType = selectAddSortieContent.options[selectAddSortieContent.selectedIndex].value;
    var dontAdd = false;
    if(parseInt(sortieType) == 1)
    {
        for(var i = 1; i < dBAry.length; i++)
        {
            if(dBAry[i]['boxType'] == 1 && dBAry[i]['boxState'] == 1)
            {
                dontAdd = true;
                break;
            }
        }
    }
    if(dontAdd == true)
    {
        alert("Unable to add another weather sortie, you already have one on your page.");
        closeAddSortie();
    }else if(sortieCounter <16) {
        switch(parseInt(sortieType)) {
        case 1:
            contentType = 0;
    	    break;
    	case 4:
            contentType = 1;
    	    break;
    	case 6:
            contentType = 3;
            num1 = 1;
    	    break;
    	case 7:
            contentType = 0;
    	    break;
    	}
    	if(contentType >= 0){
            closeAddSortie();
            if(parseInt(sortieType) == 5 && parseInt(contentType) == 3){
    	    createSortie(6, parseInt(columnIndex), 3, 1, num2, num3);
    	    }else
    	    {
    	    createSortie(parseInt(sortieType), parseInt(columnIndex), parseInt(contentType), num1, num2, num3);
    	    }
    	    sortieCounter++;
    	    setTimeout('saveBoxes()',1000);
    	}
    }else {
        alert("Unable to add new sortie, you have reached the maximun number at this time.");
        closeAddSortie();
    }
}

function closeEditSortie(tmpIndex)
{
    el = docelm("modalOverlay");
    el.style.display = (el.style.display == "block") ? "none" : "block";
    addSortiePopup = (el.style.display == "block") ? true : false;
    
    if(addSortiePopup == true) {
		var obj = addSortCon.childNodes[0];
		obj.innerHTML = '<center><div id="dvEditLoading" class="loadingEditShow">&nbsp;</div></center><div id="dvMyInterests"></div><div id="dvPopInterests"></div><span class="addedit2" style="cursor: pointer;" onclick="closeEditSortie(' + tmpIndex + ')">close</span>';
	
        var scTop = parseInt((window.pageYOffset)?(window.pageYOffset):(document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop);
		var scLeft = parseInt((window.pageXOffset)?(window.pageXOffset):(document.documentElement)?document.documentElement.scrollLeft:document.body.scrollLeft);
				
		addSortCon.style.top = scTop + "px";
		addSortCon.style.left = scLeft + "px";
		addSortCon.style.width = getViewportWidth();
		addSortCon.style.height = getViewportHeight();
		
		getMyInterest2(dBAry[tmpIndex]['contentType'],6,1);
		getPopular2(dBAry[tmpIndex]['contentType'],12,1);
    }else {
		switch(dBAry[tmpIndex]['boxType']) {
        case 5:
            rldIntCmboData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], dBAry[tmpIndex]['numRows2'], true);
	        break;
        case 6:
            rldSprtCmbData(tmpIndex, dBAry[tmpIndex]['contentType'], dBAry[tmpIndex]['numRows'], dBAry[tmpIndex]['numRows2'], dBAry[tmpIndex]['numRows3'], false);
	        break;
        }
    }
}

function getMyInterest2(lid,pp,p)
{
	var aIndx = aObjs.length;
    aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/interests/getMyInterests.aspx';
	aObjs[aIndx].onCompletion = function(){ getMyInterestComplete2(aIndx, lid); };
	aObjs[aIndx].setVar("theParams", 'lid:' + lid + ',pp:' + pp + ',p:' + p + ',oae:1,sh:0,sea:0');
	aObjs[aIndx].runAJAX();		// Execute AJAX function
}

function getMyInterestComplete2(aIndx, lid)
{
	var dvPop = docelm('dvMyInterests');
	if(dvPop != null) {
	    var popData = aObjs[aIndx].responseXML;
	    
	    var popDataItem = popData.getElementsByTagName('popData');
	    var theHTML = '';
	    if(popDataItem != null && popDataItem.length > 0)
	    {
			theHTML = popDataItem[0].firstChild.nodeValue;
	    }
		
	    dvPop.innerHTML = theHTML;
	    
	    var dvLoad = docelm('dvEditLoading');
	    if(dvLoad != null)
			dvLoad.className = 'loadingEditHidden';
	}
}

function getPopular2(lid,pp,p)
{
	var aIndx = aObjs.length;
    aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/interests/getPopular.aspx';
	aObjs[aIndx].onCompletion = function(){ getPopularComplete2(aIndx, lid); };
	aObjs[aIndx].setVar("theParams", 'lid:' + lid + ',pp:' + pp + ',p:' + p + ',oae:1,mpp:6');
	aObjs[aIndx].runAJAX();		// Execute AJAX function
}

function getPopularComplete2(aIndx, lid)
{
	var dvPop = docelm('dvPopInterests');
	if(dvPop != null) {
	    var popData = aObjs[aIndx].responseXML;
	    
	    var popDataItem = popData.getElementsByTagName('popData');
	    var theHTML = '';
	    if(popDataItem != null && popDataItem.length > 0)
	    {
			theHTML = popDataItem[0].firstChild.nodeValue;
	    }
		
	    dvPop.innerHTML = theHTML;
	    
	    var dvLoad = docelm('dvEditLoading');
	    if(dvLoad != null)
			dvLoad.className = 'loadingEditHidden';
	}
}

function delInterestNav(id, lid, pp, div)
{
    var aIndx = aObjs.length;
    aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/interests/delinterest.aspx';
	aObjs[aIndx].onCompletion = function(){ delInterestNavComplete(id, lid, pp, div); };
	aObjs[aIndx].setVar("theParams", 'id:' + id + ',lid:' + lid);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
	div.className = 'navWait';
}

function delInterestNavComplete(id, lid, pp, div)
{
	div.onclick = function(){addInterestNav(id, lid, pp, div)};
	div.className = 'addILinkNav';
	getMyInterest2(lid,pp,1);
}

function delInterestNav3(id, lid, div)
{
    var aIndx = aObjs.length;
    aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/interests/delinterest.aspx';
	aObjs[aIndx].onCompletion = function(){ delInterestNavComplete3(id, lid, div); };
	aObjs[aIndx].setVar("theParams", 'id:' + id + ',lid:' + lid);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
	div.className = 'navWait';
}

function delInterestNavComplete3(id, lid, div)
{
	docelm('dv' + id).style.display = 'none';
}

function addInterestNav(id, lid, pp, div)
{
	var aIndx = aObjs.length;
    aObjs[aIndx] = new sack();
	aObjs[aIndx].requestFile = 'o/ajax/interests/addinterest.aspx';
	aObjs[aIndx].onCompletion = function(){ addInterestNavComplete(id, lid, pp, div); };
	aObjs[aIndx].setVar("theParams", 'id:' + id + ',lid:' + lid);
	aObjs[aIndx].runAJAX();		// Execute AJAX function
	div.className = 'navWait';
}

function addInterestNavComplete(id, lid, pp, div)
{
	div.onclick = function(){delInterestNav(id, lid, pp, div)};
	div.className = 'delILinkNav';
	getMyInterest2(lid,pp,1);
}

function closeAddSortie()
{
    el = docelm("modalOverlay");
    el.style.display = (el.style.display == "block") ? "none" : "block";
    addSortiePopup = (el.style.display == "block") ? true : false;
    
    if(addSortiePopup == true) {
    	var aIndx = aObjs.length;
		aObjs[aIndx] = new sack();
		aObjs[aIndx].requestFile = 'o/ajax/addsortie.aspx';
		aObjs[aIndx].onCompletion = function(){ insertAddSortieData(aIndx); };
		aObjs[aIndx].runAJAX();		// Execute AJAX function
	
        var scTop = parseInt((window.pageYOffset)?(window.pageYOffset):(document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop);
		var scLeft = parseInt((window.pageXOffset)?(window.pageXOffset):(document.documentElement)?document.documentElement.scrollLeft:document.body.scrollLeft);
				
		addSortCon.style.top = scTop + "px";
		addSortCon.style.left = scLeft + "px";
		addSortCon.style.width = getViewportWidth();
		addSortCon.style.height = getViewportHeight();
    }
}

function moveModal(width, height) {
	if (addSortiePopup == true) {
				
		var scTop = parseInt((window.pageYOffset)?(window.pageYOffset):(document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop);
		var scLeft = parseInt((window.pageXOffset)?(window.pageXOffset):(document.documentElement)?document.documentElement.scrollLeft:document.body.scrollLeft);
		addSortCon.style.width = getViewportWidth();
		addSortCon.style.height = getViewportHeight();
				
		addSortCon.style.top = scTop + "px";
		addSortCon.style.left = scLeft + "px";
	}
}

function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 
	return window.undefined; 
}
function getViewportWidth() {
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
	return window.undefined; 
}

function addEvent(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, false);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
}
addEvent(window, "resize", moveModal);

window.onscroll = moveModal;
