
var authWindow = null;
function verisignWindow(){

	if(typeof(authWindow) != "undefined" && authWindow &&!authWindow.closed)
	{
		authWindow.location.href = "https://seal.verisign.com/splash?form_file=fdf/splash.fdf&dn=ADVERTISING.SUPERPAGES.COM&lang=en";
		authWindow.focus();
	}
	else	
		authWindow = window.open("https://seal.verisign.com/splash?form_file=fdf/splash.fdf&dn=ADVERTISING.SUPERPAGES.COM&lang=en","Verisign","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=558, height=620");
}

function trusteWindow(){

	if(typeof(authWindow) != "undefined" && authWindow &&!authWindow.closed)
	{
		authWindow.location.href = "http://www.truste.org/ivalidate.php?url=advertising.superpages.com&sealid=101";
		authWindow.focus();
	}
	else
		authWindow = window.open("http://www.truste.org/ivalidate.php?url=advertising.superpages.com&sealid=101 ","TRUSTe","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=558, height=620");
}

function hackerSafeWindow(){
	if(typeof(authWindow) != "undefined" && authWindow &&!authWindow.closed)
	{
		authWindow.location.href = "https://www.scanalert.com/RatingVerify?ref=advertising.superpages.com";
		authWindow.focus();
	}
	else
		authWindow = window.open("https://www.scanalert.com/RatingVerify?ref=advertising.superpages.com","HackerSafe","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no");
}
function showQuickClose()
     {
        if ( quickCloseFlag=="true" )
        {
            //alert('true');
            quickClose();
            return true;
        }
        else
        {
            //alert('false');
            return false;
        }
     }



    function confirmSignOut()
    {
        setSignOutClick(true);

        var confirm = window.confirm("Are you sure you want to sign-out?");
        if(confirm)
        {
           return true;
        }
        else
        {
            return false;
        }
    }


//Enter-listener
//if the user presses ENTER KEY submit the Form
function headerSignIn(e, currentForm, action){
    var characterCode;
   
   if(e.which )
        characterCode = e.which ;
   else
   		characterCode = e.keyCode;

    if(characterCode == 13){ //13 = the code for pressing ENTER
        submitForm(currentForm, action);
    }
    else{
        return true ;
    }
}
// function to open Zoomerang Survey popup
function popUpOptIn(signOut)
{
    var targetURL='/spweb/pageflows/myaccount/surveys/zoomerang/optInPopUp.jsp';
    popWin = window.open(targetURL,"SuperPagesZoomerangSurvey","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=690, height=430");
    initPopUpBlockerTimer();
}

// global onclick form submit functions
function enterSubmit(e, action, currentForm, requiredFields)
{	
    var characterCode;
			
    if(e.which )
        characterCode = e.which ;
    else
   		characterCode = e.keyCode;
    
    if(characterCode == 13){ //13 = the code for pressing ENTER 				
        if(fieldValidator(currentForm, requiredFields))
        {
        	submitForm(currentForm,action);
        }
        return false;
    }
    return true;  
}


function enterForgotPwdSubmit(e, action, currentForm, requiredFields)
{
    var characterCode;
			
    if(e.which )
        characterCode = e.which ;
    else
   		characterCode = e.keyCode;
    
    if(characterCode == 13){ //13 = the code for pressing ENTER 				
        submitForm(currentForm,action);          
     }
    return true;  
}

// global onclick form submit functions
function validateEnterKey(e)
{
    var characterCode;
			
    if(e.which )
        characterCode = e.which ;
    else
   		characterCode = e.keyCode;
    
    if(characterCode == 13){ //13 = the code for pressing ENTER 				        
        return true;
    }
    return false;  
}

function submitForm(currentForm, action)
{ 
	if(currentForm._eventId == null)
	{
		var eventId = document.createElement('input');
		eventId.setAttribute("type", "hidden");
		eventId.setAttribute("name", "_eventId");
		currentForm.appendChild(eventId);
	}
	else
	{
		eventId = currentForm._eventId;
	}
	eventId.value = action;	
    currentForm.submit();
}
        

function submitMultiForm(currentForm, action)
{  
	var eventId = document.createElement('input');
	eventId.setAttribute("type", "hidden");
	eventId.setAttribute("name", "_eventId");
	eventId.value = action;
	currentForm.appendChild(eventId);      
    currentForm.encoding='multipart/form-data'; 
}

