File: //home/mycamden.co.uk/public_html/classifieds/show_cats_and_sects3.js
<!--
// This files controls the sites and categories that will appear on the
// User creates advert page.
// setup the list of sites we can put adverts on.
allSites = new Array(
'please select\.\.\.' ,
'myaberdeen' ,
'mybelfast' ,
'mybrent' ,
'mybrighton' ,
'mybristol' ,
'mybrixton' ,
'mybrum' ,
'mycamden' ,
'mycardiff' ,
'mychelsea' ,
'mycityoflondon' ,
'myclapham' ,
'mydocklands' ,
'myedinburgh' ,
'myenfield' ,
'myfulham' ,
'myglasgow' ,
'mygreenwich',
'myhackney' ,
'myhammersmith' ,
'myhampstead' ,
'myharingey' ,
'myhighlands' ,
'myhounslow' ,
'myinverness' ,
'myislington' ,
'mykensington' ,
'mylambeth' ,
'myleeds' ,
'myleicester' ,
'myliverpool' ,
'mylivingston' ,
'mymanchester' ,
'mynewcastle' ,
'mynewham' ,
'mynorwich' ,
'mynottingham' ,
'mynottinghill' ,
'myoxford' ,
'mypaddington' ,
'myplymouth' ,
'mypreston' ,
'mysheffield' ,
'myshoreditch' ,
'mysouthbank' ,
'mysouthhampton',
'mysouthwark' ,
'mytowerhamlets' ,
'mywandsworth' ,
'mywestend',
'mywimbledon'
);
// setup the possible section we can publish to.
allCats = new Array(
//array = new Array('Homes & Property', 'Property for Rent', 'Property for Rent wanted', 'Removals and Domestic Storage'),
//array = new Array('Business Zone', 'Business Services', 'Jobs wanted', 'Jobs offered', 'Recruitment'),
array = new Array('Health & Beauty','Beauty', 'Mobile Hairdressers', 'Services and Complementary Health', 'Personal Trainers'),
array = new Array('Kids & Youth','Schools', 'Play groups', 'Associations', 'Nannies', 'Baby Sitters', 'Tuition'),
array = new Array('Community & Services', 'Groups and Organisations', 'Charities', 'Help wanted', 'Help needed', 'Dog walkers','Baby sitters', 'Tuition', 'Sport', 'Musicians/Djs', 'Activities', 'Artists', 'Childcare', 'General', 'Groups', 'Pets', 'Volunteers', 'Classes', 'Stuff for Sale', 'Household Goods', 'Stuff Wanted')
//array = new Array('Personal Services', 'Escorts', 'Personal Services', 'Massage parlours')
);
// draw the list of avialable sites onto the page.
function drawSites()
{
var numberOfSites = allSites.length;
//alert(numberOfSites);
var tempCount = 0;
document.writeln('<select name="site" size="1" onchange="document.createAd.sitex.value=this.options[this.selectedIndex].value">');
while(tempCount < numberOfSites)
{
if(tempCount == 0)
{
document.writeln('<option value="'+allSites[tempCount]+'" selected>'+allSites[tempCount]+'</option>');
}
else
{
document.writeln('<option value="'+allSites[tempCount]+'">'+allSites[tempCount]+'</option>');
}
tempCount = tempCount+1;
}
document.writeln('</select>');
}
// draw the list of avialable categories onto the page.
function drawCats()
{
var numberOfCats = allCats.length;
var tempCount = 0;
while(tempCount < numberOfCats)
{
{
document.writeln('<a class=WriteAdCategoryLinks href="#" onclick="javascript:drawSubCats(\''+tempCount+'\'); document.createAd.catx.value=\''+allCats[tempCount][0]+'\'; this.style.backgroundColor=\'yellow\'">'+allCats[tempCount][0]+'</a><br>');
}
tempCount = tempCount+1;
}
}
// draw the list of avialable subcategories onto the page.
function drawSubCats(cat)
{
var numberOfSubCats = allCats[cat].length;
//alert(numberOfSubCats);
var tempCount = 1;
allLinks = new String();
while(tempCount < numberOfSubCats)
{
allLinks = allLinks+"<a class=WriteAdSubCategoryLinks href=# onclick='javascript: document.createAd.subcatx.value=\""+allCats[cat][tempCount]+"\"; showWhere(); this.style.backgroundColor=\"yellow\"'>"+allCats[cat][tempCount]+"</a><br>";
tempCount = tempCount+1;
}
document.all.subcat.innerHTML = allLinks;
}
// draw the bit of text that shows you where the advert will get written to
function showWhere()
{
var site = document.createAd.sitex.value;
var cat = document.createAd.catx.value;
var subcat = document.createAd.subcatx.value;
document.all.createWhere.innerHTML = site+" >> "+cat+" >> "+subcat;
}
// check that the first stages have been comepleted before they continue
function checkFirstStage()
{
var site = document.createAd.sitex.value;
var cat = document.createAd.catx.value;
var subcat = document.createAd.subcatx.value;
if(site == "" || cat == "" || subcat == "")
{
alert("you must comeplete the above stages before you can compose your advert");
document.createAd.site.focus();
}
}
// Draw the links for the side of the show adverts page.
function drawCatLinks()
{
//alert(allCats.length);
var numberOfCats = allCats.length;
var tempCount = 0;
while(tempCount < numberOfCats)
{
var linker = "#"+allCats[tempCount][0];
document.writeln('<a class=ShowAdCategoryLinks href='+linker+'>'+allCats[tempCount][0]+'</a><br>');
tempCount = tempCount+1;
}
}
// Draw the subcat links down the right
function drawSubCatLinks()
{
if(document.location.search.indexOf("cat=")!= -1)
{
var cat = unescape(document.location.search.substring(document.location.search.indexOf("cat=")+4, document.location.search.indexOf("&")));
// alert(cat);
var numberOfCats = allCats.length;
var tempCount = 0;
while(tempCount < numberOfCats)
{
if(allCats[tempCount][0] == cat)
{
var numberOfEles = allCats[tempCount].length;
var eleCount = 1;
while(eleCount < numberOfEles)
{
var linker = document.location.pathname+"?cat="+document.location.search.substring(document.location.search.indexOf("cat=")+4, document.location.search.indexOf("&"))+"&subcat="+escape(allCats[tempCount][eleCount]);
document.writeln('<a class=ShowAdSubCategoryLinks href='+linker+'>'+allCats[tempCount][eleCount]+'</a><br>');
eleCount = eleCount+1;
}
}
tempCount = tempCount+1;
}
}
}
// draw the preview of the advert.
function drawPreview()
{
// var emailAdd = document.createAd.emailadd.value;
// var webAdd = document.createAd.webAdd.value;
var adtitle = document.createAd.adtitle.value;
var adtext = document.createAd.adtext.value;
var tel = document.createAd.tel.value;
var previewCode = "<font class=AdTitle>"+adtitle+"</font><br><font class=AdText>"+adtext+"</font><br><font class=AdTel>tel: "+tel+"</font><br>"
document.all.preview.innerHTML = previewCode;
}
// draw adverts for the selected site and category and subcategory.
function drawAdverts()
{
// count the total number of adverts in the file
var numberOfAdsinFile = allAds.length;
var tempCount = numberOfAdsinFile-1;
var catCount = 0;
var numberOfAdsMatching = 0;
var numberOfCats = allCats.length;
var catCountDiv = new String();
document.writeln('<table width="610px" cellpadding=0 cellspacing=0 border=0 cols=2>');
while(catCount < numberOfCats)
{
document.writeln('<tr height="25" bgcolor=#C1DAFB><td colspan=2 class=catRow><font size=2 > <b>'+allCats[catCount][0]+'</b><a name="cat'+ catCount+'"></a></font></td></tr>');
document.writeln('<tr><td>')
// go through the ads and draw the ones which are in the required section
while(tempCount > 1)
{
if(eval('allAds['+tempCount+'][0]') == allCats[catCount][0])
{
numberOfAdsMatching = numberOfAdsMatching+1;
//alert("found one");
thisTitleEscaped = new String(allAds[tempCount][2]);
thisTitle = unescape(thisTitleEscaped);
thisTextEscaped = new String(allAds[tempCount][3]);
re = new RegExp ('%0D%0A', 'g');
thisTextBreaked = thisTextEscaped.replace(re, '<BR>');
thisText = unescape(thisTextBreaked);
// thisEmail = new String(allAds[tempCount][4]);
// thisWebEscaped = new String(allAds[tempCount][5]);
// thisWeb = unescape(thisWebEscaped);
thisTelEscaped = new String(allAds[tempCount][6]);
thisTel = unescape(thisTelEscaped);
document.writeln("<a name="+allAds[tempCount][0]+"></a>");
document.writeln("<a href='show_class.html?ad=" + tempCount + "'>"+thisTitle+" - "+allAds[tempCount][1]+"</a><br><br>");
// document.writeln("<font class=AdText>"+thisText+"</font><br>");
// document.writeln("<font class=AdEmail>email: <a href=mailto:"+thisEmail+">"+thisEmail+"</a></font><br>");
// document.writeln("<font class=AdWeb>web: <a href=http://"+thisWeb+">"+thisWeb+"</a></font><br>");
// document.writeln("<font class=AdTel>tel: "+thisTel+"</font><br><br>");
// for pocket this - take out the hard breaks
re2 = new RegExp ('<BR>', 'g');
// for pocket this replace spaces with +
re3 = new RegExp (' ', 'g');
// subject for pocket this
thisTitle = thisTitle.replace(re2, "+");
pocketSubject = thisTitle.replace(re3, "+");
// body for pocket this
thisText = thisText + "+tel:+" +thisTel;
thisText = thisText.replace(re2, "+");
pocketBody = thisText.replace(re3, "+");
//document.writeln("<font class=AdTel><a href='http://uk.partners.pocketthis.com/ptl.pt?IP=7000166&PT=Note&PLS=" + pocketSubject + "&PLB=" + pocketBody + "'>send this to my mobile >></a></font><br><br>");
}
tempCount = tempCount-1;
}
if(numberOfAdsMatching == 0)
{
document.writeln("<font size=1>Be the first to get a listing here >><br><a href=category_select.htm>Click here to add your listing...</a></font>");
}
numberOfAdsMatching = 0;
tempCount = numberOfAdsinFile-1;
document.writeln('</td></tr>');
catCount = catCount+1;
}
document.writeln('</table>')
//while(catCount < numberOfCats)
// {
// catCountDiv = String(catCount / 2);
// if(eval('catCountDiv.indexOf(".")') == -1)
// {
// alert(catCountDiv);
// document.writeln('<tr><td>'+catCount+'</td>');
// catCount = catCount+1;
// }
// else
// {
// document.writeln('<td>'+catCount+'</td></tr>');
// catCount = catCount+1;
// }
// }
}
// draw newest adverts for the selected site and category.
function drawNewAdverts()
{
document.writeln('<table width="610" id="pfSearch" style="overflow: hidden;" bgcolor="#C1DAFB" cellspacing="20" cellpadding="0">');
document.writeln('<tr>');
document.writeln('<td>');
document.writeln('<font color="#52ADFB" size="2"><a href="category_select.htm"><b>FREE local classified listings</b></a></font><br>');
// count the total number of adverts in the file
var numberOfAdsinFile = allAds.length;
var tempCount = numberOfAdsinFile-1;
var catCount = 0;
var numberOfAdsMatching = 0;
var numberOfCats = allCats.length;
var catCountDiv = new String();
var str = new String();
var len = new String();
while(catCount < numberOfCats)
{
str = '<br><font size=1 color="#666666"><b>' + allCats[catCount][0] +'</b></font><br>';
// go through the ads and draw the ones which are in the required section
while(tempCount > 1 && numberOfAdsMatching < 2)
{
if(eval('allAds['+tempCount+'][0]') == allCats[catCount][0])
{
numberOfAdsMatching = numberOfAdsMatching+1;
//alert("found one");
thisTitleEscaped = new String(allAds[tempCount][2]);
thisTitle = unescape(thisTitleEscaped);
len = '<a href="show_class.html?ad=' + tempCount + '"> ' + thisTitle + '</a><br>';
if((allAds[tempCount][1].length + thisTitle.length) > 30){
str = str + len;
}
else {
str = str + len;
}
}
tempCount = tempCount-1;
}
str = str + '';
if(numberOfAdsMatching != 0)
{
document.writeln(str);
}
numberOfAdsMatching = 0;
tempCount = numberOfAdsinFile-1;
catCount = catCount+1;
str = "";
}
document.writeln('<table width="500px" id="pfSearch" style="overflow: hidden;" bgcolor="#C1DAFB" border="0" cellspacing="0" cellpadding="0">');
document.writeln('<a href="http://' + backlink + '/' + folder + '/services.htm"></a>');
//document.writeln('Online free classifieds and free advertisement site for business opportunity, personal ads, cars, musicians, and much more.<br>');
document.writeln('<B><br>');
document.writeln('<a href="http://' + backlink + '/' + folder + '/services.htm">Click here for ALL our listings</A> ');
document.writeln('<A href="category_select.htm">Click here to ADD your FREE listing ...</B></A></td>');
document.writeln('</tr>');
document.writeln('</table></td>');
document.writeln('</tr>');
document.writeln('</table>');
}
var adToDraw = "";
var sear = "";
sear = document.location.search;
if(sear.indexOf("ad=") != -1) {
adToDraw = sear.substring(sear.indexOf("ad=")+3, sear.length);
}
function drawOneAdvert()
{
//alert(adToDraw);
thisTitleEscaped = new String(allAds[adToDraw][2]);
thisTitle = unescape(thisTitleEscaped);
thisTextEscaped = new String(allAds[adToDraw][3]);
re = new RegExp ('%0D%0A', 'g');
thisTextBreaked = thisTextEscaped.replace(re, '<BR>');
thisText = unescape(thisTextBreaked);
// thisEmail = new String(allAds[tempCount][4]);
// thisWebEscaped = new String(allAds[tempCount][5]);
// thisWeb = unescape(thisWebEscaped);
thisTelEscaped = new String(allAds[adToDraw][6]);
thisTel = unescape(thisTelEscaped);
document.writeln(' <table width="610px"><tr> <td bgcolor="#C1DAFB" height="25"><font size=2 > <b>'+thisTitle+' - '+allAds[adToDraw][1]+'</b></font></td></tr>');
document.writeln(' <tr><td ><br>'+thisText);
document.writeln('<br><br><b>tel:</b> '+thisTel+'<br><br>');
document.writeln('<b><a href="/' + folder + '/services.htm">view more Classifieds</a></b><br>');
document.writeln(' </td></tr></table>');
}
// unescape everything so that you don't get any errors when publishing
function unescapeEverything()
{
document.createAd.adtitle.value = escape(document.createAd.adtitle.value);
document.createAd.adtext.value = escape(document.createAd.adtext.value);
//document.createAd.emailadd.value = escape(document.createAd.emailadd.value);
//document.createAd.webAdd.value = escape(document.createAd.webAdd.value);
document.createAd.tel.value = escape(document.createAd.tel.value);
document.createAd.contact.value = escape(document.createAd.contact.value);
document.createAd.submit();
}
function ValidateEMail(obj)
{
var bVali = true;
if (obj.value != "") {
aMail = obj.value.split("@")
if (aMail.length != 2) {
bVali = false;
} else {
usuaExp = /[a-z_0-9\.]/;
if (!usuaExp.test(aMail[0])) {
bVali = false;
} else {
aHost = aMail[1].split(".");
if (aHost.length < 2) {
bVali = false;
}
}
}
}
if (!bVali) {
alert("email address is invalid!");
obj.focus();
}
}
//-->