function getItem(id) {
var itm = false;
if(document.getElementById)
itm = document.getElementById(id);
else if(document.all)
itm = document.all[id];
else if(document.layers)
itm = document.layers[id];
return itm;
}
//tcHideShow (h)ide or (s)how
function toggleItem(id, tcHideShow) {
itm = getItem(id);
if (!itm) return false;
if (tcHideShow == 's') {
  itm.style.display = '';
  itm.visible = true; }
else {
  itm.style.display = 'none';
  itm.visible = false; }
return false;
}

function ValidateCustAccountForm(toForm){
if (!VarCheck(toForm.FIRSTNAME, 'Please enter your First Name.', false)) {
  return false; }
if (!VarCheck(toForm.LASTNAME, 'Please enter your Last Name.', false)) {
  return false; }
//if (!VarCheck(toForm.ALTADDR1, 'Please enter your Address.', false)) {
//  return false; }
if (!VarCheck(toForm.ALTCITY, 'Please enter your City.', false)) {
  return false; }
if (!VarCheck(toForm.ALTSTATE, 'Please enter your State.', false)) {
  return false; }
if (!VarCheck(toForm.ALTZIP, 'Please enter your Zipcode.', false)) {
  return false; }
if(!check_email(toForm.EMAIL.value)){
	alert("Invalid email address.");
	toForm.EMail.focus(); 
  return false; }
if (!VarCheck(toForm.PHONE, 'Please enter your Phone Number.', false)) {
  return false; }
if (!VarCheck(toForm.WSPASSWORD, 'Please enter your Password.', false)) {
  return false; }
if (!VarCheck(toForm.confirmpassword, 'Please enter your Confirm Password.', false)) {
  return false; }
return true;
}

// above functions changed for WEBREG

function launchWinSunburstPopup(toA, tcHref) {
if (screen.height >= 630) lnHeight = 630; else lnHeight = screen.height - 56;
winSunBurstPopup = launch(tcHref, toA.target, "height=" + lnHeight + ",width=600,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=2,status=0,toolbar=0", "myWindow");}

function SearchButtonClick(toForm){
if (ValidateTourAvailForm(toForm)) {
	if (toForm.StaticFlag.value == 'true') {
		var lcType = 'P';
		if (toForm.opgPkgAo[1].checked == true) lcType = 'A';

		var lcDep = getDateString(toForm.DepartDateMonthYear,toForm.DepartDateDay);
		if (!(lcDep==null)) {
			var lcDepYear = lcDep.substring(0, 4);
			if (lcDep.substring(6, 7) == '-') {
				var lcDepMth = lcDep.substring(5, 6) - 1;
				var lcDepDay = lcDep.substring(7);
				}
			else {
				var lcDepMth = lcDep.substring(5, 7) - 1;
				var lcDepDay = lcDep.substring(8);
				}
			}

		var lcDestReg = toForm.Dest.value
		if (lcDestReg.substring(3, 4) == '-') {
			var lcDest = lcDestReg.substring(0, 3);
			var lcRegion = lcDestReg.substring(4);
			lcDestReg = lcDest + lcRegion
			}

		var lnDate = cal_to_jd('CE', eval(lcDepYear), eval(lcDepMth) + 1, eval(lcDepDay), 12, 0, 0) - lnOffset;
		var lnKey  = eval(toForm.Gate.value + lcDestReg);
		var lnAvl = a[lnDate][lnKey];

		lcDepMth = lcDepMth + 1 ;
		if (lcDepMth < 10) lcDepMth = '0' + lcDepMth ;
		if (lcDepDay < 10) lcDepDay = '0' + lcDepDay ;
		var lcDepart = lcDepYear + lcDepMth + lcDepDay;

		if (lnAvl > 0 && ((lcType == 'P' && lnAvl <= 2) || (lcType == 'A' && lnAvl >= 2))) {
			var lcHref = 'SearchTour' + lcType + toForm.Gate.value + toForm.Dest.value + lcDepart + '.htm';
			LoadMain(lcHref, '');
			}
		else {
			var lcHref = 'SearchTour' + lcType + toForm.Gate.value + toForm.Dest.value + 'AltDept' + lcDepMth + '_' + lcDepYear + '.htm';
			LoadMain(lcHref, '');
			}
		}
	else {
		//toForm.submit();
		var lcType = 'P';
		if (toForm.opgPkgAo[1].checked == true) lcType = 'A';

		var lcDestReg = toForm.Dest.value
		if (lcDestReg.substring(3, 4) == '-') {
			var lcDest = lcDestReg.substring(0, 3);
			var lcRegion = lcDestReg.substring(4);}
		else {
			var lcDest = toForm.Dest.value;
			var lcRegion = '';}

		var lcDep = getDateString(toForm.DepartDateMonthYear,toForm.DepartDateDay);
		if (!(lcDep==null)) {
			var lcDepYear = lcDep.substring(0, 4);
			if (lcDep.substring(6, 7) == '-') {
				var lcDepMth = lcDep.substring(5, 6) - 1;
				var lcDepDay = lcDep.substring(7);}
			else {
				var lcDepMth = lcDep.substring(5, 7) - 1;
				var lcDepDay = lcDep.substring(8);}
			}
		lcDepMth = lcDepMth + 1 ;
		if (lcDepMth < 10) lcDepMth = '0' + lcDepMth ;
		if (lcDepDay < 10) lcDepDay = '0' + lcDepDay ;
		var lcDepart = lcDepYear + lcDepMth + lcDepDay;
		var lcHref = 'SearchTour.wbk?type=' + lcType + '&gate=' +  toForm.Gate.value + '&dest=' + lcDest + '&region=' + lcRegion + '&depart=' + lcDepart;
		if (toForm.LanderBasePath == '[object]' && toForm.LanderBasePath.value != '') {lcHref = toForm.LanderBasePath.value + lcHref;}

		toForm.action=lcHref;
		toForm.submit();
		}
  return true; }
return false;
}