//print Terms and Conditions on the FAQ page
function printTerms(order)  
{           
    var screenwidth = window.screen.width +100;
    var screentop = window.screen.height+10;
    if(order == 'free')
    {
	    var targetURL='../spportal/printfreeterms.do';        
	}
	else
	{
	    var targetURL='../spportal/printterms.do';        	
	}
    var wind = window.open(targetURL,"preview_details","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=50, height=10, left=" + screenwidth +", top=" +screentop+" ")
    wind.blur();   
}

//global required field validator checking for empty fields
function fieldValidator(formObj, requiredFields)
{
	if(formObj != null)
	{
		var flag = true;
		var index = 0;
		for(var i=0; i<requiredFields.length; i++)
		{
			if(formObj[requiredFields[i]] !=null)
			{
				if(formObj[requiredFields[i]].type == 'text' || formObj[requiredFields[i]].type == 'password' || formObj[requiredFields[i]].type == 'textarea')
				{
					if(formObj[requiredFields[i]].value == '')					    
					{    					    
						if(document.getElementById(requiredFields[i]+'-error') != null)
						{						      
							document.getElementById(requiredFields[i]+'-error').style.display = 'block';
							index = i;
						}						
						/*else
						{
							alert('error message ['+requiredFields[i]+'-error] not found');
						}*/
						flag = false;
					}
					else
					{
						if(document.getElementById(requiredFields[i]+'-error') != null)
						{						      
							document.getElementById(requiredFields[i]+'-error').style.display = 'none';
						}	
					}
				}
				else if(formObj[requiredFields[i]].type == 'checkbox')
				{
					if(!formObj[requiredFields[i]].checked)
					{
						if(document.getElementById(requiredFields[i]+'-error') != null)
						{
							document.getElementById(requiredFields[i]+'-error').style.display = 'block';
						}	
						flag = false;
					}		
					else
					{
						if(document.getElementById(requiredFields[i]+'-error') != null)
						{						      
							document.getElementById(requiredFields[i]+'-error').style.display = 'none';
						}	
					}			
				}				
				else if(formObj[requiredFields[i]].type == 'select-one')
				{
					if(formObj[requiredFields[i]].value == 'Select'|| formObj[requiredFields[i]].value=="") 
					{
						if(document.getElementById(requiredFields[i]+'-error') != null)
						{
							document.getElementById(requiredFields[i]+'-error').style.display = 'block';
						}	
						flag = false;
					}		
					else
					{
						if(document.getElementById(requiredFields[i]+'-error') != null)
						{						      
							document.getElementById(requiredFields[i]+'-error').style.display = 'none';
						}	
					}			
				}
			}
			else
			{
				if(requiredFields[i])
				{
					alert('required field ['+requiredFields[i]+'] not found');
					flag = false;
				}
			}
		}
		if(flag == false && document.getElementById('global-error-message') != null)
		{
			document.getElementById('global-error-message').style.display = 'block';
			scroll(0,0);
		}
		return flag;
	}
	else
	{
		alert('form object not found');
		return false;
	}
}

//function to update primary navigation UI
function updatePrimaryNav(index)
{
	if(document.getElementById('sign-in-nav') != null)
    {
	    if(index != 'home')
	    {	    	
	    	document.getElementById('sign-in-nav').style.display = 'block';
	    	if(document.getElementById('contactSalesDiv'))
	    		document.getElementById('contactSalesDiv').style.display = 'block';	    	
	    }
	    else
	    {
	    	document.getElementById('sign-in-nav').style.display = 'none';
	    	if(document.getElementById('contactSalesDiv'))
		    	document.getElementById('contactSalesDiv').style.display = 'none';	    	
	    	if(document.getElementById('sign-in-form') != null) {
     		   document.getElementById('sign-in-form').style.display = 'block';        
		    }
	    }
	}
	if(index != 'home')
	{
    	if(document.getElementById(index+'-nav') != null)
    		document.getElementById(index+'-nav').className = 'navon';
    }
    //if not on homepage remove superpages link
    //'sign-in-nav'is null when user is logged in
    if(index != 'home' || document.getElementById('sign-in-nav')==null ) 
    {    	
    	//remove superpages.com link
    	$('#superpagesLink').removeClass('last-item');
    	$('#superpagesLink').hide();
    	$('#headerNavLast').addClass('last-item');
    }
}
// function to refresh captcha image
function refreshCaptchaImage( ){
	var obj = document.getElementById("captchimgid");
	obj.src='jcaptcha?' + Math.random();
}

