// Global functions for Racecar Hobby


// Function to create client-side clock & date _______________________________________________________________________________________________
function doClock(){ // By Paul Davis - www.kaosweaver.com
  var t=new Date(),a=doClock.arguments,str="",i,a1,lang="10";
  var month=new Array('Januari','Jan','Februari','Feb','Mars','Mar','April','Apr','Maj','Maj','Juni','Jun','Juli','Jul','Augusti','Aug','September','Sep','Oktober','Okt','November','Nov','December','Dec');
  var tday= new Array('Söndag','Söndagen den','Måndag','Måndagen den','Tisdag','Tisdagen den','Onsdag','Onsdagen den','Torsdag','Torsdagen den','Fredag','Fredagen den','Lördag','Lördagen den');
  for(i=0;i<a.length;i++) {a1=a[i].charAt(1);switch (a[i].charAt(0)) {
  case "M":if  ((Number(a1)==3) && ((t.getMonth()+1)<10)) str+="0";
  str+=(Number(a1)>1)?t.getMonth()+1:month[t.getMonth()*2+Number(a1)];break;
  case "D": if ((Number(a1)==1) && (t.getDate()<10)) str+="0";str+=t.getDate();break;
  case "Y": str+=(a1=='0')?t.getFullYear():t.getFullYear().toString().substring(2);break;
  case "W":str+=tday[t.getDay()*2+Number(a1)];break; default: str+=unescape(a[i]);}}return str;
}

// Function for login via password  _______________________________________________________________________________________________
function submitentry(){
	password = document.password1.password2.value.toLowerCase()
	username = document.password1.username2.value.toLowerCase()
	passcode = 1
	usercode = 1
	for(i = 0; i < password.length; i++) {
		passcode *= password.charCodeAt(i);
	}
	for(x = 0; x < username.length; x++) {
		usercode *= username.charCodeAt(x);
	}
	if(usercode==1302359820300&&passcode==17444376069120)
	{
		window.location=password+".asp"}
	else{
		alert("password/username combination wrong")
	}
}

// Function for searching the site  _______________________________________________________________________________________________

var item = new Array();
c=0; item[c]=new Array("index.asp","","DemoSite","index,main,start,home,front,car","Racecar Hobby - Första sidan.");
c++; item[c]=new Array("produkter.asp","","About Me","about,author,contact,email,who","Contact details and general information about the creator of the site and what the site is about.");
c++; item[c]=new Array("links.htm","","Links page","links,more,where,similar,friends","Links to my favourite sites which I find interesting. Other friends sites which have similar interests to my own.");
c++; item[c]=new Array("main.htm","main/","Main Page","content,main,focus","The main part of my site which contains what you have come to see. Lots of stuff like that and more great things. All in a sub directory.");
c++; item[c]=new Array("logo.jpg","main/images/","Link Logo","link,image,logo,graphic","The logo.jpg is just a small image which you can place on your site as a link to me. It's in a second level subdirectory.");

page="<html><head><title>Sök resultat</title><link href='../new/jslib/csslib/racecarhobby.css' rel='stylesheet' type='text/css'><style type='text/css'>body { margin-left: 5px; margin-top: 5px; } </style></head><body><center><table width='750' border='0' cellpadding='4' cellspacing='4' bgcolor='#B0C9D6' class='tableborder2'>";

function search(frm) {
// win = window.open("","","scrollbars");
win = window.open("","", "width=800, height=600, location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes");
win.document.write(page);
txt = frm.srchval.value.split(" ");
fnd = new Array(); total=0;
for (i = 0; i < item.length; i++) {
fnd[i] = 0; order = new Array(0, 4, 2, 3);
for (j = 0; j < order.length; j++)
for (k = 0; k < txt.length; k++)
if (item[i][order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != "")
fnd[i] += (j+1);
}
for (i = 0; i < fnd.length; i++) {
n = 0; w = -1;
for (j = 0;j < fnd.length; j++)
if (fnd[j] > n) { n = fnd[j]; w = j; };
if (w > -1) total += show(w, win, n);
fnd[w] = 0;
}
win.document.write("</table><br><span class='aktutext'>Sökresultat: "+total+"<br></span></body></html>");
win.document.close();
}
function show(which,wind,num) {
link = item[which][1] + item[which][0]; 
line = "<tr><td><span class='aktutext'><a href='../new/jslib/"+link+"'>"+item[which][2]+"</a> Score: "+num+"<br>";
line += item[which][4] + "<br>"+link+"</span></td></tr>";
wind.document.write(line);
return 1;
}
function openPictureWindow_Fever(imageType,imageName,imageWidth,imageHeight,alt,posLeft,posTop) {  // v4.01
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	if (imageType == "swf"){
	newWindow.document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('<param name=movie value=\"'+imageName+'\"><param name=quality value=high>');
	newWindow.document.write('<embed src=\"'+imageName+'\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('</embed></object>');	}else{
	newWindow.document.write('<img src=\"'+imageName+'\" width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\">'); 	}
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}