function ValidateTourAvailForm(toForm){
if (toForm.Gate.value == "Other" || toForm.TripLength.value == "Other" || VarCheck(toForm.Dest, 'Please select a Destination.', false)) {
  return true; }
return false;
}

function createOnTopTourAvailTarget(toForm){
if (ValidateTourAvailForm(toForm)) {
	launch("", toForm.target, "", "myWindow");
  return true; }
return false;
}

function SetOriginalDate() {
var ldDate = new Date() ;
ldDate.setDate(ldDate.getDate() + 1) ;
if (ldDate.getDay() != 5 && ldDate.getDay() != 6 && ldDate.getDay() != 0) {
	for (i=1;i<7;i++) {
		if (ldDate.getDay() == 5 || ldDate.getDay() == 6 || ldDate.getDay() == 0) break
		else ldDate.setDate(ldDate.getDate() + 1) 
  }
}
var lnMth   = ldDate.getMonth() + 1;
var lcMthYr = ldDate.getFullYear() + '-' + lnMth;
document.frmTourAvail.DepartDateMonthYear.value = lcMthYr ;
document.frmTourAvail.DepartDateDay.value = ldDate.getDate() ;
}

function UpdateReturnDate() {
var ldDep = getDateString(document.frmTourAvail.DepartDateMonthYear,document.frmTourAvail.DepartDateDay);
if (!(ldDep==null)) {
	var lcDepYear = ldDep.substring(0, 4)
	if (ldDep.substring(6, 7) == '-') {
		var lcDepMth = ldDep.substring(5, 6) - 1;
		var lcDepDay = ldDep.substring(7);
		}
	else {
		var lcDepMth = ldDep.substring(5, 7) - 1;
		var lcDepDay = ldDep.substring(8);
		}

	if (parseInt(lcDepDay) > 28 && !IsValidDate(parseInt(lcDepYear), parseInt(lcDepMth), parseInt(lcDepDay))) {;
		var lnDepMth = parseInt(lcDepMth);
		if (lnDepMth==3 || lnDepMth==5 || lnDepMth==8 || lnDepMth==10) {
			var lcDepDay = '30'; }
		else {
			var lcDepDay = '28'; }

		var lnDepDay = parseInt(lcDepDay);

		for (var i=document.frmTourAvail.DepartDateDay.options.length-1; i>0; i--) {
			if (document.frmTourAvail.DepartDateDay.options[i].value==lnDepDay) {
				document.frmTourAvail.DepartDateDay.selectedIndex=i;
				break;
			}
		}		
	}

	var ldRet = new Date(lcDepYear, lcDepMth, lcDepDay) ;

	ldRet.setDate(ldRet.getDate() + 7) ;
	SetReturnDateFromDeparture(ldRet.getYear(), ldRet.getMonth() + 1, ldRet.getDate());
}}

function IsValidDate(year, month, day) {
if ((month==3 || month==5 || month==8 || month==10) && day==31) {
	return false
}
if (month == 1) {
	var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	if (day>29 || (day==29 && !isleap)) {
		return false;
  }
}
return true;
}