function checkMyBill(myBill){
	if(myBill){
		var obj = document.getElementById("myaccount-nav");
		obj.href="myaccount.do?myaccounttab=true";	
	}
}
function appendEmail(formName)
{
	document.forms[formName].action="forgotPwd.do";
	document.forms[formName].submit();
}
//when mouse is on a roll over menu item, change its background to grey 
function mouseoverRoItem(divobj)
{
	clearRolloverTimeout();
	divobj.style.backgroundColor= '#ebebeb';
}
//when mouse moves out of menu item, change its background back to white
function mouseoutRoItem(divobj)
{
	divobj.style.backgroundColor= 'white';
}
var rolloverDisplayTimer=null;
//rollover is displayed under DivId
function clearRolloverTimeout()
{
	clearTimeout(rolloverDisplayTimer);
}
function setRolloverTimeout()
{
	rolloverDisplayTimer= setTimeout('closeRollover2();',1000);
}
function rolloverOn(divId,targetDiv)
{
	var offsets= $("#"+divId).offset(); //get offsets of current div
	var targetDivObj= document.getElementById(targetDiv);
	var width=$("#"+divId).outerWidth()+(divId=='online-nav'?7:12);
	width= (width>0?width+5:123);//we need 2px adjustments
	var top=parseInt(offsets.top,10)+37;
	
	//cross browser
	if (jQuery.browser.msie)
	{
		offsets.left-=3;
		top-=2;
	}
	else 
		offsets.left-=1;
	
	$("#rolloverHolder").html(targetDivObj.innerHTML);
	$("#rolloverHolder").css('left',offsets.left+"px");
	$("#rolloverHolder").css('top',top+"px");
	if(divId == 'report-nav')
		$("#rolloverHolder").css('width',width+15+"px");
	else if(divId == 'tools-nav')
		$("#rolloverHolder").css('width',width+35+"px");
	else
		$("#rolloverHolder").css('width',width+"px");
	$("#rolloverHolder").slideDown(75);
	clearRolloverTimeout();
}
function closeRollover2()
{
	clearRolloverTimeout();	
	$("#rolloverHolder").slideUp(75);
}
function showRollover()
{
	clearRolloverTimeout();
	//$("#rolloverHolder").show(300);
}
//change flash video
function changeVideo(url)
{
  document.getElementById('spVideo').innerHTML = 
  "<embed src='"+url+"' quality='high' bgcolor='#e4eaf0' width='240' height='200' name='localPlayer' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
}

