// Main Navigation Preload and variables
// SBW 7/20/2001
var sPrefix = "";

if (typeof(sContentProviderUrl) == "string")
{
	sPrefix = sContentProviderUrl;
}


function changeImages()
{
  if (document.images)
  {
  for (var i=0; i<changeImages.arguments.length; i+=2)
  	{
  	document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
    }
  }
}

/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////	
function makePopup (url, name, h , w) {

	popup = window.open(url,name,"width="+ w +",height=" + h + ",top=30,left=30,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=no,screenX=30,screenY=30");

	// URL of popup window
	//popup.location.href = url;

	if (popup.opener == null) popup.opener = window;
	popup.focus();
	
	//popup.opener.name = "main";

}

function OpenUrl(url){
	window.location.href = url;
}

function makeFixedPopup (url, name, h , w) {
	sw=screen.availWidth;
	sh=screen.availHeight;
	var leftPos=(sw-w)/2, topPos=(sh-h)/2;
	
	popup = window.open(url,name,"width="+ w +",height=" + h + ",top="+topPos+",left="+leftPos+",toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,menubar=no");

	if (popup.opener == null) popup.opener = window;
	popup.focus();

}


function makePopupHelp(url,name,w,h) {

// Define the size of popup window in pixels with "width" and "height." 
popup = window.open(url,name,"width="+w+",height="+h+",top=0,left=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no,screenX=0,screenY=0");

}


function NewWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////	
//Per Binh, used on page3b.asp & step3.asp
function checkMaxLen(obj, maxChar){
	if(obj.value.length > maxChar){
		alert('You have exceeded the maximum number of characters \(' + maxChar +'\) allowed');
		obj.value = obj.value.substring(0,maxChar-1)
	}       
	return;
}

function SetUserInfoCookie(AssociateID, MembershipType)
{
	var dNow = new Date();
	dNow.setDate(dNow.getDate()+90);
    var Today = new Date();
    if(AssociateID > 0)
    {
        setCookie('UserInfo_AssociateID',AssociateID + '', dNow, '/', null, null);
        setCookie('UserInfo_MembershipType',MembershipType + '', dNow, '/', null, null);
    }
    setCookie('UserInfo_LastVisited',Today.toDateString(), dNow, '/', null, null);
    if(getCookie("UserInfo_DateCreated") == null)
    {
        setCookie('UserInfo_DateCreated',Today.toDateString(), dNow, '/', null, null);
    }
}

//added 12/22/2004 - DL
/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function myAcctToggle(ImgID,LayerID) {
	Img = document.getElementById(ImgID);
	Layer = document.getElementById(LayerID);
	if(Layer.style.display == "none") {
		Img.src = "/images/icons/closeIconBlue.gif";
		Layer.style.display = "";
	} else {
		Layer.style.display = "none";
		Img.src = "/images/icons/openIconBlue.gif";
	}
}

function IsValidCC(CCNum, Type)
{
	if(IsCCTypeCorrect(Type,CCNum) && isCreditCard(CCNum))
		return true;
	else
		return false;
}

function IsCCTypeCorrect(Type, CCNum)
{
	var bReturn = false;	
	
	CCNum = CCNum + "";
	
	if(Type == "AMEX" && CCNum.charAt(0) == "3")
	{
		bReturn = true;
	}
	else if(Type == "DISC" && CCNum.charAt(0) == "6")
	{
		bReturn = true;
	}	
	else if((Type == "VISA" || Type == "VI") && CCNum.charAt(0) == "4")
	{
		bReturn = true;
	}
	else if((Type == "MSTR" || Type == "MC") && CCNum.charAt(0) == "5")
	{
		bReturn = true;
	}
						
	return bReturn;
}

function isCreditCard(st) 
{
  // Encoding only works on cards with less than 19 digits
  if (st.length > 19)
    return (false);

  sum = 0; mul = 1; l = st.length;
  for (i = 0; i < l; i++) {
    digit = st.substring(l-i-1,l-i);
    tproduct = parseInt(digit ,10)*mul;
    if (tproduct >= 10)
      sum += (tproduct % 10) + 1;
    else
      sum += tproduct;
    if (mul == 1)
      mul++;
    else
      mul--;
  }

  if ((sum % 10) == 0)
    return (true);
  else
    return (false);

}

function StripGarbage(str, crap)
{  
    var result = '';

	for ( var i=0; i<str.length; i++ ) 
	{
		if ( crap.indexOf(str.charAt(i)) == -1 )
		{
           result += str.charAt(i);
        }
    }

	return result;
}