function SetReturnDateFromDeparture(y,m,d) {
document.frmTourAvail.DepartDateMonthYearReturn.value=y+'-'+m;
for (var i=0; i<document.frmTourAvail.DepartDateDayReturn.options.length; i++) {
	if (document.frmTourAvail.DepartDateDayReturn.options[i].value==d) {
		document.frmTourAvail.DepartDateDayReturn.selectedIndex=i;
		break;
	}
}}

function launch(newURL, newName, newFeatures, orgName) {
var remote = open(newURL, newName, newFeatures);
if (remote.opener == null) remote.opener = window;
remote.opener.name = orgName;
try{remote.focus();}catch(e){alert("The winodw is already open - please select it from the taskbar.");}
return remote;
}

function launchWinFlightInfo(toA) {
winFlightInfo = launch(toA.href, toA.target,
                       "height=670,width=550,screenX=0,left=0,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0", "myWindow");
}

function launchWinPrivacyPolicy(toA) {
winPrivacy = launch(toA.href, toA.target,
                    "height=" + screen.height - 1 + ",width=584,screenX=0,left=0,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0", "myWindow");
}

function launchWinPdf(toA) {
winPdf = launch(toA.href, toA.target,
                "height=" + screen.height - 1 + ",width=" + screen.width - 1 + ",screenX=0,left=0,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0", "myWindow");
}

function launchWinProofOfCitizenship(toA) {
winCitizen = launch(toA.href, toA.target,
                    "height=" + screen.height - 1 + ",width=600,screenX=0,left=0,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0", "myWindow");
}

function launchWinStarRatings(toA) {
winStars = launch(toA.href, toA.target,
                  "height=460,width=580,screenX=50,left=50,screenY=50,top=50,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0", "myWindow");
}

function CreateSlideShowLinkTarget(tcTarget){
launch("", 'Slideshow',	"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=550,height=330", "myWindow");
return true;
}

function LoadMain(file,target) {
    if (target != '')
        target.window.location.href = file;
    else
        window.location.href = file;
}

function SubmitPaxEntryFormFromLink(toA, tcChar){
var lcLink = toA.href
var lcParms = BuildNamedParmList(document.forms(0), false, tcChar);
var lcNewUrl = lcLink + lcParms;
window.location.href = lcNewUrl;
}

function SayMsgBoxMsg(tcMsg) {
if (!(tcMsg=="") && !(tcMsg==null))
	alert(tcMsg);
}

function SetFormFocus(toDoc){
//if noone logged in and unknown email address entered, object does not exist?!?
//ONLY used in orderlogon.gwv and logonprofile.wbk - use focusFirst() for others
var loPw = toDoc.frmLogonProfile.Password;
var loEmail = toDoc.frmLogonProfile.Email;
if (typeof(loEmail) == 'object' && typeof(loPw) == 'object')
	if (loEmail.value == '')
		toDoc.frmLogonProfile.Email.focus();
	else
		toDoc.frmLogonProfile.Password.focus();
}

function ValidateAgentsLoginForm(toForm) {
if(!check_email(toForm.Email.value)){
	alert("Invalid email address.");
	toForm.Email.focus(); 
  return false; }
return true;
}

function ValidateLogonProfileForm(toForm) {
if(!check_email(toForm.Email.value)){
	alert("Invalid email address.");
	toForm.Email.focus(); 
  return false; }
return true;
}

function ValidateMakePaymentForm(toForm) {
if (!VarCheck(toForm.txtNameOnCard, 'Please enter the Name on the Credit Card.', false)) {
  return false; }
if (!VarCheck(toForm.txtCcAddress, 'Please enter the Credit Card Billing Address.', false)) {
  return false; }
if (!VarCheck(toForm.txtCcCity, 'Please enter the Credit Card Billing City.', false)) {
  return false; }
if (!VarCheck(toForm.txtCcState, 'Please enter the Credit Card Billing State.', false)) {
  return false; }
if (!VarCheck(toForm.txtCcZipcode, 'Please enter the Credit Card Billing Zipcode.', false)) {
  return false; }
if (!VarCheck(toForm.CcNumber, 'Please enter a Credit Card Number.', true)) {
  return false; }
if (!VarCheck(toForm.ccMonth, 'Please enter the Credit Card Expiration Month.', false)) {
  return false; }
if (!VarCheck(toForm.ccYear, 'Please enter the Credit Card Expiration Year.', false)) {
  return false; }
return true;
}

