function decision(url,delete_what){
	var message = "Are you sure that you want to delete " + delete_what + "?";
	if(confirm(message)) window.location.href = url;
}
function decisionSubmit(delete_what){
	var message = "Are you sure that you want to delete " + delete_what + "?";
	if(confirm(message)) document.deleteImage.submit();
}
function submitenter(myfield,e){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	if (keycode == 13)  {
		document.login.submit();
		return false;
	} else {
		return true;
	}
}
// Handle Email Addresses
function insertEmailAddress(contactName, emailUser, emailHost, subject, initialBodyText)  {
	if(emailHost == undefined || emailHost == "") emailHost = "jc-design.com";
	if(contactName == "") contactName = emailUser + "@" + emailHost;
	if(subject == undefined) subject = "";
	if(initialBodyText == undefined) initialBodyText = "";
	
	// Generate the extra URL information for e-mail subject and body.
	extraURLData = "";
	
	if(subject != "" || initialBodyText != "" ) {
		extraURLData = "?";
		if(subject != "" ) extraURLData += "subject=" + subject + "&";
		if(initialBodyText != "" ) extraURLData += "body=" + initialBodyText;
	}
  document.write( '<a href="' + 'mailto:' + emailUser + '@' + emailHost + extraURLData + '">' + contactName + '</a>' );
}
$(document).ready(function(){

	// Ticker
	$('#ticker').each(function(){
		var ticker = $(this);
		var fader = $('<span class="fader">&nbsp;</span>').css({display:'inline-block'});
		var links = ticker.find('ul>li>a');
		
		ticker.find('ul').replaceWith(fader);
		$("#orange-bar").css({height : "22px", "overflow" : "hidden"});
		
		var counter = 0;
		var curLink;
		var fadeSpeed = 600;
		var showLink = function() {
			var newLinkIndex = (counter++) % links.length;
			var newLink = $(links[newLinkIndex]);
			var fadeInFunction = function() {
					curLink = newLink;
					fader.append(curLink).fadeIn(fadeSpeed); 
			};
			
			if(curLink) {
				fader.fadeOut(fadeSpeed, function(){
					curLink.remove();
					setTimeout(fadeInFunction, 0);
				});
			} else {
				fadeInFunction();
			}
		};
		
		var speed = 6500;
		var autoInterval;
		
		var startTimer = function() {
				autoInterval = setInterval(showLink, speed);
		};
		
		ticker.hover(function(){
			clearInterval(autoInterval);
		}, startTimer);

		fader.fadeOut(0, function(){
			fader.text('');
			showLink();
		});
		startTimer();
			
	});
	
	//Remove outline from links
	$("a").focus(function(){
		$(this).blur();
	});

	// Remove Title
	$("a").removeAttr("title");
	//$("img").removeAttr("alt");
	
	// Video
	if($("#video").length ) { $("#video").colorbox({iframe:true, innerWidth:854, innerHeight:540}) };

});
