/************************************************************************************************************
	(C) www.dhtmlgoodies.com, January 2006
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Version:	1.0	: January 16th - 2006
				1.1 : January 31th - 2006 - Added cookie support - remember rss sources
				1.2 : July 13th - 2006 - Fixed a problem in the createRSSBoxesFromCookie function
				
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/		
	
	/* USER VARIABLES */
	
	var numberOfColumns = 3;	// Number of columns for dragable boxes
	var columnParentBoxId = 'floatingBoxParentContainer';	// Id of box that is parent of all your dragable boxes
	var src_rightImage = 'images/arrow_right.gif';
	var src_downImage = 'images/arrow_down.gif';
	var src_refreshSource = 'images/refresh.gif';
	var src_smallRightArrow = 'images/small_arrow.gif';
	
	var transparencyWhenDragging = true;
	var txt_editLink = 'Edit';
	var txt_editLink_stop = 'End edit';
	var autoScrollSpeed = 4;	// Autoscroll speed	- Higher = faster	
	var dragObjectBorderWidth = 1;	// Border size of your RSS boxes - used to determine width of dotted rectangle
	
	var useCookiesToRememberRSSSources = true;
	
	var nameOfCookie = 'dragable_rss_boxes';	// Name of cookie
	
	/* END USER VARIABLES */
	
	
	
	var columnParentBox;
	var dragableBoxesObj;
	
	var ajaxObjects = new Array();
	
	var boxIndex = 0;	
	var autoScrollActive = false;
	var dragableBoxesArray = new Array();
	
	var dragDropCounter = -1;
	var dragObject = false;
	var dragObjectNextSibling = false;
	var dragObjectParent = false;
	var destinationObj = false;
	
	var mouse_x;
	var mouse_y;
	
	var el_x;
	var el_y;	
	
	var rectangleDiv;
	var okToMove = true;

	var documentHeight = false;
	var documentScrollHeight = false;
	var dragableAreaWidth = false;
		
	var opera = navigator.userAgent.toLowerCase().indexOf('opera')>=0?true:false;
	var cookieCounter=0;
	var cookieRSSSources = new Array();
	
	var staticObjectArray = new Array();
	
	/*
	These cookie functions are downloaded from 
	http://www.mach5.com/support/analyzer/manual/html/General/CookiesJavaScript.htm
	*/	
	function Get_Cookie(name) { 
	   var start = document.cookie.indexOf(name+"="); 
	   var len = start+name.length+1; 
	   if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
	   if (start == -1) return null; 
	   var end = document.cookie.indexOf(";",len); 
	   if (end == -1) end = document.cookie.length; 
	   return unescape(document.cookie.substring(len,end)); 
	} 
	// This function has been slightly modified
	function Set_Cookie(name,value,expires,path,domain,secure) { 
		expires = expires * 60*60*24*1000;
		var today = new Date();
		var expires_date = new Date( today.getTime() + (expires) );
	    var cookieString = name + "=" +escape(value) + 
	       ( (expires) ? ";expires=" + expires_date.toGMTString() : "") + 
	       ( (path) ? ";path=" + path : "") + 
	       ( (domain) ? ";domain=" + domain : "") + 
	       ( (secure) ? ";secure" : ""); 
	    document.cookie = cookieString; 
	} 

	function autoScroll(direction,yPos)
	{
		if(document.documentElement.scrollHeight>documentScrollHeight && direction>0)return;
		if(opera)return;
		window.scrollBy(0,direction);
		if(!dragObject)return;
		
		if(direction<0){
			if(document.documentElement.scrollTop>0){
				dragObject.style.top = (el_y - mouse_y + yPos + document.documentElement.scrollTop) + 'px';		
			}else{
				autoScrollActive = false;
			}
		}else{
			if(yPos>(documentHeight-50)){	
				dragObject.style.top = (el_y - mouse_y + yPos + document.documentElement.scrollTop) + 'px';			
			}else{
				autoScrollActive = false;
			}
		}
		if(autoScrollActive)setTimeout('autoScroll('+direction+',' + yPos + ')',5);
	}
		
	function initDragDropBox(e)
	{
		
		
		dragDropCounter = 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,'');
		el_x = getLeftPos(this.parentNode.parentNode)/1;
		el_y = getTopPos(this.parentNode.parentNode)/1 - document.documentElement.scrollTop;
			
		dragObject = this.parentNode.parentNode;
		
		documentScrollHeight = document.documentElement.scrollHeight + 100 + dragObject.offsetHeight;
		
		
		if(dragObject.nextSibling){
			dragObjectNextSibling = dragObject.nextSibling;
			if(dragObjectNextSibling.tagName!='DIV')dragObjectNextSibling = dragObjectNextSibling.nextSibling;
		}
		dragObjectParent = dragableBoxesArray[numericId]['parentObj'];
			
		dragDropCounter = 0;
		initDragDropBoxTimer();	
		
		return false;
	}
	
	
	function initDragDropBoxTimer()
	{
		if(dragDropCounter>=0 && dragDropCounter<10){
			dragDropCounter++;
			setTimeout('initDragDropBoxTimer()',10);
			return;
		}
		if(dragDropCounter==10){
			mouseoutBoxHeader(false,dragObject);
		}
		
	}

	function moveDragableElement(e){
		if(document.all)e = event;
		if(dragDropCounter<10)return;
		
		if(document.all && e.button!=1 && !opera){
			stop_dragDropElement();
			return;
		}
		
		if(document.body!=dragObject.parentNode){
			dragObject.style.width = (dragObject.offsetWidth - (dragObjectBorderWidth*2)) + 'px';
			dragObject.style.position = 'absolute';	
			dragObject.style.textAlign = 'left';
			if(transparencyWhenDragging){	
				dragObject.style.filter = 'alpha(opacity=70)';
				dragObject.style.opacity = '0.7';
			}	
			dragObject.parentNode.insertBefore(rectangleDiv,dragObject);
			rectangleDiv.style.display='block';
			document.body.appendChild(dragObject);

			rectangleDiv.style.width = dragObject.style.width;
			rectangleDiv.style.height = (dragObject.offsetHeight - (dragObjectBorderWidth*2)) + 'px'; 
			
		}
		
		if(e.clientY<50 || e.clientY>(documentHeight-50)){
			if(e.clientY<50 && !autoScrollActive){
				autoScrollActive = true;
				autoScroll((autoScrollSpeed*-1),e.clientY);
			}
			
			if(e.clientY>(documentHeight-50) && document.documentElement.scrollHeight<=documentScrollHeight && !autoScrollActive){
				autoScrollActive = true;
				autoScroll(autoScrollSpeed,e.clientY);
			}
		}else{
			autoScrollActive = false;
		}		

		
		var leftPos = e.clientX;
		var topPos = e.clientY + document.documentElement.scrollTop;
		
		dragObject.style.left = (e.clientX - mouse_x + el_x) + 'px';
		dragObject.style.top = (el_y - mouse_y + e.clientY + document.documentElement.scrollTop) + 'px';
								

		
		if(!okToMove)return;
		okToMove = false;

		destinationObj = false;	
		rectangleDiv.style.display = 'none'; 
		
		var objFound = false;
		var tmpParentArray = new Array();
		
		if(!objFound){
			for(var no=1;no<dragableBoxesArray.length;no++){
				if(dragableBoxesArray[no]['obj']==dragObject)continue;
				tmpParentArray[dragableBoxesArray[no]['obj'].parentNode.id] = true;
				if(!objFound){
					var tmpX = getLeftPos(dragableBoxesArray[no]['obj']);
					var tmpY = getTopPos(dragableBoxesArray[no]['obj']);

					if(leftPos>tmpX && leftPos<(tmpX + dragableBoxesArray[no]['obj'].offsetWidth) && topPos>(tmpY-20) && topPos<(tmpY + (dragableBoxesArray[no]['obj'].offsetHeight/2))){
						destinationObj = dragableBoxesArray[no]['obj'];
						destinationObj.parentNode.insertBefore(rectangleDiv,dragableBoxesArray[no]['obj']);
						rectangleDiv.style.display = 'block';
						objFound = true;
						break;
						
					}
					
					if(leftPos>tmpX && leftPos<(tmpX + dragableBoxesArray[no]['obj'].offsetWidth) && topPos>=(tmpY + (dragableBoxesArray[no]['obj'].offsetHeight/2)) && topPos<(tmpY + dragableBoxesArray[no]['obj'].offsetHeight)){
						objFound = true;
						if(dragableBoxesArray[no]['obj'].nextSibling){
							
							destinationObj = dragableBoxesArray[no]['obj'].nextSibling;
							if(!destinationObj.tagName)destinationObj = destinationObj.nextSibling;
							if(destinationObj!=rectangleDiv)destinationObj.parentNode.insertBefore(rectangleDiv,destinationObj);
						}else{
							destinationObj = dragableBoxesArray[no]['obj'].parentNode;
							dragableBoxesArray[no]['obj'].parentNode.appendChild(rectangleDiv);
						}
						rectangleDiv.style.display = 'block';
						break;					
					}
					
					
					if(!dragableBoxesArray[no]['obj'].nextSibling && leftPos>tmpX && leftPos<(tmpX + dragableBoxesArray[no]['obj'].offsetWidth)
					&& topPos>topPos>(tmpY + (dragableBoxesArray[no]['obj'].offsetHeight))){
						destinationObj = dragableBoxesArray[no]['obj'].parentNode;
						dragableBoxesArray[no]['obj'].parentNode.appendChild(rectangleDiv);	
						rectangleDiv.style.display = 'block';	
						objFound = true;				
						
					}
				}
				
			}
		
		}
		
		if(!objFound){
			
			for(var no=1;no<=numberOfColumns;no++){
				if(!objFound){
					var obj = document.getElementById('dragableBoxesColumn' + no);			
					
						var left = getLeftPos(obj)/1;						
					
						var width = obj.offsetWidth;
						if(leftPos>left && leftPos<(left+width)){
							destinationObj = obj;
							obj.appendChild(rectangleDiv);
							rectangleDiv.style.display='block';
							objFound=true;		
							
						}				
					
				}
			}		
			
		}
	

		setTimeout('okToMove=true',5);
		
	}
	
	function stop_dragDropElement()
	{
		
		if(dragDropCounter<10){
			dragDropCounter = -1
			return;
		}
		dragDropCounter = -1;
		if(transparencyWhenDragging){
			dragObject.style.filter = null;
			dragObject.style.opacity = null;
		}		
		dragObject.style.position = 'static';
		dragObject.style.width = null;
		var numericId = dragObject.id.replace(/[^0-9]/g,'');
		if(destinationObj && destinationObj.id!=dragObject.id){
			
			if(destinationObj.id.indexOf('dragableBoxesColumn')>=0){
				destinationObj.appendChild(dragObject);
				dragableBoxesArray[numericId]['parentObj'] = destinationObj;
			}else{
				destinationObj.parentNode.insertBefore(dragObject,destinationObj);
				dragableBoxesArray[numericId]['parentObj'] = destinationObj.parentNode;
			}


							
		}else{
			if(dragObjectNextSibling){
				dragObjectParent.insertBefore(dragObject,dragObjectNextSibling);	
			}else{
				dragObjectParent.appendChild(dragObject);
			}				
			
			
		}
	

		
		autoScrollActive = false;
		rectangleDiv.style.display = 'none'; 
		dragObject = false;
		dragObjectNextSibling = false;
		destinationObj = false;
		
		if(useCookiesToRememberRSSSources)setTimeout('saveCookies()',100);

		documentHeight = document.documentElement.clientHeight;	
	}

	function saveCookies()
	{
		cookieCounter = 0;
		var tmpUrlArray = new Array();
		for(var no=1;no<=numberOfColumns;no++)
		{
			var parentObj = document.getElementById('dragableBoxesColumn' + no);
			
			var items = parentObj.getElementsByTagName('DIV');
			if(items.length==0)continue;
			
			var item = items[0];
			
			var tmpItemArray = new Array();
			while(item){
				var boxIndex = item.id.replace(/[^0-9]/g,'');
				if(item.id!='rectangleDiv'){
					tmpItemArray[tmpItemArray.length] = boxIndex;
				}	
				item = item.nextSibling;			
			}
			
			var columnIndex = no;
			
			for(var no2=tmpItemArray.length-1;no2>=0;no2--){
				var boxIndex = tmpItemArray[no2];
				var url = dragableBoxesArray[boxIndex]['rssUrl'];
				var heightOfBox = dragableBoxesArray[boxIndex]['heightOfBox'];
				var maxRssItems = dragableBoxesArray[boxIndex]['maxRssItems'];
				var minutesBeforeReload = dragableBoxesArray[boxIndex]['minutesBeforeReload'];
				var uniqueIdentifier = dragableBoxesArray[boxIndex]['uniqueIdentifier'];
				var state = dragableBoxesArray[boxIndex]['boxState'];
				if(!tmpUrlArray[url]){
					tmpUrlArray[url] = true;
					
					Set_Cookie(nameOfCookie + cookieCounter,url + '#;#' + columnIndex + '#;#' + maxRssItems + '#;#' + heightOfBox + '#;#' + minutesBeforeReload + '#;#' + uniqueIdentifier + '#;#' + state ,60000);
					cookieRSSSources[url] = cookieCounter;
					cookieCounter++;	
				
				}else{
					
					Set_Cookie(nameOfCookie + cookieCounter,'' + '#;#' + columnIndex + '#;#' + '' + '#;#' + heightOfBox + '#;#' + '' + '#;#' + uniqueIdentifier ,60000);
					cookieCounter++;
				}		
				
			}
		}
	}
	
	
	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 createColumns()
	{
		if(!columnParentBoxId){
			alert('No parent box defined for your columns');
			return;
		}
		columnParentBox = document.getElementById(columnParentBoxId);
		var columnWidth = Math.floor(100/numberOfColumns);
		var sumWidth = 0;
		for(var no=0;no<numberOfColumns;no++){
			var div = document.createElement('DIV');
			if(no==(numberOfColumns-1))columnWidth = 99 - sumWidth;
			sumWidth = sumWidth + columnWidth;
			div.style.cssText = 'float:left;width:'+columnWidth+'%;padding:0px;margin:0px;';
			div.style.height='100%';
			div.style.styleFloat='left';
			div.style.width = columnWidth + '%';
			div.style.padding = '0px';
			div.style.margin = '0px';

			div.id = 'dragableBoxesColumn' + (no+1);
			columnParentBox.appendChild(div);
			
			var clearObj = document.createElement('HR');	
			clearObj.style.clear = 'both';
			clearObj.style.visibility = 'hidden';
			div.appendChild(clearObj);
		}
		
		
		
		var clearingDiv = document.createElement('DIV');
		columnParentBox.appendChild(clearingDiv);
		clearingDiv.style.clear='both';
		
	}
	
	function mouseoverBoxHeader()
	{
		if(dragDropCounter==10)return;
		var id = this.id.replace(/[^0-9]/g,'');
		document.getElementById('dragableBoxExpand' + id).style.visibility = 'visible';		
		document.getElementById('dragableBoxRefreshSource' + id).style.visibility = 'visible';		
		document.getElementById('dragableBoxCloseLink' + id).style.visibility = 'visible';
		if(document.getElementById('dragableBoxEditLink' + id))document.getElementById('dragableBoxEditLink' + id).style.visibility = 'visible';
		
	}
	function mouseoutBoxHeader(e,obj)
	{
		if(!obj)obj=this;
		
		var id = obj.id.replace(/[^0-9]/g,'');
		document.getElementById('dragableBoxExpand' + id).style.visibility = 'hidden';		
		document.getElementById('dragableBoxRefreshSource' + id).style.visibility = 'hidden';		
		document.getElementById('dragableBoxCloseLink' + id).style.visibility = 'hidden';		
		if(document.getElementById('dragableBoxEditLink' + id))document.getElementById('dragableBoxEditLink' + id).style.visibility = 'hidden';		
		
	}
	
	function refreshRSS()
	{
		reloadRSSData(this.id.replace(/[^0-9]/g,''));
		setTimeout('dragDropCounter=-5',5);
	}
	
	function showHideBoxContent(e,inputObj)
	{
		if(document.all)e = event;
		if(!inputObj)inputObj=this;
		
		var numericId = inputObj.id.replace(/[^0-9]/g,'');
		var obj = document.getElementById('dragableBoxContent' + numericId);
		
		obj.style.display = inputObj.src.indexOf(src_rightImage)>=0?'none':'block';
		inputObj.src = inputObj.src.indexOf(src_rightImage)>=0?src_downImage:src_rightImage
		
		dragableBoxesArray[numericId]['boxState'] = obj.style.display=='block'?1:0;
		saveCookies();
		setTimeout('dragDropCounter=-5',5);
	}
	
	function mouseover_CloseButton()
	{
		this.className = 'closeButton_over';	
		setTimeout('dragDropCounter=-5',5);
	}
	
	function highlightCloseButton()
	{
		this.className = 'closeButton_over';	
	}
	
	function mouseout_CloseButton()
	{
		this.className = 'closeButton';	
	}
	
	function closeDragableBox(e,inputObj)
	{
		if(!inputObj)inputObj = this;
		var numericId = inputObj.id.replace(/[^0-9]/g,'');
		document.getElementById('dragableBox' + numericId).style.display='none';	
		
		Set_Cookie(nameOfCookie + cookieRSSSources[dragableBoxesArray[numericId]['rssUrl']],'none' ,60000);

		setTimeout('dragDropCounter=-5',5);
		
	}
	
	function editRSSContent()
	{
		var numericId = this.id.replace(/[^0-9]/g,'');
		var obj = document.getElementById('dragableBoxEdit' + numericId);
		if(obj.style.display=='none'){
			obj.style.display='block';
			this.innerHTML = txt_editLink_stop;
			document.getElementById('dragableBoxHeader' + numericId).style.height = '135px';
		}else{
			obj.style.display='none';
			this.innerHTML = txt_editLink;
			document.getElementById('dragableBoxHeader' + numericId).style.height = '20px';
		}
		setTimeout('dragDropCounter=-5',5);
	}
	
	
	function showStatusBarMessage(numericId,message)
	{
		document.getElementById('dragableBoxStatusBar' + numericId).innerHTML = message;
		
	}
	
	function addBoxHeader(parentObj,externalUrl,notDrabable)
	{
		var div = document.createElement('DIV');
		div.className = 'dragableBoxHeader';
		
		div.id = 'dragableBoxHeader' + boxIndex;
		div.onmouseover = mouseoverBoxHeader;
		div.onmouseout = mouseoutBoxHeader;
		if(!notDrabable){
			div.onmousedown = initDragDropBox;
			div.style.cursor = 'move';
		}
		
		var image = document.createElement('IMG');
		image.id = 'dragableBoxExpand' + boxIndex;
		image.src = src_rightImage;
		image.style.visibility = 'hidden';	
		image.style.cursor = 'pointer';
		image.onmousedown = showHideBoxContent;	
		div.appendChild(image);
		
		var textSpan = document.createElement('SPAN');
		textSpan.id = 'dragableBoxHeader_txt' + boxIndex;
		div.appendChild(textSpan);
				
		parentObj.appendChild(div);	

		var closeLink = document.createElement('A');
		closeLink.style.cssText = 'float:right';
		closeLink.style.styleFloat = 'right';
		closeLink.id = 'dragableBoxCloseLink' + boxIndex;
		closeLink.innerHTML = 'x';
		closeLink.className = 'closeButton';
		closeLink.onmouseover = mouseover_CloseButton;
		closeLink.onmouseout = mouseout_CloseButton;
		closeLink.style.cursor = 'pointer';
		closeLink.style.visibility = 'hidden';
		closeLink.onmousedown = closeDragableBox;
		div.appendChild(closeLink);

			
		var image = document.createElement('IMG');
		image.src = src_refreshSource;
		image.id = 'dragableBoxRefreshSource' + boxIndex;
		image.style.cssText = 'float:right';
		image.style.styleFloat = 'right';
		image.style.visibility = 'hidden';
		image.onclick = refreshRSS;
		image.style.cursor = 'pointer';
		if(!externalUrl)image.style.display='none';
		div.appendChild(image);
		
	
		

		

	}
	
	function saveFeed(boxIndex)
	{
		var heightOfBox = dragableBoxesArray[boxIndex]['heightOfBox'] = document.getElementById('heightOfBox[' + boxIndex + ']').value;
		var intervalObj = dragableBoxesArray[boxIndex]['intervalObj'];
		if(intervalObj)clearInterval(intervalObj);
		
		if(heightOfBox && heightOfBox>40){
			var contentObj = document.getElementById('dragableBoxContent' + boxIndex);
			contentObj.style.height = heightOfBox + 'px';
			contentObj.setAttribute('heightOfBox',heightOfBox);
			contentObj.heightOfBox = heightOfBox;	
			if(document.all)contentObj.style.overflowY = 'auto';else contentObj.style.overflow='-moz-scrollbars-vertical;';
			if(opera)contentObj.style.overflow='auto';			
			
		}
		
		dragableBoxesArray[boxIndex]['rssUrl'] = document.getElementById('rssUrl[' + boxIndex + ']').value;
		dragableBoxesArray[boxIndex]['heightOfBox'] = heightOfBox;
		dragableBoxesArray[boxIndex]['maxRssItems'] = document.getElementById('maxRssItems[' + boxIndex + ']').value;
		dragableBoxesArray[boxIndex]['heightOfBox'] = document.getElementById('heightOfBox[' + boxIndex + ']').value;
		dragableBoxesArray[boxIndex]['minutesBeforeReload'] = document.getElementById('minutesBeforeReload[' + boxIndex + ']').value;
		
		if(dragableBoxesArray[boxIndex]['minutesBeforeReload'] && dragableBoxesArray[boxIndex]['minutesBeforeReload']>5){
			var tmpInterval = setInterval("reloadRSSData(" + boxIndex + ")",(dragableBoxesArray[boxIndex]['minutesBeforeReload']*1000*60));	
			dragableBoxesArray[boxIndex]['intervalObj'] = tmpInterval;
		}
		reloadRSSData(boxIndex);
		
		if(useCookiesToRememberRSSSources)setTimeout('saveCookies()',100);
		
	}
	
	function addRSSEditContent(parentObj)
	{

		var editLink = document.createElement('A');
		editLink.href = '#';
		editLink.onclick = cancelEvent;
		editLink.style.cssText = 'float:right';
		editLink.style.styleFloat = 'right';
		editLink.id = 'dragableBoxEditLink' + boxIndex;
		editLink.innerHTML = txt_editLink;
		editLink.className = 'dragableBoxEditLink';
		editLink.style.cursor = 'pointer';
		editLink.style.visibility = 'hidden';
		editLink.onmousedown = editRSSContent;
		parentObj.appendChild(editLink);	
				
		var editBox = document.createElement('DIV');
		editBox.style.clear='both';
		editBox.id = 'dragableBoxEdit' + boxIndex;
		editBox.style.display='none';
		
		var content = '<form><table cellpadding="1" cellspacing="1"><tr><td>Source:<\/td><td><input type="text" id="rssUrl[' + boxIndex + ']" value="' + dragableBoxesArray[boxIndex]['rssUrl'] + '" size="25" maxlength="255"><\/td><\/tr>'
		+ '<tr><td>Items:<\/td><td width="30"><input type="text" id="maxRssItems[' + boxIndex + ']" onblur="this.value = this.value.replace(/[^0-9]/g,\'\');if(!this.value)this.value=' + dragableBoxesArray[boxIndex]['maxRssItems'] + '" value="' + dragableBoxesArray[boxIndex]['maxRssItems'] + '" size="2" maxlength="2"><\/td><\/tr><tr><td>Fixed height:<\/td><td><input type="text" id="heightOfBox[' + boxIndex + ']" onblur="this.value = this.value.replace(/[^0-9]/g,\'\');if(!this.value)this.value=' + dragableBoxesArray[boxIndex]['heightOfBox'] + '" value="' + dragableBoxesArray[boxIndex]['heightOfBox'] + '" size="2" maxlength="3"><\/td><\/tr><tr>'
		+'<tr><td>Reload every:<\/td><td width="30"><input type="text" id="minutesBeforeReload[' + boxIndex + ']" onblur="this.value = this.value.replace(/[^0-9]/g,\'\');if(!this.value || this.value/1<5)this.value=' + dragableBoxesArray[boxIndex]['minutesBeforeReload'] + '" value="' + dragableBoxesArray[boxIndex]['minutesBeforeReload'] + '" size="2" maxlength="3">&nbsp;minute<\/td><\/tr>'
		+'<tr><td><input type="button" onclick="saveFeed(' + boxIndex + ')" value="Save"><\/td><\/tr><\/table><\/form>';
		editBox.innerHTML = content;
		
		parentObj.appendChild(editBox);		
		
	}
	
	
	function addBoxContentContainer(parentObj,heightOfBox)
	{
		var div = document.createElement('DIV');
		div.className = 'dragableBoxContent';
		if(opera)div.style.clear='none';
		div.id = 'dragableBoxContent' + boxIndex;
		parentObj.appendChild(div);			
		if(heightOfBox && heightOfBox/1>40){
			div.style.minHeight = heightOfBox + 'px';
			div.setAttribute('heightOfBox',heightOfBox);
			div.heightOfBox = heightOfBox;	
			if(document.all)div.style.overflowY = 'auto';else div.style.overflow='-moz-scrollbars-vertical;';
			if(opera)div.style.overflow='auto';
		}		
	}
	
	function addBoxStatusBar(parentObj)
	{
		var div = document.createElement('DIV');
		div.className = 'dragableBoxStatusBar';
		div.id = 'dragableBoxStatusBar' + boxIndex;
		parentObj.appendChild(div);	
		
		
	}
	
	function createABox(columnIndex,heightOfBox,externalUrl,uniqueIdentifier,notDragable)
	{
		boxIndex++;
		
		var maindiv = document.createElement('DIV');
		maindiv.className = 'dragableBox';
		maindiv.id = 'dragableBox' + boxIndex;
		
		var div = document.createElement('DIV');
		div.className='dragableBoxInner';
		maindiv.appendChild(div);
		
		
		addBoxHeader(div,externalUrl,notDragable);
		addBoxContentContainer(div,heightOfBox);
		addBoxStatusBar(div);
		
		var obj = document.getElementById('dragableBoxesColumn' + columnIndex);		
		var subs = obj.getElementsByTagName('DIV');
		if(subs.length>0){
			obj.insertBefore(maindiv,subs[0]);
		}else{
			obj.appendChild(maindiv);
		}
		
		dragableBoxesArray[boxIndex] = new Array();
		dragableBoxesArray[boxIndex]['obj'] = maindiv;
		dragableBoxesArray[boxIndex]['parentObj'] = maindiv.parentNode;
		dragableBoxesArray[boxIndex]['uniqueIdentifier'] = uniqueIdentifier;
		dragableBoxesArray[boxIndex]['heightOfBox'] = heightOfBox;
		dragableBoxesArray[boxIndex]['boxState'] = 1;	// Expanded
		
		staticObjectArray[uniqueIdentifier] = boxIndex;
		
		return boxIndex;
		
	}
	
	function showRSSData(ajaxIndex,boxIndex)
	{
		var rssContent = ajaxObjects[ajaxIndex].response;
		tokens = rssContent.split(/\n\n/g);
		
		
		var headerTokens = tokens[0].split(/\n/g);
		if(headerTokens[0]=='0'){
			headerTokens[1] = '';
			headerTokens[0] = 'Invalid source';
			closeDragableBox(false,document.getElementById('dragableBoxHeader_txt' + boxIndex));
			return;			
		}
		document.getElementById('dragableBoxHeader_txt' + boxIndex).innerHTML = '<span>' + headerTokens[0] + '&nbsp;<\/span><span class="rssNumberOfItems">(' + headerTokens[1] + ')<\/span>';	// title
		
		var string = '<table cellpadding="1" cellspacing="0">';
		for(var no=1;no<tokens.length;no++){	// Looping through RSS items
			var itemTokens = tokens[no].split(/##/g);			
			string = string + '<tr><td><img src="' + src_smallRightArrow + '"><td><p class=\"boxItemHeader\"><a class=\"boxItemHeader\" href="' + itemTokens[3] + '" onclick="var w = window.open(this.href);return false">' + itemTokens[0] + '<\/a><\/p><\/td><\/tr>';		
		}
		string = string + '<\/table>';
		document.getElementById('dragableBoxContent' + boxIndex).innerHTML = string;
		showStatusBarMessage(boxIndex,'');
		ajaxObjects[ajaxIndex] = false;
	}
	
	function reloadRSSData(numericId)
	{
		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		showStatusBarMessage(numericId,'Loading data...');
		ajaxObjects[ajaxIndex].requestFile = 'readRSS.php?rssURL=' + escape(dragableBoxesArray[numericId]['rssUrl']) + '&maxRssItems=' + dragableBoxesArray[numericId]['maxRssItems'];	// Specifying which file to get
		ajaxObjects[ajaxIndex].onCompletion = function(){ showRSSData(ajaxIndex,numericId); };	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
		
	}
		
	function createARSSBox(url,columnIndex,heightOfBox,maxRssItems,minutesBeforeReload,uniqueIdentifier,state)
	{

		if(!heightOfBox)heightOfBox = '0';
		if(!minutesBeforeReload)minutesBeforeReload = '0';

			
		var tmpIndex = createABox(columnIndex,heightOfBox,true);

		if(useCookiesToRememberRSSSources)
		{
			if(!cookieRSSSources[url]){
				cookieRSSSources[url] = cookieCounter;		
				Set_Cookie(nameOfCookie + cookieCounter,url + '#;#' + columnIndex + '#;#' + maxRssItems + '#;#' + heightOfBox + '#;#' + minutesBeforeReload + '#;#' + uniqueIdentifier + '#;#' + state  ,60000);
				cookieCounter++;
			}
		}		
		
		dragableBoxesArray[tmpIndex]['rssUrl'] = url;
		dragableBoxesArray[tmpIndex]['maxRssItems'] = maxRssItems?maxRssItems:100;
		dragableBoxesArray[tmpIndex]['minutesBeforeReload'] = minutesBeforeReload;
		dragableBoxesArray[tmpIndex]['heightOfBox'] = heightOfBox;
		dragableBoxesArray[tmpIndex]['uniqueIdentifier'] = uniqueIdentifier;
		dragableBoxesArray[tmpIndex]['state'] = state;

		if(state==0){
			showHideBoxContent(false,document.getElementById('dragableBoxExpand' + tmpIndex));
		}
		
		staticObjectArray[uniqueIdentifier] = tmpIndex;
		
		var tmpInterval = false;
		if(minutesBeforeReload && minutesBeforeReload>0){
			var tmpInterval = setInterval("reloadRSSData(" + tmpIndex + ")",(minutesBeforeReload*1000*60));
		}

		dragableBoxesArray[tmpIndex]['intervalObj'] = tmpInterval;
			
		addRSSEditContent(document.getElementById('dragableBoxHeader' + tmpIndex))
			
		if(!document.getElementById('dragableBoxContent' + tmpIndex).innerHTML)document.getElementById('dragableBoxContent' + tmpIndex).innerHTML = 'loading RSS data';

		if(url.length>0 && url!='undefined'){
			
			var ajaxIndex = ajaxObjects.length;
			ajaxObjects[ajaxIndex] = new sack();
			if(!maxRssItems)maxRssItems = 100;
			ajaxObjects[ajaxIndex].requestFile = 'readRSS.php?rssURL=' + escape(url) + '&maxRssItems=' + maxRssItems;	// Specifying which file to get
			ajaxObjects[ajaxIndex].onCompletion = function(){ showRSSData(ajaxIndex,tmpIndex); };	// Specify function that will be executed after file has been found
			ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function
		}else{
			hideHeaderOptionsForStaticBoxes(tmpIndex);
		}			
	}
	
	function createHelpObjects()
	{
		/* Creating rectangle div */
		rectangleDiv = document.createElement('DIV');
		rectangleDiv.id='rectangleDiv';
		rectangleDiv.style.display='none';
		document.body.appendChild(rectangleDiv);
		
		 
	}
	
	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(dragDropCounter>=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;	
		
		documentHeight = document.documentElement.clientHeight;	
		
	}
	
	
	function createFeed(formObj)
	{
		var url = formObj.rssUrl.value;
		var items = formObj.items.value;
		var height = formObj.height.value;
		var reloadInterval = formObj.reloadInterval.value;
		if(isNaN(height) || height/1<40)height = false;	
		if(isNaN(reloadInterval) || reloadInterval/1<5)reloadInterval = false;
		createARSSBox(url,1,height,items,reloadInterval);	
	}
	
function createRSSBoxesFromCookie() 
   { 
      var tmpArray = new Array(); 
      var cookieValue = Get_Cookie(nameOfCookie + '0'); 
      cookieCounter=0; 
      while(cookieValue && cookieValue!='') 
        { 
            var items = cookieValue.split('#;#'); 
         var index = items[0]; 
         if(!items[0])index = items[5]; 
         if(items.length>1 && !tmpArray[index]) 
            { 
                tmpArray[index] = true; 
            createARSSBox(items[0],items[1],items[3],items[2],items[4],items[5],items[6]); 
            cookieRSSSources[items[0]]=cookieCounter-1; 
         } 
            else 
            { 
            cookieCounter++; 
         } 
         var cookieValue = Get_Cookie(nameOfCookie + cookieCounter); 
      } 
   }

	
	/* Clear cookies */
	
	function clearCookiesForDragableBoxes()
	{
		var cookieValue = Get_Cookie(nameOfCookie);
		while(cookieValue && cookieValue!=''){
			Set_Cookie(nameOfCookie + cookieCounter,'',-500);
			cookieCounter++;
			var cookieValue = Get_Cookie(nameOfCookie + cookieCounter);
		}		
		
	}
	
	/* Delete all boxes */
	
	function deleteAllDragableBoxes()
	{
		var divs = document.getElementsByTagName('DIV');
		for(var no=0;no<divs.length;no++){
			if(divs[no].className=='dragableBox')closeDragableBox(false,divs[no]);	
		}
			
	}
	
	/* Reset back to default settings */
	
	function resetDragableBoxes()
	{
		cookieCounter = 0;
		clearCookiesForDragableBoxes();
		
		deleteAllDragableBoxes();
		cookieCounter = 0;
		cookieRSSSources = new Array();
		createDefaultBoxes();
	}
	
	function hideHeaderOptionsForStaticBoxes(boxIndex)
	{
		if(document.getElementById('dragableBoxRefreshSource' + boxIndex))document.getElementById('dragableBoxRefreshSource' + boxIndex).style.display='none';
		if(document.getElementById('dragableBoxCloseLink' + boxIndex))document.getElementById('dragableBoxCloseLink' + boxIndex).style.display='';		
		if(document.getElementById('dragableBoxEditLink' + boxIndex))document.getElementById('dragableBoxEditLink' + boxIndex).style.display='none';		
	}
	
	
	
	/* You customize this function */
	function createDefaultBoxes()
	{				
		if(cookieCounter==0){
			createARSSBox('http://rss.cnn.com/rss/cnn_topstories.rss',2,false,5,1);			
			createARSSBox('http://feeds.feedburner.com/reuters/topNews/',2,false,5);			
			createARSSBox('http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml',2,false,5,10);			
			createARSSBox('http://rss.pcworld.com/rss/latestnews.rss',2,false,5);			
		}
		
		



		<!----------------------------------------------------------new sarfaraj start ------------------------------------------------------>
		<!-- box for images start -->
		var htmlContentOfNewBoxImages = '<ul id="countrytabsImages" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">Models</a></li>'+
		'<li><a href="gadgets/ImagesSwimSuit.htm" rel="countrycontainer">Swim Suit</a></li>'+
		'<li><a href="gadgets/ImagesPicasa.htm" rel="countrycontainer">Picasa</a></li>'+
		'<li><a href="gadgets/ImagesHot.htm" rel="#iframe">Hot</a></li>'+
		'<li><a href="gadgets/ImagesBikini.htm" rel="#iframe">Bikini</a></li></ul>'+
		
		'<div id="countrydivcontainerImages" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="http://www.gmodules.com/ig/ifr?url=http://victorias.secret.models.googlepages.com/victoriassecret.xml&amp;amp;synd=open&amp;amp;w=320&amp;amp;h=450&amp;amp;title=Victoria+Secret+Model+of+the+Day&amp;amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;amp;output=js" frameborder="0" scrolling="no" width="100%" height="340"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxImages = 'Image of the day';
		if(!staticObjectArray['staticObjectImages']){	// The box is not stored in cookie - we need to create it.
			var newIndexImages = createABox(2,100,false,'staticObjectImages');
			document.getElementById('dragableBoxContent' + newIndexImages).innerHTML = htmlContentOfNewBoxImages;		
			document.getElementById('dragableBoxContent' + newIndexImages).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexImages).innerHTML = titleOfNewBoxImages;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectImages']).innerHTML = htmlContentOfNewBoxImages;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectImages']).innerHTML = titleOfNewBoxImages;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectImages']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsImages", "countrydivcontainerImages")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for Images end -->
		
		
		<!-- box for miscellaneous start -->
		var htmlContentOfNewBoxMiss = '<ul id="countrytabsMiss" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">Weather</a></li>'+
		'<li><a href="gadgets/MiscellaneousWorldClock.htm" rel="countrycontainer">World Clock</a></li>'+
		'<li><a href="gadgets/MiscellaneousIPAddress.htm" rel="countrycontainer">IP Address</a></li>'+
		'<li><a href="gadgets/MiscellaneousRadio.htm" rel="#iframe">Radio</a></li></ul>'+
		
		'<div id="countrydivcontainerMiss" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="http://www.gmodules.com/ig/ifr?url=http://www.labpixies.com/campaigns/weather/weather.xml&amp;amp;up_degree_unit_type=0&amp;amp;up_first_load=1&amp;amp;up_locations=0&amp;amp;up_zip_code=0&amp;amp;up_city_code=0&amp;amp;up_disable_os=0&amp;amp;synd=open&amp;amp;w=320&amp;amp;h=250&amp;amp;title=Live+Weather&amp;amp;lang=all&amp;amp;country=ALL&amp;amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;amp;output=js" frameborder="0" scrolling="no" width="100%" height="232"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxMiss = 'Miscellaneous';
		if(!staticObjectArray['staticObjectMiss']){	// The box is not stored in cookie - we need to create it.
			var newIndexMiss = createABox(1,100,false,'staticObjectMiss');
			document.getElementById('dragableBoxContent' + newIndexMiss).innerHTML = htmlContentOfNewBoxMiss;		
			document.getElementById('dragableBoxContent' + newIndexMiss).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexMiss).innerHTML = titleOfNewBoxMiss;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectMiss']).innerHTML = htmlContentOfNewBoxMiss;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectMiss']).innerHTML = titleOfNewBoxMiss;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectMiss']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsMiss", "countrydivcontainerMiss")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for miscellaneous end -->
		
		
		<!-- box for messenger start -->
		var htmlContentOfNewBoxMsngr = '<ul id="countrytabsMsngr" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">G Talk</a></li>'+
		'<li><a href="gadgets/MessengerYahooMsngr.htm" rel="countrycontainer">Yahoo Msngr</a></li>'+
		'<li><a href="gadgets/MessengerLiveMessenger.htm" rel="#iframe">Live Messenger</a></li></ul>'+
		
		'<div id="countrydivcontainerMsngr" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/googletalk.xml&amp;amp;synd=open&amp;amp;w=320&amp;amp;h=500&amp;amp;title=__MSG_title__&amp;amp;lang=en&amp;amp;country=US&amp;amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;amp;output=js" frameborder="0" scrolling="auto" width="100%" height="500"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxMsngr = 'Messenger';
		if(!staticObjectArray['staticObjectMsngr']){	// The box is not stored in cookie - we need to create it.
			var newIndexMsngr = createABox(3,100,false,'staticObjectMsngr');
			document.getElementById('dragableBoxContent' + newIndexMsngr).innerHTML = htmlContentOfNewBoxMsngr;		
			document.getElementById('dragableBoxContent' + newIndexMsngr).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexMsngr).innerHTML = titleOfNewBoxMsngr;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectMsngr']).innerHTML = htmlContentOfNewBoxMsngr;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectMsngr']).innerHTML = titleOfNewBoxMsngr;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectMsngr']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsMsngr", "countrydivcontainerMsngr")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for messenger end -->
		
		
		<!-- box for video start -->
		var htmlContentOfNewBoxVideo = '<ul id="countrytabsVideo" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">YouTube</a></li>'+
		'<li><a href="gadgets/VideoYouTube2.htm" rel="countrycontainer">YouTube 2</a></li>'+
		'<li><a href="gadgets/VideoDailyMotion.htm" rel="#iframe">Daily Motion</a></li></ul>'+
		
		'<div id="countrydivcontainerVideo" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="http://www.gmodules.com/ig/ifr?url=http://www.labpixies.com/campaigns/youtube/youtube.xml&amp;amp;up_my_clips=none&amp;amp;synd=open&amp;amp;w=320&amp;amp;h=335&amp;amp;title=YouTube+Top+Videos&amp;amp;lang=all&amp;amp;country=ALL&amp;amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;amp;output=js" frameborder="0" scrolling="auto" width="100%" height="345"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxVideo = 'Video';
		if(!staticObjectArray['staticObjectVideo']){	// The box is not stored in cookie - we need to create it.
			var newIndexVideo = createABox(3,100,false,'staticObjectVideo');
			document.getElementById('dragableBoxContent' + newIndexVideo).innerHTML = htmlContentOfNewBoxVideo;		
			document.getElementById('dragableBoxContent' + newIndexVideo).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexVideo).innerHTML = titleOfNewBoxVideo;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectVideo']).innerHTML = htmlContentOfNewBoxVideo;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectVideo']).innerHTML = titleOfNewBoxVideo;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectVideo']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsVideo", "countrydivcontainerVideo")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for video end -->
		
		
		<!-- box for services start -->
		var htmlContentOfNewBoxServices = '<ul id="countrytabsServices" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">In.com</a></li>'+
		'<li><a href="gadgets/ServicesRediff.htm" rel="countrycontainer">Rediff</a></li>'+
		'<li><a href="gadgets/ServicesAOL.htm" rel="#iframe">AOL</a></li></ul>'+
		
		'<div id="countrydivcontainerServices" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="http://m.in.com/" frameborder="0" scrolling="auto" width="100%" height="345"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxServices = 'Services';
		if(!staticObjectArray['staticObjectServices']){	// The box is not stored in cookie - we need to create it.
			var newIndexServices = createABox(3,100,false,'staticObjectServices');
			document.getElementById('dragableBoxContent' + newIndexServices).innerHTML = htmlContentOfNewBoxServices;		
			document.getElementById('dragableBoxContent' + newIndexServices).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexServices).innerHTML = titleOfNewBoxServices;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectServices']).innerHTML = htmlContentOfNewBoxServices;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectServices']).innerHTML = titleOfNewBoxServices;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectServices']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsServices", "countrydivcontainerServices")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for services end -->
		
		
		<!-- box for web search  start -->
		var htmlContentOfNewBoxS = '<ul id="countrytabsS" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">Yahoo</a></li>'+
		'<li><a href="gadgets/WebSearchBing.htm" rel="countrycontainer">Bing</a></li>'+
		'<li><a href="gadgets/WebSearchGoogle.htm" rel="countrycontainer">Google</a></li>'+
		'<li><a href="gadgets/WebSearchAsk.htm" rel="#iframe">Ask</a></li></ul>'+
		
		'<div id="countrydivcontainerS" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="http://www.gmodules.com/ig/ifr?url=http://fe.shortcuts.search.yahoo.com/googlegadget.xml&amp;amp;up_query=&amp;amp;synd=open&amp;amp;w=400&amp;amp;h=500&amp;amp;title=Yahoo!+Shortcuts&amp;amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;amp;output=js" frameborder="0" scrolling="no" width="100%" height="400" marginheight="0" marginwidth="0"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxS = 'Web Search';
		if(!staticObjectArray['staticObjectS']){	// The box is not stored in cookie - we need to create it.
			var newIndexS = createABox(3,100,false,'staticObjectS');
			document.getElementById('dragableBoxContent' + newIndexS).innerHTML = htmlContentOfNewBoxS;		
			document.getElementById('dragableBoxContent' + newIndexS).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexS).innerHTML = titleOfNewBoxS;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectS']).innerHTML = htmlContentOfNewBoxS;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectS']).innerHTML = titleOfNewBoxS;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectS']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsS", "countrydivcontainerS")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for web search end -->
		
		
		<!-- box for community start -->
		var htmlContentOfNewBoxCmnty = '<ul id="countrytabsCmnty" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">Orkut</a></li>'+
		'<li><a href="gadgets/CommunityMySpace.htm" rel="countrycontainer">MySpace</a></li>'+
		'<li><a href="gadgets/CommunityFacebook.htm" rel="countrycontainer">Facebook</a></li>'+
		'<li><a href="gadgets/CommunityAnswers.htm" rel="countrycontainer">Answers</a></li>'+
		'<li><a href="gadgets/Communityhi5.htm" rel="#iframe">hi5</a></li></ul>'+
		
		'<div id="countrydivcontainerCmnty" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="http://m.orkut.com/" frameborder="0" scrolling="auto" width="100%" height="345"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxCmnty = 'Community';
		if(!staticObjectArray['staticObjectCmnty']){	// The box is not stored in cookie - we need to create it.
			var newIndexCmnty = createABox(3,100,false,'staticObjectCmnty');
			document.getElementById('dragableBoxContent' + newIndexCmnty).innerHTML = htmlContentOfNewBoxCmnty;		
			document.getElementById('dragableBoxContent' + newIndexCmnty).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexCmnty).innerHTML = titleOfNewBoxCmnty;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectCmnty']).innerHTML = htmlContentOfNewBoxCmnty;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectCmnty']).innerHTML = titleOfNewBoxCmnty;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectCmnty']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsCmnty", "countrydivcontainerCmnty")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for community end -->
		
		
		<!-- box for reminder start -->
		var htmlContentOfNewBoxRmndr = '<ul id="countrytabsRmndr" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">Set Alarm</a></li>'+
		'<li><a href="gadgets/ReminderToDoList.htm" rel="countrycontainer">To Do List</a></li>'+
		'<li><a href="gadgets/ReminderBirthday.htm" rel="countrycontainer">Birthday</a></li>'+
		'<li><a href="gadgets/ReminderAlert.htm" rel="#iframe">Alert</a></li></ul>'+
		
		'<div id="countrydivcontainerRmndr" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="http://www.gmodules.com/ig/ifr?url=http://znupi69.googlepages.com/clock.xml&amp;amp;up_alarmSet=false&amp;amp;up_alarmHour=0&amp;amp;up_alarmMinute=0&amp;amp;up_ctype=ampm&amp;amp;up_ctheme=purple&amp;amp;up_songURL=&amp;amp;synd=open&amp;amp;w=400&amp;amp;h=160&amp;amp;title=Alarm+Clock&amp;amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;amp;output=js" frameborder="0" scrolling="no" width="100%" height="160"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxRmndr = 'Reminder';
		if(!staticObjectArray['staticObjectRmndr']){	// The box is not stored in cookie - we need to create it.
			var newIndexRmndr = createABox(1,100,false,'staticObjectRmndr');
			document.getElementById('dragableBoxContent' + newIndexRmndr).innerHTML = htmlContentOfNewBoxRmndr;		
			document.getElementById('dragableBoxContent' + newIndexRmndr).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexRmndr).innerHTML = titleOfNewBoxRmndr;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectRmndr']).innerHTML = htmlContentOfNewBoxRmndr;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectRmndr']).innerHTML = titleOfNewBoxRmndr;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectRmndr']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsRmndr", "countrydivcontainerRmndr")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for reminder end -->
		
		
		<!-- box for mail start -->
		var htmlContentOfNewBoxMail = '<ul id="countrytabsMail" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">Gmail</a></li>'+
		'<li><a href="gadgets/MailServicesLive.htm" rel="countrycontainer">Windows Live</a></li>'+
		'<li><a href="gadgets/MailServicesYahoo.htm" rel="#iframe">Yahoo! Mail</a></li></ul>'+
		
		'<div id="countrydivcontainerMail" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="https://www.google.com/accounts/ServiceLogin?service=mail&amp;passive=true&amp;continue=http%3A%2F%2Fmail.google.com%2Fmail%2Fx%2F1mcym8lo2weqh%2F%3Fui%3Dhtml%26zy%3Dl&amp;bsv=zpwhtygjntrz&amp;scc=1&amp;ltmpl=ecobh&amp;hl=en&amp;nui=5&amp;btmpl=mobile" frameborder="0" scrolling="auto" width="100%" height="270"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxMail = 'Mail Services';
		if(!staticObjectArray['staticObjectMail']){	// The box is not stored in cookie - we need to create it.
			var newIndexMail = createABox(1,100,false,'staticObjectMail');
			document.getElementById('dragableBoxContent' + newIndexMail).innerHTML = htmlContentOfNewBoxMail;		
			document.getElementById('dragableBoxContent' + newIndexMail).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexMail).innerHTML = titleOfNewBoxMail;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectMail']).innerHTML = htmlContentOfNewBoxMail;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectMail']).innerHTML = titleOfNewBoxMail;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectMail']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsMail", "countrydivcontainerMail")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for mail end -->
		
		
		<!-- box for jobs start -->
		var htmlContentOfNewBoxJobs = '<ul id="countrytabsJobs" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">Monster India</a></li>'+
		'<li><a href="gadgets/JobsNaukri.htm" rel="countrycontainer">Naukri.com</a></li>'+
		'<li><a href="gadgets/JobsMonster.htm" rel="#iframe">Monster Int.</a></li></ul>'+
		
		'<div id="countrydivcontainerJobs" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="http://m.monsterindia.com/" frameborder="0" scrolling="auto" width="100%" height="355"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxJobs = 'Jobs';
		if(!staticObjectArray['staticObjectJobs']){	// The box is not stored in cookie - we need to create it.
			var newIndexJobs = createABox(1,100,false,'staticObjectJobs');
			document.getElementById('dragableBoxContent' + newIndexJobs).innerHTML = htmlContentOfNewBoxJobs;		
			document.getElementById('dragableBoxContent' + newIndexJobs).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexJobs).innerHTML = titleOfNewBoxJobs;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectJobs']).innerHTML = htmlContentOfNewBoxJobs;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectJobs']).innerHTML = titleOfNewBoxJobs;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectJobs']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsJobs", "countrydivcontainerJobs")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for jobs end -->
		
		
		<!-- box for important start -->
		var htmlContentOfNewBoxImprt = '<ul id="countrytabsImprt" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">Translate</a></li>'+
		'<li><a href="gadgets/ImportantCurrencyConverter.htm" rel="countrycontainer">Currency Converter</a></li>'+
		'<li><a href="gadgets/ImportantUnitConverter.htm" rel="#iframe">Unit Converter</a></li></ul>'+
		
		'<div id="countrydivcontainerImprt" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="http://www.gmodules.com/ig/ifr?url=http://www.geocities.com/boaz_haberman/translate.xml&amp;amp;up_defaultSource=&amp;amp;up_defaultTarget=&amp;amp;synd=open&amp;amp;w=400&amp;amp;h=300&amp;amp;title=Google+Translate&amp;amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;amp;output=js" frameborder="0" scrolling="auto" width="100%" height="200"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxImprt = 'Important';
		if(!staticObjectArray['staticObjectImprt']){	// The box is not stored in cookie - we need to create it.
			var newIndexImprt = createABox(1,100,false,'staticObjectImprt');
			document.getElementById('dragableBoxContent' + newIndexImprt).innerHTML = htmlContentOfNewBoxImprt;		
			document.getElementById('dragableBoxContent' + newIndexImprt).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexImprt).innerHTML = titleOfNewBoxImprt;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectImprt']).innerHTML = htmlContentOfNewBoxImprt;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectImprt']).innerHTML = titleOfNewBoxImprt;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectImprt']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsImprt", "countrydivcontainerImprt")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for important end -->
		
		
		<!-- box for information start -->
		var htmlContentOfNewBoxInfo = '<ul id="countrytabsInfo" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">Horoscope</a></li>'+
		'<li><a href="gadgets/InformationWorldTime.htm" rel="countrycontainer">World Time</a></li>'+
		'<li><a href="gadgets/InformationPopulation.htm" rel="#iframe">World Population</a></li></ul>'+
		
		'<div id="countrydivcontainerInfo" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="http://www.gmodules.com/ig/ifr?url=http://www.labpixies.com/campaigns/horoscope/horoscope.xml&amp;amp;up_k1=&amp;amp;up_k2=&amp;amp;up_k3=&amp;amp;up_owner_settings=&amp;amp;up_last_item_id=&amp;amp;up_last_item_id_date=&amp;amp;up_filter_type=&amp;amp;up_total_count=0&amp;amp;synd=open&amp;amp;w=320&amp;amp;h=240&amp;amp;title=__MSG_title__&amp;amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;amp;output=js" frameborder="0" scrolling="no" width="100%" height="175"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxInfo = 'Information';
		if(!staticObjectArray['staticObjectInfo']){	// The box is not stored in cookie - we need to create it.
			var newIndexInfo = createABox(1,100,false,'staticObjectInfo');
			document.getElementById('dragableBoxContent' + newIndexInfo).innerHTML = htmlContentOfNewBoxInfo;		
			document.getElementById('dragableBoxContent' + newIndexInfo).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexInfo).innerHTML = titleOfNewBoxInfo;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectInfo']).innerHTML = htmlContentOfNewBoxInfo;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectInfo']).innerHTML = titleOfNewBoxInfo;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectInfo']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsInfo", "countrydivcontainerInfo")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for information end -->
		
		
		<!-- box for OtherNews start -->
		var htmlContentOfNewBoxOtherNews = '<ul id="countrytabsOtherNews" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">BBC</a></li>'+
		'<li><a href="gadgets/NwsHdlnsCricInfo.htm" rel="countrycontainer">CricInfo</a></li>'+
		'<li><a href="gadgets/NwsHdlnsDigg.htm" rel="countrycontainer">Digg</a></li>'+
		'<li><a href="gadgets/NwsHdlnsFoxNews.htm" rel="countrycontainer">FoxNews</a></li>'+
		'<li><a href="gadgets/NwsHdlnsWeather.htm" rel="#iframe">Weather</a></li></ul>'+
		
		'<div id="countrydivcontainerOtherNews" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="http://www.bbc.co.uk/mobile/i/" frameborder="0" scrolling="auto" width="100%" height="285"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxOtherNews = 'News Headlines';
		if(!staticObjectArray['staticObjectOtherNews']){	// The box is not stored in cookie - we need to create it.
			var newIndexOtherNews = createABox(2,100,false,'staticObjectOtherNews');
			document.getElementById('dragableBoxContent' + newIndexOtherNews).innerHTML = htmlContentOfNewBoxOtherNews;		
			document.getElementById('dragableBoxContent' + newIndexOtherNews).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexOtherNews).innerHTML = titleOfNewBoxOtherNews;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectOtherNews']).innerHTML = htmlContentOfNewBoxOtherNews;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectOtherNews']).innerHTML = titleOfNewBoxOtherNews;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectOtherNews']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsOtherNews", "countrydivcontainerOtherNews")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for OtherNews end -->
		
		
		<!-- box for services1 start -->
		var htmlContentOfNewBoxServices1 = '<ul id="countrytabsServices1" class="shadetabs">'+
		'<li><a href="#" rel="#default" class="selected">Ebay</a></li>'+
		'<li><a href="gadgets/Services1Flickr.htm" rel="countrycontainer">Flickr</a></li>'+
		'<li><a href="gadgets/Services1Photobucket.htm" rel="countrycontainer">Photobucket</a></li>'+
		'<li><a href="gadgets/Services1Friendster.htm" rel="#iframe">Friendster</a></li></ul>'+
		
		'<div id="countrydivcontainerServices1" style="background:#ffffff;padding:5px; margin-top:3px;"><iframe src="http://m.ebay.com/" frameborder="0" scrolling="auto" width="100%" height="285"></iframe></div>';

		// HTML content of new box
		
		var titleOfNewBoxServices1 = 'Services';
		if(!staticObjectArray['staticObjectServices1']){	// The box is not stored in cookie - we need to create it.
			var newIndexServices1 = createABox(2,100,false,'staticObjectServices1');
			document.getElementById('dragableBoxContent' + newIndexServices1).innerHTML = htmlContentOfNewBoxServices1;		
			document.getElementById('dragableBoxContent' + newIndexServices1).style.backgroundColor = "#868686";
			document.getElementById('dragableBoxHeader_txt' + newIndexServices1).innerHTML = titleOfNewBoxServices1;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectServices1']).innerHTML = htmlContentOfNewBoxServices1;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObjectServices1']).innerHTML = titleOfNewBoxServices1;	
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObjectServices1']).style.backgroundColor = "#868686";
			
		}
		var countries=new ddajaxtabs("countrytabsServices1", "countrydivcontainerServices1")
		countries.setpersist(true)
		countries.setselectedClassTarget("link") //"link" or "linkparent"
		countries.init()
		<!-- box for services1 end -->
		
		
		/* Create static boxes */
		var htmlContentOfNewBox = '<DIV><iframe src="google_ad.html" width="250" height="250" frameborder="0" scrolling="no" /></div>';	// HTML content of new box
		var titleOfNewBox = 'Google Sponsered Link 1';
		if(!staticObjectArray['staticObject1']){	// The box is not stored in cookie - we need to create it.
			var newIndex = createABox(1,50,false,'staticObject1');
			document.getElementById('dragableBoxContent' + newIndex).innerHTML = htmlContentOfNewBox;		
			document.getElementById('dragableBoxHeader_txt' + newIndex).innerHTML = titleOfNewBox;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObject1']).innerHTML = htmlContentOfNewBox;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObject1']).innerHTML = titleOfNewBox;	
			
		}
		<!---------------------------------------------------------- new sarfaraj end  ------------------------------------------------------>
		
		
		
		
		
		
		
		
		
		hideHeaderOptionsForStaticBoxes(staticObjectArray['staticObject1']);
		
		var htmlContentOfNewBox = '<DIV><iframe src="google_ad.html" width="250" height="250" frameborder="0" scrolling="no" /></div>';	// HTML content of new box
		var titleOfNewBox = 'Google Sponsered Link';
		if(!staticObjectArray['staticObject2']){	// The box is not stored in cookie - we need to create it.
			var newIndex = createABox(2,50,false,'staticObject2',true);	// true as last argument indicates that this box is not dragable
			document.getElementById('dragableBoxContent' + newIndex).innerHTML = htmlContentOfNewBox;		
			document.getElementById('dragableBoxHeader_txt' + newIndex).innerHTML = titleOfNewBox;		
		}else{	// Box is stored in cookie - all we have to do is to move content into it.
			document.getElementById('dragableBoxContent' + staticObjectArray['staticObject2']).innerHTML = htmlContentOfNewBox;	
			document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObject2']).innerHTML = titleOfNewBox;
			disableBoxDrag(	staticObjectArray['staticObject2']);	// Not dragable

		}
		hideHeaderOptionsForStaticBoxes(staticObjectArray['staticObject2']);		
		
		setTimeout('saveCookies()',100);
		
	}
		
	/* Disable drag for a box */
	function disableBoxDrag(boxIndex)
	{
			document.getElementById('dragableBoxHeader' + boxIndex).onmousedown = '';
			document.getElementById('dragableBoxHeader' + boxIndex).style.cursor = 'default';		
		
	}
	
	
	function initDragableBoxesScript()
	{
		document.getElementById('pagepreloader').style.display = "none";
		createColumns();	// Always the first line of this function
		createHelpObjects();	// Always the second line of this function
		initEvents();	// Always the third line of this function
		
		if(useCookiesToRememberRSSSources)createRSSBoxesFromCookie();	// Create RSS boxes from cookies
		createDefaultBoxes();	// Create default boxes.


		
	}

	
	
	
	window.onload = initDragableBoxesScript;
	
	
	
	//** Ajax Tabs Content script v2.0- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