function RoundStr( str )
{
	var newNum = parseFloat( str );
	if( newNum == 'NaN' )
		return 0;
		
	return Math.round( newNum );
}

function IsValidCCDate(date)
{
	try
	{
		var month = "";
		var year = "";
		for(i=0; i<date.length && date.charAt(i) != '/'; i++)
			month += date.charAt(i);
		i++;
		while(i < date.length)
		{
			year += date.charAt(i);
			i++;
		}
		if(month > 12)
			return false;
		year = "20" + year;
		TheDate1 = new Date();
		TheDate1.setDate(1);
		TheDate1.setMonth(month-1);
		TheDate1.setFullYear(year);
		TheDate = new Date();
		TheDate.setDate(1);
		if(TheDate1.valueOf() >= TheDate.valueOf())
			return true;
		else
			return false;
	}
	catch(e)
	{
		return false;
	}
}
function Trim(str)
{
	strResult = "";
	for(i=0; i<str.length; i++)
	{
		if(str.charAt(i) != ' ');
			strResult += str.charAt(i);
	}
	return strResult;
}
function ConvertCCType(Type)
{
	if(Type == "1720")
		return "AMEX";
	if(Type == "1722")
		return "DISC";
	if(Type == "1723")
		return "VISA";
	if(Type == "1719")
		return "MSTR";
	if(Type == "1721")
		return "WIRE";
}

function getControl(PartialName)
{
  for(j =0; j<document.forms.length; j++)
  {
	F = document.forms[j];
	for(i = 0; i<F.elements.length; i++)
	{
		  if(F.elements[i].name.indexOf(PartialName) >= 0 || F.elements[i].id.indexOf(PartialName) >= 0)
			  return F.elements[i];
	}
  }
}


function GetExpiryDate(){
	var min = 2; //two minutes
	var Today = new Date();
	Today.setTime(Today.getTime() + (min * 60 * 1000));
	var UTCstring = Today.toUTCString();
	return UTCstring;
	}

	function InPageSetCookie(name, value)
	{
		var cookiestring= name + '=' +escape(value) + ';path=/;domain=.loopnet.com;EXPIRES='+ GetExpiryDate();
		document.cookie= cookiestring;
	}

	function InPageGetCookie(cookiename) 
	{
		//alert(document.cookie);
		var cookiestring = '' + document.cookie;
		
		var index1 = cookiestring.indexOf(cookiename);
		if (index1==-1 || cookiename=='') 
			return ''; 
		
		var index2 = cookiestring.indexOf(';',index1);
		if (index2 == -1) 
			index2 = cookiestring.length; 
		
		//RH if this is cleared the value goes back out as a ; because the cookie is there but empty
		if((cookiestring.substring(index1 + cookiename.length + 1, index2)) != ";")
		{
			return unescape(cookiestring.substring(index1 + cookiename.length + 1, index2));
		}
		else
			return "";
	}



var SROLSaveSearchNotDailyClick = "105";                                 
var SROLContactBrokerClick   = "106";                                            
var SROLSavePropertyClick  = "107";                                                
var SROLSaveSearchDailyClick  = "108";                                          
var RCOLCreateReport = "109";                                                        
var SRViewBasicListing  = "111";                                                       
var PPOLContactBrokerClick  = "112"; 
var PPOSContactBrokerClick  = "165";                                             
var PPOLSavePropertyClick  = "113";                                                
var PPOLEmailListingClick  = "114";         

var SRBuyPMSaveSearchDaily = "18600";                                          
var SRBuy24HRPSMSaveSearchDaily = "18610";                                  
var SRBuyPMReport = "18620";                                               
var SRBuy24HRSPSMReport = "18630";                                             
var SRBuyPMBaslicListing = "18640";                                    
var SRBuy24HRSPSMBasicListing = "18650";   

var SROSBuyPMSaveSearchDaily = "18940";                                          
var SROSBuy24HRPSMSaveSearchDaily = "18950";                                  
var SROSBuyPMReport = "18960";                                          
var SROSBuy24HRSPSMReport = "18970";                                             
var SROSBuyPMBaslicListing = "18980";                                    
var SROSBuy24HRSPSMBasicListing = "18990";  
var SROSBuyPMBar = "19000";
var SROSBuyPSMBar = "19010";


