var youtube = '';

function toggleVideo(){
    if ($('slideshow').style.display == 'none') {
        $('video-feature').src = "images/uploads/feature.png";
        $('slideshow').show();
		youtube = $('player').innerHTML;
		$('player').update('');
        $('player').hide();
    }
    else {
        $('video-feature').src = "images/uploads/feature_close.png";
        $('slideshow').hide();
		if ($('player').innerHTML == '') {
			$('player').update(youtube);
		}
        $('player').show();
    }
}

function ajaxSubmitDoc(formName){
    var obj = findObj(formName);
    if (obj != null) {
        allparams = $(obj).serialize();
        new Ajax.Request($(obj).action, {
            method: 'post',
            asynchronous: true,
            evalScripts: true,
            onLoading: function(request){
                pic = $(obj).down('.prodPageImg');
                new Effect.Pulsate(pic, {
                    pulses: 2,
                    duration: 1.0
                });
                return false;
            },
            onSuccess: function(request){
                response = request.responseText;
                x = response.indexOf("<!-- startcartbox -->");
                y = response.indexOf("<!-- endcartbox -->");
                //				alert(response.substring(x,y));
                $('cart-box').update(response.substring(x, y));
                new Effect.Pulsate('shopping-cart', {
                    pulses: 2,
                    duration: 1.0
                });
                return false;
            },
            onFailure: function(request){
                alert('Problem adding to your shopping bag, please try again later');
            },
            parameters: allparams
        });
    }
    else {
        alert('The form you are attempting to submit called \'' + formName + '\' couldn\'t be found. Please make sure the submitDoc function has the correct id and name.');
    }
}