//** Updated Oct 21st, 07 to version 2.0. Contains numerous improvements
//** Updated Feb 18th, 08 to version 2.1: Adds a public "tabinstance.cycleit(dir)" method to cycle forward or backward between tabs dynamically. Only .js file changed from v2.0.
//** Updated April 8th, 08 to version 2.2:
//   -Adds support for expanding a tab using a URL parameter (ie: http://mysite.com/tabcontent.htm?tabinterfaceid=0) 
//   -Modified Ajax routine so testing the script out locally in IE7 now works 

var ddajaxtabssettings={}
ddajaxtabssettings.bustcachevar=1  //bust potential caching of external pages after initial request? (1=yes, 0=no)
ddajaxtabssettings.loadstatustext="<img src='ajaxtabs/loading.gif' /> Requesting content..." 


////NO NEED TO EDIT BELOW////////////////////////

function ddajaxtabs(tabinterfaceid, contentdivid){
	this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container
	this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container
	this.enabletabpersistence=true
	this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
	this.currentTabIndex=0 //Index of currently selected hot tab (tab with sub content) within hottabspositions[] array
	this.contentdivid=contentdivid
	this.defaultHTML=""
	this.defaultIframe='<iframe src="about:blank" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" class="tabcontentiframe" style="width:100%; height:auto; min-height: 100px"></iframe>'
	this.defaultIframe=this.defaultIframe.replace(/<iframe/i, '<iframe name="'+"_ddajaxtabsiframe-"+contentdivid+'" ')
this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
	this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")
}