var SLOSSearchMoreOptionsClick = "136";
var RCOSCreateReport = "124";
var SROSSaveSearchNotDailyClick = "125";
var SROSSaveSearchDailyClick = "126";
var SROSContactBrokerClick = "127";
var SROSSavePropertyClick = "128";
var SROSViewBasicListing = "129";
var SROSShowCaseClick = "130";
var SROSPMClick = "131";


function DoNothing(){}
    
    
function LogValidationError(ErrorType,ErrorSource, ErrorMsg,SessionFarmGuid,SiteString,ScriptName,Guid,Module, Method)
{
    var iErrorType = "<ErrorType>" + ErrorType + "</ErrorType>";  
    var iErrorSource = "<ErrorSource>" + ErrorSource + "</ErrorSource>";
    var sModule = "<Module>" + Module + "</Module>";
    var sMethod = "<Method>" + Method + "</Method>";
    var sEventData = ErrorMsg;
    sEventData = "<EventData><![CDATA[" + sEventData + "]]></EventData>";
    sSessionFarmGuid = "<SessionFarmGuid>" + SessionFarmGuid + "</SessionFarmGuid>";
    sSiteString = SiteString;
    sByPassEventLogInsert = "<ByPassEventLogInsert>Y</ByPassEventLogInsert>";
    sScriptName = "<LNScriptName>" + ScriptName + "</LNScriptName>";
    var guid = Guid;
    var sXml = '<PFRequestData PageExecutionGuid="' + guid + '">' + iErrorType +  iErrorSource + sModule + sMethod  + sEventData + sSessionFarmGuid + sSiteString +  sByPassEventLogInsert + sScriptName + '</PFRequestData>';
    RemoteAJAXCall(null, '/xNet/MainSite/WebServices/WebStatistics/RequestInfo.asmx', sXml,'FireErrorEvent','http://www.loopnet.com/WebServices', -1);	    
}

function LNSaveActionCode(ActionCode, ActionCodeValue)
{
    if(ActionCodeValue + 0 >= 0)
    {
        var sXml = '<PFRequestData BypassLogServiceStats="Yes" PageExecutionGuid="' + PageExecutionGuid + '" ActionCode="' + ActionCode + '" ActionCodeValue="' + ActionCodeValue + '"></PFRequestData>';
        RemoteAJAXCall(null, '/xNet/MainSite/WebServices/WebStatistics/RequestInfo.asmx', sXml,'UpdateActionCode','http://www.loopnet.com/WebServices', -1);
    }
    else
    {
        AjaxSaveActionCode(ActionCode,PageExecutionGuid);
    }
}

function AjaxSaveActionCode(ActionCode,guid)
{
    var TempActionCode = ActionCode;
    var sXml = '<PFRequestData BypassLogServiceStats="Yes" PageExecutionGuid="' + guid + '" ActionCode="' + TempActionCode + '"></PFRequestData>';
    RemoteAJAXCall(null, '/xNet/MainSite/WebServices/WebStatistics/RequestInfo.asmx', sXml,'UpdateActionCode','http://www.loopnet.com/WebServices', -1);
}


function AddHiddenInputs(sName, sValue, bOverwriteValue,sFormName)
{	
	var oFormItems = eval('document.' +  sFormName);
	oInput = document.createElement('input');
	oInput.type = 'hidden';
	oInput.name = sName;
	oInput.id = sName;
	oInput.value = sValue;
	oVar = eval('document.' + sFormName + '.' + sName);
	if(oVar != null)
	    oVar.value = sValue;
	else
		oFormItems.appendChild(oInput);
}

 function rand() 
 {
     var now = new Date();
     return "" + now.getYear() + now.getMonth() + now.getDate() + now.getHours() + now.getMinutes() + now.getSeconds();
 }
 
function trimAll(sString) 
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

function IsValidPhone(sPhone)
{
    iDigits = 0;
    for (i = 0; i < sPhone.length; i++)
    {
        var sDigit = sPhone.charAt(i) + "";
        if(!isNaN(sDigit))
            iDigits++;
    }
    

    if(iDigits >= 10 && iDigits <= 14)
        return true;
    else
        return false;
}

