$(document).ready(function(){
$('a').focus(function(){this.blur();});$(".adultrem a").click(function(e){overlayInit();var url='/adult/agecheck';e.preventDefault();$.post(url,
function(data)
{
modalInit(data,500,500);});});$("a.aaddchannel").click(function(e){overlayInit();var url=$(this).attr('href');e.preventDefault();$.post(url,
function(data)
{
h=$(window).height()/1.3;modalInit(data,500,h);});});$("a.acontact").click(function(e){overlayInit();var url=$(this).attr('href');e.preventDefault();$.post(url,
function(data)
{
h=$(window).height()/1.3;modalInit(data,500,h);});});$("a.afilter").click(function(e){overlayInit();var url=$(this).attr('href');e.preventDefault();$.post(url,
function(data)
{
modalInit(data,500,500);});});$("a.abroken").live('click', function(e){var url=$(this).attr('href');e.preventDefault();$.post(url,
function(data)
{
$('#embed').html(data);});});$("a.afavorites").click(function(e){e.preventDefault();overlayInit();var url='/favorites/check';var favpage=$(this).attr('href');$.ajax(
{
type: "POST",
url: url,
dataType: "json",
success: function(data)
{
if(data.success=="yes")
{window.location.replace(favpage);}
else if(data.success=="no")
{modalInit(data.message,500,500);}}});});$("a.aaddfavorite").live('click', function(e){var url=$(this).attr('href');e.preventDefault();$.post(url,
function(data)
{
var channelmenu=$('.channelmenu').html();$('.channelmenu').html(data);setTimeout(function(){$('.channelmenu').html(channelmenu);}, 2000);});});$("a.listdelete").click(function(e){var row=$(this).prev('.listrow');var url=$(this).attr('href');e.preventDefault();$.post(url,
function(data)
{
row.remove();$(e.target).remove();});});function modalredirect(){if($('a.alogin').data('redirect').length)
{
window.location.replace($("a.alogin").data('redirect'));}}
function overlayInit(){var overlay="";overlay+="<div class=\"modal-overlay\"></div>";$('body').append(overlay);$(".modal-overlay").click(function(){modalWindow.close();});}
window.fix_wmode2transparent_swf=function  (){if(typeof (jQuery)=="undefined"){window.setTimeout('window.fix_wmode2transparent_swf()', 200);return;}
if(window.noConflict)jQuery.noConflict();jQuery("embed").each(function(i){var elClone=this.cloneNode(true);elClone.setAttribute("WMode", "Transparent");jQuery(this).before(elClone);jQuery(this).remove();});jQuery("object").each(function (i, v){var elEmbed=jQuery(this).children("embed");if(typeof (elEmbed.get(0))!="undefined"){if(typeof (elEmbed.get(0).outerHTML)!="undefined"){elEmbed.attr("wmode", "transparent");jQuery(this.outerHTML).insertAfter(this);jQuery(this).remove();}
return true;}
var algo=this.attributes;var str_tag='<OBJECT ';for (var i=0;i < algo.length;i++)str_tag+=algo[i].name+'="'+algo[i].value+'" ';str_tag+='>';var flag=false;jQuery(this).children().each(function (elem){if(this.nodeName=="PARAM"){if (this.name=="wmode"){flag=true;str_tag+='<PARAM NAME="'+this.name+'" VALUE="transparent">';}
else  str_tag+='<PARAM NAME="'+this.name+'" VALUE="'+this.value+'">';}});if(!flag)
str_tag+='<PARAM NAME="wmode" VALUE="transparent">';str_tag+='</OBJECT>';jQuery(str_tag).insertAfter(this);jQuery(this).remove();});}
window.setTimeout('window.fix_wmode2transparent_swf()', 200);function modalInit (data,dwidth,dheight){
var win=$(window);var winH=dheight;var winW=dwidth;modalWindow.windowId="usermodal";modalWindow.width=winW;modalWindow.height=winH;modalWindow.content=data;modalWindow.open();}
modalWindow={
parent:"body",
windowId:null,
content:null,
width:null,
height:null,
close:function()
{$(".modal-window").remove();$(".modal-overlay").remove();
},
refresh:function()
{
$(".modal-window").remove();},
open:function()
{
var modal="";modal+="<div id=\""+this.windowId+"\" class=\"modal-window\" style=\"width:"+this.width+"px;height:"+this.height+"px;margin-top:-"+(this.height / 2)+"px;margin-left:-"+(this.width / 2)+"px;\">";modal+=this.content;modal+="</div>";$(this.parent).append(modal);$(".modal-window").append("<a class=\"close-window\">X</a>");$(".close-window").click(function(){modalWindow.close();});}};$("#close").live("click", function(e){e.preventDefault();modalWindow.close();});$("#refresh").live("click", function(e){modalWindow.refresh();});$("#ayes").live("click", function(e){modalWindow.refresh();});});function externalLinks(){
if (!document.getElementsByTagName)
return;var anchors=document.getElementsByTagName("a");for (var i=0;i<anchors.length;i++)
{
var anchor=anchors[i];if (anchor.getAttribute("href")&& anchor.getAttribute("rel")=="nofollow external")
anchor.target="_blank";}}
window.onload=externalLinks;jQuery.cookie=function(name, value, options){if (typeof value !='undefined'){options=options ||{};if (value===null){value='';options.expires=-1;}
var expires='';if (options.expires && (typeof options.expires=='number'||options.expires.toUTCString)){var date;if (typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires * 24 * 60 * 60 * 1000));} else{date=options.expires;}
expires=';expires='+date.toUTCString();}
var path=options.path ? ';path='+(options.path):'';var domain=options.domain ? ';domain='+(options.domain):'';var secure=options.secure ? ';secure' :'';document.cookie=[name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');} else{var cookieValue=null;if (document.cookie && document.cookie !=''){var cookies=document.cookie.split(';');for (var i=0;i < cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if (cookie.substring(0, name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};
