function createPagerLight(ajaxCallUrl, callBackFunction, page, displayTarget, numberOfPages, twoItemsSlider, isTest)
{

  //create form 	
  if(ajaxCallUrl==0 && displayTarget==0)
  {
    //use an old form
    document.forms["pagerForm_" + callBackFunction].page.value = page;
  }
  else
  {
   var stream = "<form name='pagerForm_" + callBackFunction + "' action='" + ajaxCallUrl + "' method='post'>";
    stream += "<input type='hidden' name='ajaxCallUrl' value='"+ ajaxCallUrl + "'/>";
    stream += "<input type='hidden' name='callBackFunction' value='"+ callBackFunction + "'/>";
    stream += "<input type='hidden' name='page' value='"+ page + "'/>";	
    stream += "<input type='hidden' name='displayTarget' value='"+ displayTarget + "'/>";
    stream += "<input type='hidden' name='numberOfPages' value='"+ numberOfPages + "'/>";
    stream += "</form>";
    //alert("displayTarget:"+displayTarget);
	
	var $altCont = $(ajaxCallUrl+'PagerForm');
	
	if ($altCont)
	{
		$altCont.update(stream); 
	}
	else
	{
		document.write(stream);
	}
    //alert(document.forms["pagerForm_" + callBackFunction].ajaxCallUrl.value);		
  }	
   //alert(twoItemsSlider);
  if(twoItemsSlider && twoItemsSlider!='resp') 
  { 
    TIajaxCallSimulator(document.forms["pagerForm_" + callBackFunction].ajaxCallUrl.value,
       document.forms["pagerForm_" + callBackFunction].callBackFunction.value,
       document.forms["pagerForm_" + callBackFunction].page.value,
       document.forms["pagerForm_" + callBackFunction].displayTarget.value,
       document.forms["pagerForm_" + callBackFunction].numberOfPages.value
      );
  }
  else
  {
    ajaxCallSimulator(document.forms["pagerForm_" + callBackFunction].ajaxCallUrl.value,
       document.forms["pagerForm_" + callBackFunction].callBackFunction.value,
       document.forms["pagerForm_" + callBackFunction].page.value,
       document.forms["pagerForm_" + callBackFunction].displayTarget.value,
       document.forms["pagerForm_" + callBackFunction].numberOfPages.value
      );
  }    
}

function myCallBackLight(response, twoItemsSlider){

  //extract parameters
  var params = new Array();
  params[0]="ajaxCallUrl";
  params[1]="userCallBackFunction";
  params[2]="page";
  params[3]="displayTarget";
  params[4]="numberOfPages";

  for(i=0; i<params.length; i++){
    var start = response.indexOf("<" + params[i] + ">", 0);
    var end = response.indexOf("</" + params[i] + ">", 0);
    //alert(params[i]);
    params[i] = response.substring(start + params[i].length+2, end);
    //alert(params[i]);
  }
  //call drawPager() with extracted params
  drawPagerLight(params[0], params[1], params[2], params[3], params[4], response, twoItemsSlider);
}


	function drawPagerLight(ajaxCallUrl, callBackFunction, page, displayTarget, numberOfPages, response, twoItemsSlider){  
    var pagerSkin = (twoItemsSlider)? TwoItemsSlider.pagerSkin:'gray';

    var stream = '';
    stream += '<table cellpadding="0" cellspacing="0" border="0">';
    stream += '<tr>';
    stream += '<td class="generic_paging">';

		if(numberOfPages>1){
			for(i=1; i<=numberOfPages; i++) {
				if(i==page){
					stream += '<img src="' + staticResourcesUriPrefix + '/images/common/'+pagerSkin+'_selected_page.gif" id="page' + i + '">';
				}	
				else {
					stream += '<img src="' + staticResourcesUriPrefix + '/images/common/'+pagerSkin+'_nonselected_page.gif" id="page' + i + '"';
					stream += ' onclick="pickPageLight(' + i + ',\'' + callBackFunction + '\','+twoItemsSlider+')">';
				}
			}
		}
			stream += '</td>';
			stream += '<td class="generic_paging_arrows">';
		if(numberOfPages>1){
			stream += '<img src="' + staticResourcesUriPrefix + '/images/common/Prev_Button_Grey.gif" '; 
			if(!(page==1)) {
				stream += 'onmouseover="highlight(this,\'' + staticResourcesUriPrefix + '/images/common/Prev_Button_Grey_Over.gif\');" '; 
				stream += 'onmouseout="highlight(this,\'' + staticResourcesUriPrefix + '/images/common/Prev_Button_Grey.gif\');"  ';
				stream += 'onclick="pickPageLight(' + (page-1) + ',\'' + callBackFunction + '\','+twoItemsSlider+')"';
			}
			stream += '>';
			stream += '<img src="' + staticResourcesUriPrefix + '/images/common/diagonal_pageing.gif">';
			stream += '<img src="' + staticResourcesUriPrefix + '/images/common/Next_Button_black.gif"';
			if (!(page==numberOfPages)) {
				stream += 'onmouseover="highlight(this,\'' + staticResourcesUriPrefix + '/images/common/Next_Button_black_Over.gif\');" '; 
				stream += 'onmouseout="highlight(this,\'' + staticResourcesUriPrefix + '/images/common/Next_Button_black.gif\');" ';
				stream += 'onclick="pickPageLight(' + (eval(page)+1) +  ',\'' + callBackFunction  + '\','+twoItemsSlider+')"';
			}
			stream += '>';
		}
			stream += '</td>';
			stream += '</tr>';
			stream += '</table>';
			
		
			$(displayTarget).innerHTML = stream;	
		
		//TODO: call userCallBackName(response)
		eval(callBackFunction)(response, twoItemsSlider);	
	}
	
function highlit(object, isOn){
  var suffix = "HighLight";
  if(isOn==1){
    object.className = object.className + suffix;
  }
  else{
    object.className = object.className.substr(0, object.className.indexOf(suffix));		
  }	
}

function highlight(obj, imgSrc) {
  obj.src = imgSrc;
}

function pickPageLight(page, callBackFunction, twoItemsSlider, keepSlider){
  
  if(!keepSlider && twoItemsSlider)
  {
    TwoItemsSlider.stopAutoSliding();
    TwoItemsSlider.CurPage=page;
  }
   
  
  createPagerLight(0, callBackFunction, page, 0, null,twoItemsSlider)
  
  if(!keepSlider && twoItemsSlider)
  {
    TwoItemsSlider.startAutoSliding();
  }
  
}