function findObjPos(obj, Tag) 
{
	var curtop = 0;
	if (obj.offsetParent) 
	{
		while (obj.offsetParent) 
		{
		    if(Tag == "Y")
				curtop += obj.offsetTop;
			else
			    curtop += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y && Tag == "Y")
		curtop += obj.y;
	else if(obj.x && Tag == "X")
	    curtop += obj.x;
	  
	return curtop;
}

function getPageSize(){
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
		xScroll = document.documentElement.scrollWidth;
		yScroll = document.documentElement.scrollHeight;
	} else { // Explorer Mac...would also work in Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) { // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	//get page offsets
    var scrOfY = 0;
    var scrOfX = 0
    if( typeof( window.pageYOffset ) == 'number' ) 
    {
        //Netscape compliant
        scrOfX = window.pageXOffset;
        scrOfY = window.pageYOffset;
    } 
    else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
    {
        //DOM compliant
        scrOfX = document.body.scrollLeft;
        scrOfY = document.body.scrollTop;
    } 
    else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
    {
        //IE6 standards compliant mode
        scrOfX = document.documentElement.scrollLeft;
        scrOfY = document.documentElement.scrollTop;
    }
	

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,scrOfX,scrOfY)
	return arrayPageSize;
}


function RemoveHiddenInputs(sName,sFormName)
{	
	var oFormItems = eval('document.' +  sFormName);
	var oField = eval('document.' +  sFormName + '.' + sName);
	oFormItems.removeChild(oField);
}

function ClearFormInput(sName, sFormName )
{
    var oFormItems = eval('document.' +  sFormName);
    if( oFormItems != null ){
	    var oField = eval('document.' +  sFormName + '.' + sName);
	    if( oField != null )
	        oField.value = '';
	}
}

function RemoveAllFormInput(sFormName )
{
    var oFormItems = eval('document.' +  sFormName);
    if( oFormItems != null )
    {
	    for(i = 0; i<oFormItems.elements.length; i++)
	    {
	        if(oFormItems[i].name != "PgCxtGuid" && oFormItems[i].name != "PgCxtFLKey" && oFormItems[i].name != "PgCxtCurFLKey")
    	        oFormItems[i].value = "";
	    }
	}
}



 function rand() 
 {
     var now = new Date();
     return "" + now.getYear() + now.getMonth() + now.getDate() + now.getHours() + now.getMinutes() + now.getSeconds();
 }
 
function trimAll(sString) 
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

function IsValidPhone(sPhone)
{
    iDigits = 0;
    for (i = 0; i < sPhone.length; i++)
    {
        var sDigit = sPhone.charAt(i) + "";
        if(!isNaN(sDigit))
            iDigits++;
    }
    

    if(iDigits >= 10 && iDigits <= 14)
        return true;
    else
        return false;
}

