File: //home/mycamden.co.uk/public_html/busilists/show_cats_and_sects2.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' ,
'mybrum' ,
'mycamden' ,
'mycardiff' ,
'mychelsea' ,
'mycityoflondon' ,
'myclapham' ,
'mydocklands' ,
'myedinburgh' ,
'myenfield' ,
'myglascow' ,
'mygreenwich' ,
'myhackney' ,
'myhammersmith' ,
'myhampstead' ,
'myharingay' ,
'myhighlands' ,
'myhounslow' ,
'myinverness' ,
'myislington' ,
'mykensington' ,
'mylambeth' ,
'myleeds' ,
'myleicester' ,
'myliverpool' ,
'mymanchester' ,
'mynewham' ,
'mynewcastle' ,
'mynottingham' ,
'mynottinghill' ,
'mynorwich' ,
'myoxford' ,
'mypaddington' ,
'myplymouth' ,
'mypreston' ,
'mysheffield' ,
'myshoreditch' ,
'mysouthhampton' ,
'mysouthwark' ,
'mysouthbank' ,
'mytowerhamlets' ,
'mywandsworth' ,
'mywestend' ,
'mywimbledon'
);
// setup the possible section we can publish to.
allCats = new Array(
array = new Array('Homes & Property', 'Estate/Letting Agents & Property Finders', 'Architects & Interior Designers', 'Furniture for Home & Garden', 'Plumbers', 'Electricians', 'Builders & DIY', 'Painters & Decorators', 'Roofing Services', 'Locksmiths', 'Security Systems & Burglar Alarms', 'Removals & Domestic Storage'),
array = new Array('Business Zone', 'Accountants & Tax Consultants', 'Banks & Building Societies', 'Finance Financial Services & Insurance', 'Bureaux de Change', 'Conference Venues', 'Courier & Delivery Services', 'Hotels & Accommodation', 'Printers', 'Recruitment Agencies', 'Solicitors', 'Training Services'),
array = new Array('Services', 'Goods delivered to your door', 'Computer & Internet Services', 'Dry Cleaners & Laundrettes', 'Electricians', 'Funeral Directors', 'Graphic & Web Designers', 'Hotels & Accommodation', 'Party Organisers', 'Photographers & Processing', 'Plumbers & Central Heating Engineers', 'Travel Agents', 'Car Dealers', 'Car and Van Hire', 'Mechanics & Car Repair', 'Taxis and Private Hire'),
array = new Array('Arts & Entertainment', 'Cinema', 'Performance & Theatre', 'Museums & Galleries', 'Studio & Workshops', 'Video-DVD Rentals & Sales'),
array = new Array('Health & Beauty', 'Beauty', 'Hairdressers', 'Mens Beauty and Barbers', 'Food and Products', 'Chemists', 'Clinics', 'Hospitals', 'Doctors', 'Dentists', 'Opticians', 'Services & Complementary Health', 'Gyms & Leisure Centres'),
array = new Array('Kids & Youth','Schools', 'Play groups', 'Associations', 'Nannies', 'Baby Sitters', 'Toys for sale', 'Tuition'),
array = new Array('Fashion & Lifestyle', 'Fashion Shops', 'Mens Fashion Shops', 'Fashion Accessories', 'Bridal wear', 'Florists', 'Jewellers & Jewellery designers', 'Shoe shops'),
array = new Array('Football & Sport', 'Sports', 'Clubs'),
array = new Array('Community', 'Adult Education', 'Advice Centres', 'Libraries', 'Local Courses & Classes', 'Places of Worship'),
array = new Array('Personal Services', 'Escorts', 'Personal Services', 'Massage parlours'),
array = new Array('Bars & Music', 'Bars & Pubs', 'Night Clubs', 'Club Night Listings', 'Hi Fi Shops', 'Music Shops', 'Record & CD Shops')
);
// 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()
{
var numberOfCats = allCats.length;
var tempCount = 0;
while(tempCount < numberOfCats)
{
var linker = document.location.pathname+"?cat="+escape(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);
document.all.whichCat.innerHTML = "<font class=ShowAdCategoryTitle>"+cat+" - Classifieds</font>";
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><font class=AdEmail>email: <a href=mailto:"+emailAdd+">"+emailAdd+"</a></font><br><font class=AdWeb>web: <a href=http://"+webAdd+">"+webAdd+"</a></font>"
document.all.preview.innerHTML = previewCode;
}
// draw adverts for the selected site and category and subcategory.
function drawAdverts(cat,subcat)
{
// count the total number of adverts in the file
var numberOfAdsinFile = allAds.length;
var tempCount = numberOfAdsinFile-1;
var numberOfAdsMatching = 0;
// find out the required section
if(document.location.search.indexOf("subcat=")!= -1)
{
var subcat = unescape(document.location.search.substring(document.location.search.indexOf("subcat=")+7, document.location.search.length));
}
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(subcat);
//alert(cat);
// go through the ads and draw the ones which are in the required section
while(tempCount > 1)
{
if(eval('allAds['+tempCount+'][0]') == cat && eval('allAds['+tempCount+'][1]') == subcat)
{
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("<font class=AdTitle>"+thisTitle+"</font><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>");
}
tempCount = tempCount-1;
}
}
// *************************************************************************************
// *************************************************************************************
// *************************************************************************************
// *************************************************************************************
// *************************************************************************************
// *************************************************************************************
//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();
//
// }
//
// if(document.createAd.amount(document.createAd.amount.selectedIndex).value == 0)
// {
// alert("you must choose a payment plan");
// return;
// };
//
// if(document.createAd.amount[document.createAd.amount.selectedIndex].value == 27.50)
// {
// }
// else
// {
// document.createAd.startDate.value = SumarDate(365)
// document.createAd.noOfPayments.value = 0
// document.createAd.intervalUnit.value = 4
// document.createAd.intervalMult.value = 1
// document.createAd.normalAmount.value = 41.175
// document.createAd.option.value = 1
// }
// unescape everything so that you don't get any errors when publishing
function unescapeEverything()
{
if(document.createAd.emailadd.value == "")
{
alert("email field is required.");
return;
};
if(document.createAd.contact.value == "")
{
alert("contact field is required.");
return;
};
if(document.createAd.tel.value == "")
{
alert("telephone number is required.");
return;
};
if(confirm("do you agree with the advert?\n\nmake sure your advert is exactly as you want it before publishing, \nyou will not be able to go back and change it."))
{
//document.createAd.startDate.value = SumarDate(90)
//document.createAd.noOfPayments.value = 0
//document.createAd.intervalUnit.value = 3
//document.createAd.intervalMult.value = 3
//document.createAd.normalAmount.value = 27.50
//document.createAd.option.value = 1
document.createAd.M_adtitle.value = escape(document.createAd.adtitle.value);
document.createAd.M_adtext.value = escape(document.createAd.adtext.value);
document.createAd.M_emailadd.value = escape(document.createAd.emailadd.value);
document.createAd.email.value = escape(document.createAd.emailadd.value);
document.createAd.M_tel.value = escape(document.createAd.tel.value);
document.createAd.M_contact.value = escape(document.createAd.contact.value);
document.createAd.name.value = escape(document.createAd.contact.value);
document.createAd.M_catx.value = document.createAd.catx.value;
document.createAd.M_sitex.value = escape(document.createAd.sitex.value);
document.createAd.M_subcatx.value = document.createAd.subcatx.value;
document.createAd.M_site.value = escape(document.createAd.site.value);
document.createAd.M_siteext.value = location.host;
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();
}
}
function SumarDate(qty)
{
var d,m,y,da,ok
da = new Date()
m = da.getMonth() + 1
d = da.getDate()
y = da.getYear()
d = d + qty
ok = true
while (ok) {
if (((m == 1) || (m == 3) || (m == 5) || (m == 7) || (m == 8) || (m == 10) || (m == 12)) && (d > 31)){
d = d - 31
m++
}
if (((m == 4) || (m == 6) || (m == 9) || (m == 11)) && (d > 31)){
d = d - 30
m++
}
if ((m == 2) && (d > 28)){
if ((y % 4) == 0){
if ((y % 100) != 0) {
if (d > 29) {
d = d - 29
m++
}
}
else {
if ((y % 400) == 0) {
if (d > 29) {
d = d - 29
m++
}
}
else {
d = d - 28
m++
}
}
}
else {
d = d - 28
m++
}
}
if (m > 12) {
m = m - 12
y++
}
if ((m == 1) || (m == 3) || (m == 5) || (m == 7) || (m == 8) || (m == 10) || (m == 12)){
if (d < 32) {
ok = false
}
}
if ((m == 4) || (m == 6) || (m == 9) || (m == 11)){
if (d < 31) {
ok = false
}
}
if (m == 2){
if ((y % 4) == 0){
if ((y % 100) != 0) {
if (d < 30) {
ok = false
}
}
else {
if ((y % 400) == 0) {
if (d < 30) {
ok = false
}
}
else {
if (d < 29) {
ok = false
}
}
}
}
else {
if (d < 29) {
ok = false
}
}
}
}
if (m < 10) {
m = "0" + m
}
if (d < 10) {
d = "0" + d
}
return y + "-" + m + "-" + d
}
//-->