

//save to the respective hidden fields
function SaveScrollPosition(hdnField, propertyType, scrollPosition )
{


       var index = document.getElementById(hdnField).value.indexOf('newPT'+propertyType);
			if(index == '-1')
			{
			
			document.getElementById(hdnField).value = document.getElementById(hdnField).value+'newPT'+propertyType+','+scrollPosition+';';
			
			}
			else
			{
				var propType_array = document.getElementById(hdnField).value.split(";");
				var part_num = 0;
				var finalStr = '';
				var len = propType_array.length - 1;
				
				
				//Spilt the string to replace the value
				while ( part_num < len )
				{
			   
					if((propType_array[part_num].indexOf('newPT'+propertyType))!= '-1')
					{
						propType_array[part_num] = 'newPT'+propertyType+','+ scrollPosition;
						
					}
					finalStr = finalStr + propType_array[part_num] + ';';
					part_num = part_num + 1;
				   
				}
				document.getElementById(hdnField).value = finalStr;
				
			}

}


function GetScrollPosition(sectionType, propertyType)
{
      
      
      if (sectionType == '1')
       {
        
        var currPos = GetValue("hdnNewlyMatchedScrollPos", propertyType);
        return currPos;
       }
      else if (sectionType == '2')
       {
        var currPos = GetValue("hdnSavedScrollPos", propertyType);
        return currPos;
		 }
	    else if (sectionType == '3')
       {
        var currPos = GetValue("hdnRejectedScrollPos", propertyType);
        return currPos;
       }
   
 }
	
	
function GetValue(hdnField, propertyType)
{

       if(document.getElementById(hdnField).value.indexOf('newPT'+propertyType)!='-1')
			{
 				var propType_array = document.getElementById(hdnField).value.split(";");
				var part_num = 0;
				var len = propType_array.length - 1;
				while ( part_num < len )
				{
			   
				if((propType_array[part_num].indexOf('newPT'+propertyType))!= '-1')
				{
				var tempcurrentScrollPosArray = propType_array[part_num].split(",");
			   return tempcurrentScrollPosArray[1];
				}
				part_num = part_num + 1;
			   
				}
			}
			else
			{
			return '0';
			}

}

//sets the scroll position to the hidden fields  
  function SetScrollPostion(sectionType, propertyType, scrollPosition)
  {
	
	
	  if (sectionType == '1')
       {
       SaveScrollPosition("hdnNewlyMatchedScrollPos", propertyType, scrollPosition );
       }
      else if (sectionType == '2')
       {
	     SaveScrollPosition("hdnSavedScrollPos", propertyType, scrollPosition );
			
	    }
	    else if (sectionType == '3')
       {
       SaveScrollPosition("hdnRejectedScrollPos", propertyType, scrollPosition );
       }
	
}


function GetPageNum(sectionType, propertyType)
{
      if (sectionType == '1')
       {
        
        var currPageNum = GetValue("hdnNewlyMatchedPageNum", propertyType);
        return currPageNum;
       }
      else if (sectionType == '2')
       {
       
        var currPageNum = GetValue("hdnSavedPageNum", propertyType);
        return currPageNum;
		 }
	    else if (sectionType == '3')
       {
        var currPageNum = GetValue("hdnRejectedPageNum", propertyType);
        return currPageNum;
       }

}


function SetPageNum(sectionType, propertyType, pageNum)
{
       if (sectionType == '1')
       {
        var currPageNum = SavePageNum("hdnNewlyMatchedPageNum", propertyType,pageNum);
        return currPageNum;
       }
       else if (sectionType == '2')
       {
       
        var currPageNum = SavePageNum("hdnSavedPageNum", propertyType, pageNum);
        return currPageNum;
		 }
	    else if (sectionType == '3')
       {
        var currPageNum = SavePageNum("hdnRejectedPageNum", propertyType, pageNum);
        return currPageNum;
       }
}

function SavePageNum(hdnField, propertyType, pageNum)
{

       var index = document.getElementById(hdnField).value.indexOf('newPT'+propertyType);
			if(index == '-1')
			{
			
			document.getElementById(hdnField).value = document.getElementById(hdnField).value+'newPT'+propertyType+','+pageNum+';';
			
			}
			else
			{
				var propType_array = document.getElementById(hdnField).value.split(";");
				var part_num = 0;
				var finalStr = '';
				var len = propType_array.length - 1;
				
				
				//Spilt the string to replace the value
				while ( part_num < len )
				{
			   
					if((propType_array[part_num].indexOf('newPT'+propertyType))!= '-1')
					{
						propType_array[part_num] = 'newPT'+propertyType+','+ pageNum;
						
					}
					finalStr = finalStr + propType_array[part_num] + ';';
					part_num = part_num + 1;
				   
				}
				document.getElementById(hdnField).value = finalStr;
				
			}

}

/*function CallProspectCart()
{
	var URL = "SaveToProspectCart.aspx";
	var form = document.createElement("form");
	form.action = URL;
	form.method = "post";
	form.target = "ClientPortalFrame";		
	var ProspectCart = document.createElement("INPUT");
	ProspectCart.name = "PCART";
	ProspectCart.value = "C";
	form.appendChild(ProspectCart);			
	document.getElementById('divClientPortal').appendChild(form);
	form.submit();	
}*/