function findObjPos(obj, Tag) 
{
	var curtop = 0;
	if (obj.offsetParent) 
	{
		while (obj.offsetParent) 
		{
		    if(Tag = "Y")
				curtop += obj.offsetTop;
			else
			    curtop += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y && Tag == "Y")
		curtop += obj.y;
	else if(obj.x && Tag == "X")
	    curtop += obj.x;
	  
	return curtop;
}




var dtCh = "/";
	var minYear = 1900;
	var maxYear = 2100;

function isInteger(s)
	{
		var i;
		for (i = 0; i < s.length; i++)
		{   
			var c = s.charAt(i);
			if (((c < "0") || (c > "9"))) return false;
		}
		return true; // All characters are numbers.
	}
	function stripCharsInBag(s, bag)
	{
		var i;
		var returnString = "";
		// Search through string's characters one by one.
		// If character is not in bag, append to returnString.
		for (i = 0; i < s.length; i++){   
			var c = s.charAt(i);
			if (bag.indexOf(c) == -1) returnString += c;
		}
		return returnString;
	}
	function daysInFebruary (year){
		// February has 29 days in any year evenly divisible by four,
		// EXCEPT for centurial years which are not also divisible by 400.
		return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}
	function DaysArray(n) 
	{
		for (var i = 1; i <= n; i++) 
		{
			this[i] = 31
			if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
			if (i==2) {this[i] = 29}
		} 
		return this
	}
	function isDate(sDate)
	{
		//Days in each month
		var daysInMonth = DaysArray(12);
		
		var pos1 = sDate.indexOf(dtCh);
		var pos2 = sDate.indexOf(dtCh, pos1+1);
		
		var sMonth = sDate.substring(0,pos1);
		var sDay = sDate.substring(pos1+1,pos2);
		var sYear = sDate.substring(pos2+1);
		
		strYr = sYear;
		if (sDay.charAt(0) == "0" && sDay.length > 1) 
			sDay = sDay.substring(1);
		
		if (sMonth.charAt(0) == "0" && sMonth.length > 1) 
			sMonth = sMonth.substring(1);
		
		for (var i = 1; i <= 3; i++) 
		{
			if (strYr.charAt(0) == "0" && strYr.length > 1) 
				strYr = strYr.substring(1);
		}
		
		month = parseInt(sMonth);
		day = parseInt(sDay);
		year = parseInt(strYr);
		
		if (pos1 == -1 || pos2 == -1)
		{
			return false //The date format should be : mm/dd/yyyy
		}
		if (sMonth.length < 1 || month < 1 || month > 12)
		{
			return false //Please enter a valid month
		}
		if (sDay.length < 1 || day < 1 || day > 31 || (month==2 && day > daysInFebruary(year)) || day > daysInMonth[month])
		{
			return false //Please enter a valid day
		}
		if (sYear.length != 4 || year==0 || year < minYear || year > maxYear)
		{
			return false //Please enter a valid 4 digit year between "+minYear+" and "+maxYear
		}
		if (sDate.indexOf(dtCh,pos2+1)!= -1 || isInteger(stripCharsInBag(sDate, dtCh)) == false)
		{
			return false //Please enter a valid date
		}
		
		return true //Valid date!!
	}
	function getDay(sDate)
	{
		var pos1 = sDate.indexOf(dtCh);
		var pos2 = sDate.indexOf(dtCh, pos1+1);
		
		var sMonth = sDate.substring(0,pos1);
		var sDay = sDate.substring(pos1+1,pos2);
		
		
		if (sDay.charAt(0) == "0" && sDay.length > 1) 
			sDay = sDay.substring(1);
		
		return sDay;
	}
	function getMonth(sDate)
	{
		var pos1 = sDate.indexOf(dtCh);
		
		var sMonth = sDate.substring(0,pos1);
		
		if (sMonth.charAt(0) == "0" && sMonth.length > 1) 
			sMonth = sMonth.substring(1);
		
		return sMonth;
	}
	function getYear(sDate)
	{
		var pos1 = sDate.indexOf(dtCh);
		var pos2 = sDate.indexOf(dtCh, pos1+1);
		
		var sYear = sDate.substring(pos2+1);
		
		strYr = sYear;
		
		for (var i = 1; i <= 3; i++) 
		{
			if (strYr.charAt(0) == "0" && strYr.length > 1) 
				strYr = strYr.substring(1);
		}
		
		return strYr;
	}
	
	function ShowTopMenu()
    {
        document.getElementById("searchDropdownmenu").style.visibility = "visible";
    }
    
    function HideTopMenu()
    {
        document.getElementById("searchDropdownmenu").style.visibility = "hidden";
    }
    
    function CategoryTypeVisibility(showhide)
    {
        var ddlCatType = document.getElementById("Top1_topUniSearch_ddlCategoryType");
            
        if(ddlCatType)
        {
            ddlCatType.style.visibility = showhide;
        }        
    }
    
    
    
    function createForm(formName, actionURL, target, method)
    {
        var oForm = document.createElement("form");
        oForm.name = formName; //Form name
        oForm.id = formName; // Form ID
        oForm.action = actionURL; // URL to post back
        oForm.target = target; // This is important. Use “_blank” if you wish to post back to new window
        oForm.method = method; // Method GET or POST
        return oForm;
    }

    //Create input fields 
    function createInputField(name, value, type)
    {

        var oField = document.createElement("input");
        oField.name = name;
        oField.id = name;
        oField.value = value;
        oField.type = type; // Type normally “hidden”
        return oField;
    }

//Append Field to form
function appendField(oForm, oField)
{
	oForm.appendChild(oField);
}



function LNPostURL(sURL)
{
    
    var sUrlAndParms = sURL.split('?');
    var sUrl = sUrlAndParms[0];
    var sParms = sUrlAndParms[1].split('&'); 
    var oForm = createForm("LNJSPost_Form",sUrl,"","POST");
    for(i=0; i<sParms.length; i++)
    {
        var RequestVar = sParms[i].split('=');
        var RequestVarValue = '';
        if(RequestVar.length == 2)
            RequestVarValue = RequestVar[1];
        if(RequestVarValue != '')
        {
            var oField = createInputField(RequestVar[0], RequestVarValue,"hidden");
            appendField(oForm,oField);
        }
    } 
    document.body.appendChild(oForm);
    oForm.submit();
}