function changeFlv(url, autoplay)
{
	 /*
		use flashembed to place flowplayer into HTML element 
		whose id is "example" (below this script tag)
	 */
	 flashembed("spVideo", 
	
		/* 
			first argument supplies standard Flash parameters. See full list:
			http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12701
		*/
		{
			src:'/spportal/img-spportal/flash/FlowPlayerDark.swf',
			width: 240, 
			height: 200
		},
		
		/*
			second argument is Flowplayer specific configuration. See full list:
			http://flowplayer.org/player/configuration.html
		*/
		{config: {   
			autoPlay: autoplay,
			loop: false,
			showFullScreenButton: false,
			showStopButton: true,
			showMenu: false,
			autoBuffering: true,
			controlBarBackgroundColor:'0x606060',
			initialScale: 'scale',
			initialVolumePercentage: 100,
			videoFile: url
		}} 
	);
}
/*
This function manages tabbed navigation by showing selectionId element
and hiding all others whose Ids are in idArray
And it also sets class of element with id selectionId+'-nav' to navOnClass
and all other -navs to navOffClass
The function uses the following naming convention:
if content id is 'mycontent' then its navigation tab id should be 'mycontent-nav'
If this convention is not followed the navIdArray should contain corresponding Ids of navigation tabs
*/
function tabbedNavigationShow(selectionId,idArray,navOffClass,navOnClass,navIdArray)
{
	for(var i=0;i<idArray.length;i++)
	{
		if(navIdArray)
			$('#'+navIdArray[i]).attr('class',navOffClass);
		else
			$('#'+idArray[i]+'-nav').attr('class',navOffClass);
		if(selectionId!=idArray[i])
			$('#'+idArray[i]).hide();
		else
		{
			if(navIdArray)
				$('#'+navIdArray[i]).attr('class',navOnClass);
			else
				$('#'+selectionId+'-nav').attr('class',navOnClass);
			$('#'+selectionId).fadeIn(500);	
		}			
	}
}
function pPage2_popup(this_tr,id,xoff)
{	
	//This code automatically adds tooltip 'holder div' first time this function is invoked
	if(!document.getElementById('portal-ToolTipHolder'))
	{
		if(document.getElementById('content'))
			$("<div id='portal-ToolTipHolder'></div>").appendTo("#content");
		else
			$("<div id='portal-ToolTipHolder'></div>").appendTo("body");
		$("#portal-ToolTipHolder").hide();
	}
	var pos= $(this_tr).position();
	var x= pos.left+ xoff,y=pos.top+20;//coordinates of the pop up div	
	$('#portal-ToolTipHolder').load("./jsp/alltooltips.jsp #"+id,"",appendLinkToTooltip);
	$("#portal-ToolTipHolder").hide();
	//$('#portal-ToolTipHolder').html('pos:('+x+','+y+')');
	$("#portal-ToolTipHolder").css('left',x+'px');
	$("#portal-ToolTipHolder").css('top',y+'px');
	//appendLinkToTooltip();
}
//This function is called as soon as tool tip is loaded and adds 'close window' button to it 
function appendLinkToTooltip()
{
	if($('#portal-ToolTipHolder').html()!='')
	{
		var closelink= "<div style='text-align:right;width:100%;'><img src='/spportal/img-spportal/buttons/close-window.gif' onclick='closeTooltipWindow()'/></div>";
		$(closelink).appendTo('#portal-ToolTipHolder');
		$("#portal-ToolTipHolder").fadeIn(400);
	}
	//else
		//alert('tool tip unavailable');
}
function closeTooltipWindow()
{
	$('#portal-ToolTipHolder').fadeOut(400, function(){
	
	$('#portal-ToolTipHolder').html('');
	
	});	
}
//builds category display list from hidden selectbox
//defSel default select status of added elements

function isValidCategoryResults(selectId, displayId,defSel){
	
	var sel = document.getElementById(selectId);
	if (selectId =="categoriesResults" ){
			
		if (sel)
		{
			if (sel.options.length > 0){
				$('#searchResults').hide();
				$('#resultsMessage').show();
				$('#left').css('visibility','visible');
				$('#right').css('visibility','visible');
				$('#CategoryDisplay').show(); 
			}else{
				
				$('#resultsMessage').hide();
				$('#left').css('visibility','hidden');
				var tosel = document.getElementById('toList');
				if (tosel && tosel.options.length > 0){
				$('#CategoryDisplay').show();	
				$('#right').css('visibility','visible');
				}
				else{
				$('#CategoryDisplay').hide();
				$('#right').css('visibility','hidden');
				}
				$('#searchResults').show();
				return false;
			}
		}
	}if (selectId =="toList" ){
			
		if (sel)
		{
			var catsel = document.getElementById('categoriesResults');
			var keysel = document.getElementById('keywordsResults');
			if (sel.options.length > 0){
				$('#searchResults').hide();
				$('#right').css('visibility','visible');
				$('#CategoryDisplay').show(); 
				
				if (catsel){
					if (catsel.options.length > 0){
						$('#left').css('visibility','visible');
						$('#right').css('visibility','visible');
					}else{
						$('#left').css('visibility','hidden');
						$('#right').css('visibility','visible');
					}
				}
				
			}else{
				
				if (catsel){
					if (catsel.options.length > 0){
						$('#left').css('visibility','visible');
						$('#right').css('visibility','hidden');
					}else{
						$('#left').css('visibility','hidden');
						$('#right').css('visibility','hidden');
					}
				}
				if (keysel){
					if (keysel.options.length > 0){
						$('#left').css('visibility','visible');
						$('#right').css('visibility','visible');
					}else{
						$('#left').css('visibility','hidden');
						$('#right').css('visibility','hidden');
					}
				}
				
				return false;
			}
		}
	}
	return true;
}

