//floating bubble tool tip, simply add the class "tip" to an anchor tag and include
//the content for the bubble in the "title" attribute
$(function(){
	$(".tip").tipTip({maxWidth: "250px", edgeOffset: 4, delay: 100});
});

//floating bubble tool tip ALTERNATE, simply add the class "tipAlt" to an anchor tag and include
//the content for the bubble in the "title" attribute
$(function(){
	$(".tipAlt").tipTip({maxWidth: "250px", edgeOffset: 4, delay: 100});
});


function showVideo(elm, path) {
	document.getElementById('video'+elm).style.display='block';
	var s1 = new SWFObject('/videos/jwplayer.swf','player','400','245','9');
	s1.addParam('allowfullscreen','true');
	s1.addParam('allowscriptaccess','always');
	s1.addParam('flashvars','file=http://www.boulderdigitalarts.com/videos/instructors/'+path+'&autostart=true');
	s1.write('videoPlayback'+elm);
}

function showVideoLarge(elm, path) {
	document.getElementById('video'+elm).style.display='block';
	var s1 = new SWFObject('/videos/jwplayer.swf','player','600','358','9');
	s1.addParam('allowfullscreen','true');
	s1.addParam('allowscriptaccess','always');
	s1.addParam('flashvars','file=http://www.boulderdigitalarts.com/videos/instructors/'+path+'&autostart=true');
	s1.write('videoPlayback'+elm);
}

function showClasses(elm) {
	document.getElementById('classes'+elm).style.display='block';
}

function hideVideo(elm) {
	document.getElementById('video'+elm).style.display='none';
}

function hideClasses(elm) {
	document.getElementById('classes'+elm).style.display='none';
}

function PaymentPlanInfo(action) {
	pos = findPos(document.getElementById('offeringCosts'));
	posTop = (pos[1]+25);
	posLeft = (pos[0]-265);
	if (action == 'show') {
	document.getElementById('PaymentPlanInfo').style.top=posTop+'px';
	document.getElementById('PaymentPlanInfo').style.left=posLeft+'px';
	document.getElementById('blackBackground').style.display='block';
	document.getElementById('PaymentPlanInfo').style.display='block';
	document.getElementById('PaymentPlanTable').style.display='none';
	} else {
	document.getElementById('blackBackground').style.display='none';
	document.getElementById('PaymentPlanInfo').style.display='none';
	document.getElementById('PaymentPlanTable').style.display='none';
	}
}

function PaymentPlanTable(action) {
	pos = findPos(document.getElementById('offeringCosts'));
	posTop = (pos[1]+25);
	posLeft = (pos[0]-265);
	if (action == 'show') {
	document.getElementById('PaymentPlanTable').style.top=posTop+'px';
	document.getElementById('PaymentPlanTable').style.left=posLeft+'px';
	document.getElementById('blackBackground').style.display='block';
	document.getElementById('PaymentPlanTable').style.display='block';
	document.getElementById('PaymentPlanInfo').style.display='none';
	} else {
	document.getElementById('blackBackground').style.display='none';
	document.getElementById('PaymentPlanTable').style.display='none';
	document.getElementById('PaymentPlanInfo').style.display='none';
	}
}

function followOffering(offeringID,elm,returnURL) {
	$.post("/functions/follow-offering.php", { id: offeringID, elm: elm, returnURL: returnURL },
	   function(data) {
	     $("#"+elm).prepend(data);
	     $("."+elm).prepend(data);
	});
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function switchTab(showElm,tabElm) {
	$(".tab").hide();
	$("#"+showElm).show();
	$(".tabSet").children().removeClass('activeTab');
	$("#"+tabElm).addClass('activeTab');
}

function switchTabGrey(showElm,tabElm) {
	$(".tab").hide();
	$("#"+showElm).show();
	$(".tabSetGrey").children().removeClass('activeTab');
	$("#"+tabElm).addClass('activeTab');
}

function hide(elm) {
	$("#"+elm).fadeOut(400);
}

function waitThenHide(elm) {
	$("#"+elm).delay(5500).fadeOut(400);
}

function waitThenHideLong(elm) {
	$("#"+elm).delay(10000).fadeOut(400);
}

function show(elm) {
	$("#"+elm).fadeIn(400);
}

/* automatically submit if any element in the form changes - form must have the autoSubmit class */
$(function() {
  $(".autoSubmit").change(function() {
    this.submit();
  });
});

function submitForm(elm) {
	$("#"+elm).submit();
}

function popWindow(url,h,w) { 
	window.open(url,"pop","menubar=1,resizable=1,width="+h+",height="+w); 	
}

function setValue(elm,val,submit) {
	$("#"+elm).val(val);
	if(submit == 'true') {
		$(".form1").submit();
	}
}
function showSchedule(format) {
	if(format == 'weekday') {
		document.getElementById('eveningSchedule').style.display = "none";
		document.getElementById('weekdaySchedule').style.display = "block";
	} else {
		document.getElementById('eveningSchedule').style.display = "block";
		document.getElementById('weekdaySchedule').style.display = "none";
	}
}

