// These file contains the core functions for JazzyD.co.uk

/* begin tigra tables */
// Title: tigra tables
// Description: See the demo at url
// URL: http://www.softcomplex.com/products/tigra_tables/
// Version: 1.0
// Date: 03-04-2002 (mm-dd-yyyy)
// Author: Denis Gritcyuk <denis@softcomplex.com>
// Notes: Permission given to use this script in any kind of applications if
//    header lines are left unchanged. Feel free to contact the author
//    for feature requests and/or donations

function tigra_tables (
		str_tableid, // table id (req.)
		num_header_offset, // how many rows to skip before applying effects at the begining (opt.)
		num_footer_offset, // how many rows to skip at the bottom of the table (opt.)
		str_odd_color, // background color for odd rows (opt.)
		str_even_color, // background color for even rows (opt.)
		str_mover_color, // background color for rows with mouse over (opt.)
		str_onclick_color // background color for marked rows (opt.)
	) {

	 // skip non DOM browsers
	if (typeof(document.all) != 'object') return;

	// validate required parameters
	if (!str_tableid) return alert ("No table(s) ID specified in parameters");
	var obj_tables = (document.all ? document.all[str_tableid] : document.getElementById(str_tableid));
	if (!obj_tables) return alert ("Can't find table(s) with specified ID (" + str_tableid + ")");

	// set defaults for optional parameters
	var col_config = [];
	col_config.header_offset = (num_header_offset ? num_header_offset : 0);
	col_config.footer_offset = (num_footer_offset ? num_footer_offset : 0);
	col_config.odd_color = (str_odd_color ? str_odd_color : '#ffffff');
	col_config.even_color = (str_even_color ? str_even_color : '#dbeaf5');
	col_config.mover_color = (str_mover_color ? str_mover_color : '#6699cc');
	col_config.onclick_color = (str_onclick_color ? str_onclick_color : '#4C7DAB');
	
	// init multiple tables with same ID
	if (obj_tables.length)
		for (var i = 0; i < obj_tables.length; i++)
			tt_init_table(obj_tables[i], col_config);
	// init single table
	else
		tt_init_table(obj_tables, col_config);
}

function tt_init_table (obj_table, col_config) {
	var col_lconfig = [],
		col_trs = obj_table.rows;
	for (var i = col_config.header_offset; i < col_trs.length - col_config.footer_offset; i++) {
		col_trs[i].config = col_config;
		col_trs[i].lconfig = col_lconfig;
		col_trs[i].set_color = tt_set_color;
		col_trs[i].onmouseover = tt_mover; 
		col_trs[i].onmouseout = tt_mout;
		col_trs[i].onmousedown = tt_onclick;
		col_trs[i].order = (i - col_config.header_offset) % 2;
		col_trs[i].onmouseout();
	}
}
function tt_set_color(str_color) {
	this.style.backgroundColor = str_color;
}

// event handlers
function tt_mover () {
	if (this.lconfig.clicked != this)
		this.set_color(this.config.mover_color);
}
function tt_mout () {
	if (this.lconfig.clicked != this)
		this.set_color(this.order ? this.config.odd_color : this.config.even_color);
}
function tt_onclick () {
	if (this.lconfig.clicked == this) {
		this.lconfig.clicked = null;
		this.onmouseover();
	}
	else {
		var last_clicked = this.lconfig.clicked;
		this.lconfig.clicked = this;
		if (last_clicked) last_clicked.onmouseout();
		this.set_color(this.config.onclick_color);
	}
}
/* end tigra tables */

/* open windows */


function openWin(url, nam, feat)	{
	/*
		openWin("url.html", "name", 'toolbar=0,status=0,scrollbars=0,location=0,directories=0,menubar=0,resizable=0,width=410,height=410');
	*/
		window.open(url, nam, feat);
	}

function openPhoto(Purl, VorH)	{
var theFeat, photoName, htmlurl;
theFeat = 'toolbar=0,status=0,scrollbars=0,location=0,directories=0,menubar=0,resizable=0,';
		theFeat+= 'width=410,height=410';
		photoName = "jazzyPhotos";
	htmlurl = './viewPhoto.php?photo='+Purl;
	openWin(htmlurl, photoName, theFeat);
}

