$(document).ready(function(){
/*detect if they're using an iThing before we load jScroll*/
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
} else {
    $('.scroll-pane').jScrollPane();
}});

function contactMe(name, type){
    var emailMe;
    if (type == 'individual') {
        emailMe = "<n pynff=\"vaqRznvy\" uers=\"znvygb:"+name+"@erqrpubcbfg.pbz\" ery=\"absbyybj\">RZNVY "+name+"</n>";
    } else {
        emailMe = "<n uers=\"znvygb:"+name+"@erqrpubcbfg.pbz\" ery=\"absbyybj\">"+name+"@erqrpubcbfg.pbz</n>";
    }
document.write(emailMe.replace(/[a-zA-Z]/g, function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);}));
}



function runMovie(name,size) /*DEPRECATED*/ {
$('#movie').show('slow');
//jwplayer().load('http://www.redechopost.com/new/video/' + name + '.m4v').onComplete(function(){$('#movie').hide('slow')}).play();
jwplayer().load('http://www.redechopost.com/video/' + name + '.m4v');


//force width & height for HTML5. Otherwise video is hidden.
    var width;
    var height;
if (size == "widescreen") {
    width = 480;
    height = 294; //270 + 24px for controls
} else {
    width = 480;
    height = 344; //320 + 24px for controls
}
$('#snowman_container').css("width",width);
$('#snowman_container').css("height",height);
return false;
}

function loadMovie(name,ar,size,play,close) {
/*since the movie may have been hidden before, we need to show it*/
$('#movie').show();
/*set the variables for width & height based on the aspect ratio*/
    var width;
    var height;
    if (size == "large" && ar == "widescreen") {    /*Main Page Widescreen*/
    width = 640;
    height = 384; //360 + 24px for controls
} else if (size == "small" && ar == "widescreen") { /*Individual Pages Widescreen*/
    width = 480;
    height = 294; //270 + 24px for controls
} else {                                            /*Main Page or Individual Page Fullscreen*/
    width = 480;
    height = 384; //360 + 24px for controls
}

$('#movie').removeClass(); //remove any previous classes so they don't conflict'
$('#movie').addClass(ar); //add a class so CSS can position it correctly
/*Here's where the player gets inserted*/
jwplayer("container").setup({
file: "http://www.redechopost.com/video/" + name + ".mp4",
image: "http://www.redechopost.com/images/poster/" + name + ".jpg",
controlbar: "bottom",
backcolor: "000000",
frontcolor: "666666",
players: [
    {type: "flash", src: "jwplayer/player.swf"},
    {type: "html5"}
],
width:  width,
height: height,
events: {
    onReady:    function(){if (play == 'play') this.play(true);}, //autoplay when loaded
    onComplete: function(){if (close == 'close') closeMovie();} //autoclose when finished
}
});
return false;
}

function loadMovieM(name,ar,size,play,close) {
/*since the movie may have been hidden before, we need to show it*/
$('#movie').show();
/*set the variables for width & height based on the aspect ratio*/
    var width;
    var height;
    if (size == "large" && ar == "widescreen") {    /*Main Page Widescreen*/
    width = 640;
    height = 384; //360 + 24px for controls
} else if (size == "small" && ar == "widescreen") { /*Individual Pages Widescreen*/
    width = 480;
    height = 294; //270 + 24px for controls
} else {                                            /*Main Page or Individual Page Fullscreen*/
    width = 480;
    height = 384; //360 + 24px for controls
}

$('#movie').removeClass(); //remove any previous classes so they don't conflict'
$('#movie').addClass(ar); //add a class so CSS can position it correctly
/*Here's where the player gets inserted*/
jwplayer("container").setup({
levels: [
    {bitrate: 200, file: "http://www.redechopost.com/video/" + name + "_200.mp4", width: 240},
    {bitrate: 600, file: "http://www.redechopost.com/video/" + name + "_600.mp4", width: 480},
    {bitrate: 1000, file: "http://www.redechopost.com/video/" + name + ".mp4", width: width}
],
provider: "http",
"http.startparam":"starttime",
image: "http://www.redechopost.com/images/poster/" + name + ".jpg",
controlbar: "bottom",
backcolor: "000000",
frontcolor: "666666",
players: [
    {type: "flash", src: "jwplayer/player.swf"},
    {type: "html5"}
],
width:  width,
height: height,
events: {
    onReady:    function(){if (play == 'play') this.play(true);}, //autoplay when loaded
    onComplete: function(){if (close == 'close') closeMovie();} //autoclose when finished
}
});
return false;
}






function loadPortMovie(name,size,autoplay) {     /*This function leaves the movie open when finished*/

/*since the movie may have been hidden before, we need to show it
 *Shouldn't need this though, since these movies never get hidden
$('#movie').show();*/
/*set the variables for width & height based on the aspect ratio*/
    var width;
    var height;
if (size == "widescreen") {
    width = 480;
    height = 294; //270 + 24px for controls
} else {
    width = 480;
    height = 344; //320 + 24px for controls
}

/*Here's where the player gets inserted*/
jwplayer("container").setup({
file: "http://www.redechopost.com/video/" + name + ".m4v",
controlbar: "bottom",
image: "http://www.redechopost.com/video/" + name + ".jpg",
players: [
    {type: "flash", src: "jwplayer/player.swf"},
    {type: "html5"}
],
width:  width,
height: height,
events: {
    onReady: function(){this.play(autoplay);}, //autoplay when loaded
    onComplete: function(){jwplayer().stop();} //stop when finished
}
});
return false;
}

function closeMovie() {
    $('#movie').hide();
    jwplayer().stop();
/*$('#container').replaceWith('<div id="container">Loading  the player ...</div>');*/
}