ddajaxtabs.connect=function(pageurl, tabinstance){
	var page_request = false
	var bustcacheparameter=""
	if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else
		return false
	var ajaxfriendlyurl=pageurl.replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/") 
	page_request.onreadystatechange=function(){ddajaxtabs.loadpage(page_request, pageurl, tabinstance)}
	if (ddajaxtabssettings.bustcachevar) //if bust caching of external page
		bustcacheparameter=(ajaxfriendlyurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', ajaxfriendlyurl+bustcacheparameter, true)
	page_request.send(null)
}

ddajaxtabs.loadpage=function(page_request, pageurl, tabinstance){
	var divId=tabinstance.contentdivid
	document.getElementById(divId).innerHTML=ddajaxtabssettings.loadstatustext //Display "fetching page message"
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
		document.getElementById(divId).innerHTML=page_request.responseText
		ddajaxtabs.ajaxpageloadaction(pageurl, tabinstance)
	}
}

ddajaxtabs.ajaxpageloadaction=function(pageurl, tabinstance){
	tabinstance.onajaxpageload(pageurl) //call user customized onajaxpageload() function when an ajax page is fetched/ loaded
}

ddajaxtabs.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

ddajaxtabs.setCookie=function(name, value){
	document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
}

ddajaxtabs.prototype={

	expandit:function(tabid_or_position){ //PUBLIC function to select a tab either by its ID or position(int) within its peers
		this.cancelautorun() //stop auto cycling of tabs (if running)
		var tabref=""
		try{
			if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=document.getElementById(tabid_or_position)
			else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=this.tabs[tabid_or_position]
		}
		catch(err){alert("Invalid Tab ID or position entered!")}
		if (tabref!="") //if a valid tab is found based on function parameter
			this.expandtab(tabref) //expand this tab
	},

	cycleit:function(dir, autorun){ //PUBLIC function to move foward or backwards through each hot tab (tabinstance.cycleit('foward/back') )
		if (dir=="next"){
			var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1 : 0
		}
		else if (dir=="prev"){
			var currentTabIndex=(this.currentTabIndex>0)? this.currentTabIndex-1 : this.hottabspositions.length-1
		}
		if (typeof autorun=="undefined") //if cycleit() is being called by user, versus autorun() function
			this.cancelautorun() //stop auto cycling of tabs (if running)
		this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]])
	},

	setpersist:function(bool){ //PUBLIC function to toggle persistence feature
			this.enabletabpersistence=bool
	},

	loadajaxpage:function(pageurl){ //PUBLIC function to fetch a page via Ajax and display it within the Tab Content instance's container
		ddajaxtabs.connect(pageurl, this)
	},

	loadiframepage:function(pageurl){ //PUBLIC function to fetch a page and load it into the IFRAME of the Tab Content instance's container
		this.iframedisplay(pageurl, this.contentdivid)
	},

	setselectedClassTarget:function(objstr){ //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")
		this.selectedClassTarget=objstr || "link"
	},

	getselectedClassTarget:function(tabref){ //Returns target element to assign "selected" CSS class to
		return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref
	},

	urlparamselect:function(tabinterfaceid){
		var result=window.location.search.match(new RegExp(tabinterfaceid+"=(\\d+)", "i")) //check for "?tabinterfaceid=2" in URL
		return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index
	},

	onajaxpageload:function(pageurl){ //PUBLIC Event handler that can invoke custom code whenever an Ajax page has been fetched and displayed
		//do nothing by default
	},

	expandtab:function(tabref){
		var relattrvalue=tabref.getAttribute("rel")
		//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easy searching through
		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
		if (relattrvalue=="#default")
			document.getElementById(this.contentdivid).innerHTML=this.defaultHTML
		else if (relattrvalue=="#iframe")
			this.iframedisplay(tabref.getAttribute("href"), this.contentdivid)
		else
			ddajaxtabs.connect(tabref.getAttribute("href"), this)
		this.expandrevcontent(associatedrevids)
		for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("href")==tabref.getAttribute("href"))? "selected" : ""
		}
		if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
			ddajaxtabs.setCookie(this.tabinterfaceid, tabref.tabposition)
		this.setcurrenttabindex(tabref.tabposition) //remember position of selected tab within hottabspositions[] array
	},

	iframedisplay:function(pageurl, contentdivid){
		if (typeof window.frames["_ddajaxtabsiframe-"+contentdivid]!="undefined"){
			try{delete window.frames["_ddajaxtabsiframe-"+contentdivid]} //delete iframe within Tab content container if it exists (due to bug in Firefox)
			catch(err){}
		}
		document.getElementById(contentdivid).innerHTML=this.defaultIframe
		window.frames["_ddajaxtabsiframe-"+contentdivid].location.replace(pageurl) //load desired page into iframe
	},


	expandrevcontent:function(associatedrevids){
		var allrevids=this.revcontentids
		for (var i=0; i<allrevids.length; i++){ //Loop through rev attributes for all tabs in this tab interface
			//if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it
			document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"
		}
	},

	setcurrenttabindex:function(tabposition){ //store current position of tab (within hottabspositions[] array)
		for (var i=0; i<this.hottabspositions.length; i++){
			if (tabposition==this.hottabspositions[i]){
				this.currentTabIndex=i
				break
			}
		}
	},

	autorun:function(){ //function to auto cycle through and select tabs based on a set interval
		this.cycleit('next', true)
	},

	cancelautorun:function(){
		if (typeof this.autoruntimer!="undefined")
			clearInterval(this.autoruntimer)
	},

	init:function(automodeperiod){
		var persistedtab=ddajaxtabs.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
		var selectedtab=-1 //Currently selected tab index (-1 meaning none)
		var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid) //returns null or index from: tabcontent.htm?tabinterfaceid=index
		this.automodeperiod=automodeperiod || 0
		this.defaultHTML=document.getElementById(this.contentdivid).innerHTML
		for (var i=0; i<this.tabs.length; i++){
			this.tabs[i].tabposition=i //remember position of tab relative to its peers
			if (this.tabs[i].getAttribute("rel")){
				var tabinstance=this
				this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
				this.tabs[i].onclick=function(){
					tabinstance.expandtab(this)
					tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
					return false
				}
				if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element
					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
				}
				if (selectedtabfromurl==i || this.enabletabpersistence && selectedtab==-1 && parseInt(persistedtab)==i || !this.enabletabpersistence && selectedtab==-1 && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
					selectedtab=i //Selected tab index, if found
				}
			}
		} //END for loop
		if (selectedtab!=-1) //if a valid default selected tab index is found
			this.expandtab(this.tabs[selectedtab]) //expand selected tab (either from URL parameter, persistent feature, or class="selected" class)
		else //if no valid default selected index found
			this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr
		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
		}
	} //END int() function

} //END Prototype assignment