function ValidateChangeProfileForm(toForm) {
var lcVar = toForm.email;
if (!(lcVar==null)) {
	if (!check_email(toForm.email.value)){
		alert("Invalid email address.");
		toForm.email.focus(); 
		return false;
	}
}
}

function SetFormOrderLogonFocus(toDoc) {
var lcVal = toDoc.frmOrderLogon.Email.value;
if (lcVal=="")
	toDoc.frmOrderLogon.Email.focus();
else
	toDoc.frmOrderLogon.Password.focus();
}

function ValidateMyAccountForm(toForm){
if (VarCheck(toForm.Bookingno, 'Please enter booking number.', true)) {
	return true; }
return false;
}

function RunSelectAgencyParmTarget(tcHref){
var toForm = document.forms(0);
if (ValidateSelectAgencyForm(toForm)) {
	var lcParms = BuildNamedParmList(toForm);
	launch(tcHref + lcParms,'window2',"height=" + screen.height - 1 + ",width=600,screenX=50,left=50,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0",'myWindow');
}}

function ValidateSelectAgencyForm(toForm){
var lcName = toForm.txtAgencyName.value;
var lcCity = toForm.txtAgencyCity.value;
var lcZipcode = toForm.txtAgencyZipcode.value;
if (((lcName==null)||(lcName=="")) && ((lcCity==null)||(lcCity=="")) && ((lcZipcode==null)||(lcZipcode==""))) {
  alert('Please enter at least one search value.');
  toForm.txtAgencyName.focus();
  return false; }
return true;
}

function setReturnValuesFromCalendarPopup(y,m,d) {
	var lcSavVal = document.frmTourAvail.DepartDateMonthYear.value
	document.frmTourAvail.DepartDateMonthYear.value=y+'-'+m;
	if (document.frmTourAvail.DepartDateMonthYear.value=="") {
		alert("Selected date is not in available departure range.");
		document.frmTourAvail.DepartDateMonthYear.value = lcSavVal;
	}

	for (var i=0; i<document.frmTourAvail.DepartDateDay.options.length; i++) {
		if (document.frmTourAvail.DepartDateDay.options[i].value==d) {
			document.frmTourAvail.DepartDateDay.selectedIndex=i;
			break;
		}
	}
	UpdateReturnDate();
}

function getDateString(ym_obj,d_obj) {
	if (ym_obj.selectedIndex < 0) {return null;}
	var ym = ym_obj.options[ym_obj.selectedIndex].value;
	var d = d_obj.options[d_obj.selectedIndex].value;
	if (ym=="") { return null; }
	if (d=="") { d="1"; }
	return str= ym+'-'+d;
	}

function RunLifestyleParmTargetNoValidate(toForm){
if (VarCheck(toForm.cboLifeStyle, '', false)) {
	var lcHref = toForm.cboLifeStyle.value;
	if (typeof(toForm.WebCampId) == 'object' && toForm.WebCampId.value != "" && toForm.WebCampId.value != null) lcHref = lcHref + '~&camp=' + toForm.WebCampId.value;
	launch(lcHref,'window2',"height=" + screen.height - 1 + ",width=600,screenX=50,left=50,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0",'myWindow');
}}

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function WTV_onimageload(id, url, caption) {
	document.getElementById(id).innerHTML =
	 "<a href = \"#\" onclick=\"window.open(\'" + url + "\',\'\', \'width= 700,height= 450\')\">" + caption + "</a>";
}

function SelectListItem(loList,lcValue) {
loList.selectedIndex = 0;
for (x=0;x<loList.length-1;x++) {
	if (loList.options[x].value == lcValue) {
		loList.selectedIndex = x;
		break;
	}
}
}

function BuildParmList(toForm){
var lcParms = '?'
for(i=0; i<toForm.elements.length; i++){
	var field = toForm.elements[i];
	if(field.type=="text" || field.type=="textarea"){
		lcParms = lcParms + field.value + '~' };
	if(field.type=="select-one"){	
		lcParms = lcParms + field.value + '~' };
}
return lcParms;
}