function bpbuildList(selectId, displayId,defSel)
{
	var sel = document.getElementById(selectId);
	
	$('#load-icon').hide();
	if (isValidCategoryResults(selectId, displayId,defSel)){
    var tableObj = document.getElementById(displayId);
   $('#'+displayId).html('');
    
    var row, cell, catId, catText;
	if(sel){
	    for( var i = 0; i < sel.options.length; i++ )  
	    {
	        catId = sel.options[i].value;
	        catText = sel.options[i].text;
	        bploadCategoriesToDisplay(catId, catText, row, cell, tableObj,defSel);								
	    }    
	    bpalternateColor(displayId);
	}
	
	$('#CategoryDisplay').show();  
	
	}
}
//load selected categories to display list
function bploadCategoriesToDisplay(catId, catText, row, cell, tableObj,defSel)
{	
	row = document.createElement("tr");    
    cell = document.createElement("td");
    cell.setAttribute("height", '20px');    
    cell.setAttribute("id", catId + 'Item');
    cell.style.verticalAlign = 'middle';
    cell.style.paddingLeft = '5px';
    var arr= catId.split('##');
    if(arr&&arr.length==3)
    {
    	if(arr[2]=='true')
    		cell.innerHTML= '<span class="availCats-SGIcon">'+catText+'</span>'+'<img class="SG-check-icon" src="/spportal/img-spportal/icons/check-icon-small.gif" />';
    	else
    		cell.innerHTML = catText;
    }
    else
    	cell.innerHTML = catText;
    row.appendChild(cell);
    cell = document.createElement("td");
    cell.setAttribute("align", "right");
    cell.setAttribute("width", "50px");
    cell.style.verticalAlign = 'middle';
    cell.style.paddingRight = '5px';    
    if (tableObj!=null && tableObj.id=='fromDisplay')
       {
        cell.innerHTML = "<a href=\"#test\" onclick=\"bpmaintAddItem('"+getJSString(catText)+"','"+getJSString(catId)+"', true"+(defSel?",true)":")")+"\">Add ></a>";
       }
       else
       {
        cell.innerHTML = "<a href=\"#test\" onclick=\"bpmaintAddItem('"+getJSString(catText)+"','"+getJSString(catId)+"', false)\">Remove</a>";
       }
    row.appendChild(cell);
    tableObj.appendChild(row);	
}
function getJSString(str)
{
	var str2=str.replace('\'','\\\'');
	return str2;
}
//for PPC Maintenace Category pages
function bpmaintAddItem(catName, catId, flag,defSel){           
	bpaddCategoryItem(catName, catId, flag,defSel);
	bpalternateColor('toDisplay');              
}

function bpalternateColor(selectId)
{
	var tableObj = document.getElementById(selectId);
	if(tableObj==null)
		return;
	var color = '#ebebeb';
		
	for(var i=0; i<tableObj.getElementsByTagName('tr').length; ++i)
	{
		tableObj.getElementsByTagName('tr')[i].style.backgroundColor = color;		
		if(color == '#ebebeb')
		{
			color = '#FFFFFF';
		}
		else
		{
			color = '#ebebeb';
		}
	}
}
    
function bpaddCategoryItem(catName, catId, flag,defSel){
        var sel = document.getElementById('toList');
         
        //add category to selectbox      
        if(flag)
        {
        	if(sel.options.length == 5 && document.getElementById('catLimitCheck'))
        	{
        		alert('You have reached the max of 5 categories.')
        	}
        	else if((catName != "") && (catName.length != 0) && !bpitemExist(sel,catId)){
	                var newOption = new Option(catName, catId,null,defSel);                      
	                sel.options[sel.options.length] = newOption;
	                if(typeof(bpAddCallback) != 'undefined')
		               bpAddCallback();
	                else
	                	bpaddCategoryDisplay(catName,catId, flag);
	        }
        }
        //remove category from selectbox
        else
        {
            for( var i = 0; i < sel.options.length; i++ )  
            {
                if(sel.options[i].value != "")
                {
                    if(catId == sel.options[i].value)
                    {
                        sel.options[i].value = ""; 
                        sel.options[i].text = ""; 
                    }
                }
            }
            bpbumpUp( sel );
            if(typeof(bpRemoveCallback) != 'undefined')
            	 bpRemoveCallback();
            else
           		bpaddCategoryDisplay(catName,catId, flag);
        }

}
//update list from user selection
function bpaddCategoryDisplay(catName,catId, flag)
{    			
	var tableObj = document.getElementById('toDisplay');
    var row, cell;
    var sel = document.getElementById('toList');

	//add category to display 
    if(flag)
    {       
    	bploadCategoriesToDisplay(catId, catName, row, cell, tableObj);		
    }
    //remove category to display
    else
    {
        var sel = document.getElementById('toList');
	    var tableRows = tableObj.getElementsByTagName('tr');
	
	    for( var i = 0; i < sel.options.length; i++ )  
	    {
	        if(sel.options[i].value == catId)
	        {
	            sel.remove(i);
	        }
	
	    }
	
	    for( var i = 0; i < tableRows.length; i++ )  
	    {
	        if( tableRows[i].firstChild.id == (catId+"Item"))
	        {
	            tableRows[0].parentNode.removeChild(tableRows[i]);
	        }
	    }
    }        
}
function bpbumpUp( box )  { 
    for( var i = 0; i < box.options.length; i++ ) { 
        if( box.options[i].value == "" )  { 
            for( var j = i; j < box.options.length - 1; j++ )  { 
                box.options[j].value = box.options[j + 1].value; 
                box.options[j].text  = box.options[j + 1].text; 
            } 
            var ln = i; 
            break; 
        } 
    } 
    if( ln < box.options.length )  { 
        box.options.length -= 1; 
        bpbumpUp( box ); 
    } 
}