function openPhotoShow(Show)	{
var theFeat, photoName, htmlurl;
theFeat = 'toolbar=0,status=0,scrollbars=0,location=0,directories=0,menubar=0,resizable=0,';
		theFeat+= 'width=750,height=520';
		showName = "jazzyPhotoShow";
	htmlurl = './photoShow/?show='+Show;
	openWin(htmlurl, showName, theFeat);
}

/* end open windows */
function init()	{
	/* break this routine up so that the function calls another function that places elements */

	var w = window, d = document, pageID = d.body.id, pageClass = d.body.className, statusStr = "", logo = d.getElementById("jdlogo");
	var focus = 0;

	switch(pageID)	{

		case "splash":
		break;

		case "JazRedux":
			focus = 1;
		break;

		default:
			statusStr = " switch default";
		break;
	}

	// applied to all pages on loading
	soopaPopSetup(); // set up soopaPopUp windows
	// set up other widgets
	w.status = "jazzyd.net";
	if(focus == 1)	
		w.focus();

}

function changeImages(n, s)	{
	// simple swap function for images
	document.images[n].src = s;
	return;
}

function preloadImages()	 {
	// ensure that document supports images
	if (document.images) {
		if (typeof(document.imgs) == 'undefined'){
		document.imgs = new Object();
	}
	document.imgs.loadedImages = new Array();
	// Loop through all the arguments.
	var argLength = preloadImages.arguments.length;
	for(arg=0; arg < argLength; arg++) {
		// For each arg, create a new image.
		document.imgs.loadedImages[arg] = new Image();
		// Then set the source of that image to the current argument.
		document.imgs.loadedImages[arg].src = preloadImages.arguments[arg];
		}
	}
}

// begin soopaPopUp
function soopaPopSetup() {
	var a;
	for (var i = 0; (a = document.links[i]); i++) {
		if (a.target && a.target.indexOf("_soopaPop") == 0) {
			a.onclick = soopaPop;
		}
	}
}

function soopaPop() {
	var a = this.target.split(":");
	var sFeatures = a[1];
	/* ###############
		ss29: added while loops to replace dodts and 
		dashes in target attribute. Coma and equals 
		cause xhtml validation errors. Simple adaption 
		of an inspiring widget. Youngpup is the jet.
		############### */
	while (sFeatures.indexOf(".") != -1) { sFeatures = sFeatures.replace(".", ","); }
	while (sFeatures.indexOf("-") != -1) { sFeatures = sFeatures.replace("-", "=");	}
	// end of ss29 customisation.
	window.open(this.href, a.length > 2 ? a[2] : String((new Date()).getTime()), sFeatures);
	return false;
}
// end soopPopUp

// window open from flash
/*

menubar 
This is the row of functions that appears on most software applications. Normally it includes File, Edit, and a few other items. 

status 
This is the message bar at the bottom of your window. When you move your mouse over an HTML link, the URL appears in the status bar. You may have seen pages that use JavaScript to turn this status bar into a scrolling marquee. I'm not going to show you how to do this. If you want to know, you have to figure it out yourself. "Down with marquees," the monkey cried! 

scrollbars 
This allows scrollbars to appear when necessary. 

resizable 
If resizable is listed, the window can be resized. Be careful of the spelling. I always get it wrong. 

width 
The width of the window in pixels. 

height 
The height of the window in pixels. 

toolbar 
The browser toolbar, which contains the Back and Forward buttons, the Stop button, and the Home button, among others. 

location 
The text area of a browser into which you can type URLs. 

directories 
The directories that Netscape browsers have called "What's new," "What's cool," and so on. 

*/
function flaOpenWin(url)	{
	url = url + "?" + sessStr + "&flash=yes";
	window.open(url, "jazzyRedux", "menubar = 0, status = 0, scrollbars = 0, resizable = 0, width = 720, height = 380, toolbar = 0, location = 0, directories = 0");
	window.location.href = "./next.php?" + sessStr + "&flash=yes";
}

// end open from flash

// begin debug

function debug(obj)
{
	var s = "";
	var i = 0;

	for (prop in obj)
	{
		s += prop + ":" + obj[prop] + "\n";
		if (++i % 10 == 0) {
			alert(s);
			s = "";
		}
	};

};

// end debug

// new open window script - remove the others later
function openCenterWin(mypage, myname, w, h, scroll, resize) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resize
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

window.onload = init; window.onresize = init;