function BuildNamedParmList(toForm, tlExclCcNum, tcChar){
if (tcChar == null) tcChar = "?";
var lcParms = tcChar;
for(i=0; i<toForm.elements.length; i++){
	var field = toForm.elements[i];
	if(field.type=="text" || field.type=="textarea" || field.type=="select-one") {
		if (field.name != 'CcNumber' || tlExclCcNum != true) {
			var lcField = field.name;
			var lcBaseField = lcField.substring(0, lcField.length - 1);
			var lcValue = field.value;
			if (lcBaseField == 'DOB') lcValue = xreplace(lcValue, '/', '-');

			lcParms = lcParms + field.name + '=' + lcValue + '&'};
	}
}
return lcParms;
}

function VarCheck(toVar, tcMsg, tlNum){
var lcVal = toVar.value;
if((lcVal==null)||(lcVal=="")||((tlNum && isNaN(lcVal)))) {
	if (tcMsg != "") {alert(tcMsg)};
	toVar.focus();
  lcType = toVar.type ;
  if (lcType == 'text' || lcType == 'textarea') {
	  toVar.select();
	}
  return false;
}
return true;
}

function SelectListItem(loList,lcValue) {
   loList.selectedIndex = 0;
	for (x=0;x<loList.length;x++) {
     if (loList.options[x].value == lcValue) {
	       loList.selectedIndex = x;
	       break;
	    }
	}
}

function focusFirst(tcFormName) {
	if (tcFormName == null)
  	var tcFormName = 'forms[0]';
	var loForm = eval('document.' + tcFormName);
  if (loForm)
  {
    if ( loForm.elements.length ) {
       var lnElems = loForm.elements.length ;
     }
     else {
       var lnElems = 2 ;
     }
     var lnElem = 0 ;
     var lcType = '' ;
     while ( lnElem < lnElems ) {
       lcType = loForm.elements[lnElem].type ;
       if ( loForm.elements[lnElem].disabled != true && (lcType == 'text' || lcType == 'textarea' || lcType == 'select-one' || lcType == 'password' )) {
           loForm.elements[lnElem].focus() ;
           break ;
       }
       if ( loForm.elements[lnElem].disabled != true && (lcType == 'radio' || lcType == 'checkbox' || lcType == 'select-multiple' )) {
           break ;
       }
       lnElem++ ;
     }
  }
}

function check_email(e) {
ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
for(i=0; i < e.length ;i++){
	if(ok.indexOf(e.charAt(i))<0){ 
		return (false);
	}	
} 
if (document.images) {
	re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
	re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	if (!e.match(re) && e.match(re_two)) {
		return (-1);		
	} 
}
}

function RunClearPubAgencySaveParm(tcHref){
var toForm = document.forms(0);
var lcParms = BuildNamedParmList(toForm, true);
window.location.href = tcHref + lcParms
}

function CreateOnTopFindAnAgentTarget(toForm){
if (ValidateSelectAgencyForm(toForm)) {
	launch("", toForm.target,
					  "height=" + screen.height - 1 + ",width=700,screenX=0,left=0,screenY=0,top=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0",
					  "myWindow");
  return true; }
return false;
}

function cal_to_jd( era, y, m, d, h, mn, s )
{
	var jy, ja, jm;

	if( y == 0 ) {
		alert("There is no year 0 in the Julian system!");
        return "invalid";
    }
    if( y == 1582 && m == 10 && d > 4 && d < 15 && era == "CE" ) {
		alert("The dates 5 through 14 October, 1582, do not exist in the Gregorian system!");
        return "invalid";
    }

    if( era == "BCE" ) y = -y + 1;
	if( m > 2 ) {
		jy = y;
		jm = m + 1;
	} else {
		jy = y - 1;
		jm = m + 13;
	}

	var intgr = Math.floor( Math.floor(365.25*jy) + Math.floor(30.6001*jm) + d + 1720995 );

    var gregcal = 15 + 31*( 10 + 12*1582 );
	if( d + 31*(m + 12*y) >= gregcal ) {
		ja = Math.floor(0.01*jy);
		intgr += 2 - ja + Math.floor(0.25*ja);
	}

	var dayfrac = h/24.0 - 0.5;
	if( dayfrac < 0.0 ) {
		dayfrac += 1.0;
		--intgr;
	}

	var frac = dayfrac + (mn + s/60.0)/60.0/24.0;

    var jd0 = (intgr + frac)*100000;
    var jd  = Math.floor(jd0);
    if( jd0 - jd > 0.5 ) ++jd;
    return jd/100000;
}
function xreplace(checkMe,toberep,repwith){
var temp = checkMe;
var i = temp.indexOf(toberep);
while(i > -1)
{
temp = temp.replace(toberep, repwith);
i = temp.indexOf(toberep, i + repwith.length + 1);
}
return temp;
}