//check if the select item already exist in the selection
function bpitemExist(toList, val)
{
    for(var i=0; i<toList.options.length; ++i)
    {
        if(toList.options[i].value == val)
        {
            return true;
        }
    }
    return false;
}
function stopRKey(evt) {
	  var evt = (evt) ? evt : ((event) ? event : null);
	  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
	}
function isEmpty(x)
{
	return (x==''||x==null||x==undefined);
}
//returns an anchor wrapped in a span
function getNavAnchor(text,linkTo,clkHandle)
{
	return '<span><a href="'+linkTo+'" onclick=\''+clkHandle+'\'>'+text+'</a></span>';
}
function setUpPagedList(src,dest,settings)
{
	if(settings==null||settings==undefined)
	{
		alert('in setUpPagedList() settings must be defined!');
		return;
	}
	if(settings.title==undefined)
		settings.title=' ';
	if(settings.pageSize==undefined)
		settings.pageSize= 10;
	if(settings.startPage==undefined)
		settings.startPage=0;
	//validate starting page if invalid set it closest to the invalid page given
	var maxPages= Math.ceil($('#'+src+' option').size()/settings.pageSize);
	if(settings.startPage >= maxPages)
		settings.startPage= maxPages-1;
	else if(settings.startPage<0)
		settings.startPage= 0;
	showPagedList(settings.startPage*settings.pageSize,settings.pageSize,src,dest,settings.title);
}
function showPagedList(start,count,src,dest,title)
{
	var str='<table class="sppaged">';
	str+= '<tr><th>'+title+'</th></tr>';
	var n=0,noOfitems=0;
	str+= '<tbody class="sppaged-items">';
	//check if given page is valid
	$('#'+src+' option').each(function(index){
		if(index>=start && n<count)
		{
			str+= '<tr><td class="sppaged sppaged-';
			str+= ((index-start)%2==0?'even">':'odd">');
			if(typeof customPagingHTML == 'function')
				str+= customPagingHTML($(this),index)+'</td></tr>';
			else
				str+= selectedCatsHTML($(this),index)+'</td></tr>';
			n++;
		}
		noOfitems++;
	});
	str+= '</tbody><tr><td class="sppaged-nav">';
	if(noOfitems>count)
	{
		//make prev link
		var args= ','+count+',"'+src+'","'+dest+'","'+title+'"';
		if(start-count>=0)
			str+= getNavAnchor('prev','#link','showPagedList('+(start-count)+args+')');
		var tempStart=0;
	 	for(var i=0;i<noOfitems/count;i++)
		{
			if(start!= count*i)
				str+= getNavAnchor((i+1),'#link','showPagedList('+tempStart+args+')');
			else
				str+= '<span>'+(i+1)+'</span>';		
			tempStart+= count;
		}
		if(start+count<noOfitems)
			str+= getNavAnchor('next','#link','showPagedList('+(start+count)+args+')');
	}
	str+= '</td></tr></table>';
	$('#'+dest).html(str);
}
function selectedCatsHTML(opt,index)
{
	return '<table class="innertable"><tr><td>'+opt.html()+'</td><td width=30px><a href="#link" onclick="removeFromSelectedCats('+index+')">remove</a></td></table>';
}