var folioDivWidth = 205;
var folioDivSlideDuration = 250;
var folioDivTriggerIdPrefix = "trigger";
var folioDivCount = 9;
var sliding=false;
function slideFolio(col){
	if (!sliding) {
		sliding = true;
		setTimeout("sliding=false;", 250);
		var x = ((col - 1) * -folioDivWidth)
		var folioChange = new Fx.Tween('folio', {
			duration: folioDivSlideDuration
		});
		folioChange.start('left', x);
		var cur = folioDivTriggerIdPrefix + col;
		$(cur).addClass('current');
		
		for (i = 1; i <= folioDivCount; i++) {
			var loopLI = folioDivTriggerIdPrefix + i;
			if (cur == loopLI) {
			}
			else {
				$(loopLI).removeClass('current');
			}
		}
	}
}
		
$(function() {
    /* set global variable for boxy window */
    var contactBoxy = null;
    /* what to do when click on contact us link */
    $('.contact_us').click(function(){
        var boxy_content;
        boxy_content += "<div style=\"width:300px; height:300px \"><form id=\"feedbacked\">";
        boxy_content += "<p>Subject<br /><input type=\"text\" name=\"subject\" id=\"subject\" size=\"41\" /></p><p>Your name and/or email:<br /><input type=\"text\" name=\"your_email\" size=\"41\" /></p><p>Comment:<br /><textarea name=\"comment\" id=\"comment\" cols=\"37\" rows=\"5\"></textarea></p><br /><input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Send >>\" />";
        boxy_content += "</form></div>";
        contactBoxy = new Boxy(boxy_content, {
            title: "Send feedback",
            draggable: false,
            modal:true,
            behaviours: function(c) {
                c.find('#feedbacked').submit(function() {
                    Boxy.get(this).setContent("<div style=\"width: 300px; height: 300px\">Sending...</div>");
                    // submit form by ajax using post and send 3 values: subject, your_email, comment
                    $.post("sendmail.php", { subject: c.find("input[name='subject']").val(), your_email: c.find("input[name='your_email']").val(), comment: c.find("#comment").val()},
                    function(data){
                        /*set boxy content to data from ajax call back*/
                        contactBoxy.setContent("<div style=\"width: 300px; height: 300px\">"+data+"</div>");
                    });
                    return false;
                });
            } 
        });
        return false;
    });
	
	$('#youtubevideo').click(function(){
		var boxy_content;
        boxy_content += "<div style=\"width:425px; height:344px \">";
        boxy_content += "<object width=\"425\" height=\"344\"><param name=\"movie\" value=\"http://www.youtube.com/v/p8cALrNEZtk&hl=en_US&fs=1&\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/p8cALrNEZtk&hl=en_US&fs=1&\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"425\" height=\"344\"></embed></object>";
        boxy_content += "</div>";		
		
		contactBoxy = new Boxy(boxy_content, {
			title: "WOD Timer Video",
			draggable:false,
			modal:true
		});
		return false;
	});
});


