// 11-09 updates //
//http://www.youtube.com/watch?v=tgVeq6ynGQs
var video_url =' http://www.youtube.com/v/tgVeq6ynGQs&hl=en_US&fs=1';;

//////////////// CONFIGURING THE FLASH OBJECT ///////////////////////
// Simply change the previous line to the new URL you want.
// MAKE SURE is is properly quoted, beginning and ending
// with a single quote. Example: 
// var vid = 'http://www.youtube.com/v/N9i2fqxSjTI&hl=en_US&fs=1';
// Note that this is NOT the same as the "watch video" URL - when viewing the
// video on YouTube, get the "embed" code but only use the URL
// portion of it as shown above.
///////////////// No need to edit anything below! ///////////////////

// attach behaviors on window load.

window.onload= function () { attachBehaviors(); };

// Attach behaviors to search forms.

function attachBehaviors() {
	ext_links = new Array('about-link','fb-link','tw-link');
	frms = new Array('main-form','search-form');
	var id;
	for (i=0;i<frms.length;i++) {
		id = frms[i];
		if (document.getElementById(id)) {
			document.getElementById(id).onsubmit=function() { return appendURL(this.q.value); }
		}
	}
	for (i=0;i<ext_links.length;i++) {
		id = ext_links[i];
		if (document.getElementById(id)) {
			document.getElementById(id).onclick=function() { return newWin(this.href,600,500); };
		}
	}
	if (document.getElementById('flash-placeholder')) { init_video(); }
}

// Initialize video if it exists. ID element is
// already checked in window.onload.

function init_video () {
	var vid = new SWFObject(video_url, 'DIYgigsVideo', '425', '344', '6', '#ffffff'); 
	vid.addParam("wmode", "transparent");
	vid.write('flash-placeholder');
}

// Simple new window.

function newWin(url,w,h) {
	if (! url) { return; }
	var day= new Date();
	var id = day.getTime();
	if ((screen.height) && (h > screen.height-100)) { h = screen.height-100; }
	var params = 'width='+w+',height='+h+',toolbar,scrollbars,resizable';
	if (url!='') {
		var win = open(url,id,params);
		win.document.close();
	}
	return false;
}

// For the search forms, generate a S.E. friendly URL. This really has no
// bearing on S.E. freindliness directly because the URL's are generated
// by Javascript, but it avoids query strings and get.
function appendURL(val) {
 	if (val == '') { alert('Please enter a search term.'); }
 	else { 
		var regExp = /\s+/g;
		val = val.replace(regExp, '-');
		var url = '/Musical-Venues/' + val;
		document.location = url; 
	}
 return false;
}
