// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function loadVideo(url, height, width, target) {
	if (height == null){height = '640';}
	if (width == null){width = '360';}
	if (target == null){target = 'flashcontent';}
    $j('#flashcontent').html('');
    var so = new SWFObject('/videoplayer/jw/player.swf','mpl',height,width,'9');
    so.addParam('allowscriptaccess','always');
    so.addParam('allowfullscreen','true');
    so.addParam('flashvars','&file='+url+'&type=rtmp&streamer=rtmp://24.165.45.209/oc16vod/&controlbar=over&skin=/dangdang.swf&dock=true&autostart=true');
    so.write(target);
}

function validateEmail(){
    var email = $("mailer_email").value;
    var valid = (email.indexOf(".") > 2) && (email.indexOf("@") > 0);
    if (!valid){
	    alert("Please enter a valid email address. ");
	}
    return valid;
}

function swapImages(prevId, nextId, maxId){
	if(maxId != 0){
		$j("#scroller"+prevId).fadeOut(2000)
		$j("#scroller"+nextId).fadeIn(2000)
		nextNextId = (nextId == maxId) ? 0 : nextId + 1
		setTimeout(function(){swapImages(nextId, nextNextId, maxId)}, 7000)
	}
}