function printEmailAddress(name, domain){if(domain == null) domain = 'polytalk.net';str=(name + '@' + domain);document.write('<a href="mailto:' + str + '">' + str + '</a>');}
function HideContent(d) {if(d.length < 1) { return; }document.getElementById(d).style.display = "none";}
function ShowContent(d) {if(d.length < 1) { return; }document.getElementById(d).style.display = "block";}
function ReverseContentDisplay(d) {if(d.length < 1) { return; }if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }	else { document.getElementById(d).style.display = "none"; }	}


function toggleAllCheckboxes(form){
  for (var i=0;i<form.elements.length;i++){
    var e = form.elements[i];
    // only if it's a checkbox.
    if(e.type == "checkbox"){
        e.checked = !e.checked;
    }
  }
}

function changeTextAreaSize(id, cols, rows){
    var txtId = document.getElementById(id);
    txtId.cols = cols;
    txtId.rows = rows;
}



function openABC(channel, video) {
    var popupWidth = 1000;
    var popupHeight = 675;
    var ifScrollBar = 0;
    if ((typeof(screen.availHeight) != "undefined" && screen.availHeight < popupHeight+49) || (typeof(screen.availWidth) != "undefined" && screen.availWidth < popupWidth+10)) {
        ifScrollBar = 1;
    }
    var popupParams = "height=" + popupHeight + ",width=" + popupWidth + ",toolbar=0,scrollbars=" + ifScrollBar + ",location=0,statusbar=0,menubar=0,resizable=0,top=0,left=0";
    var trackRedirect = "http://transfer.go.com/cgi/transfer.dll?name=REMOTEPLAYERJS_PARTNER_HULU&srvc=abc&goto=";
    trackRedirect = trackRedirect + "http://dynamic.abc.go.com/streaming/player&rEnable=0&pl=mv&mk=20171845&channel=" + channel + "&video=" + video + "&raff=&partner=hulu&hostname=" + document.location.hostname;

    //console.log(trackRedirect);

    var win = window.open(trackRedirect, 'abcfesplayer_window', popupParams);
    if (win==null || typeof(win)=="undefined") {
        alert("Oops - your browser may be blocking this pop-up. Please disable your pop-up blocker before continuing.");
    }


    //doRequest('/index2.php?m=media&a=get_abc_player_iframe&channel=' +channel+ '&video=' +video, 'current_video_description');


}



function isNumeric(s) {
	var validChars = "0123456789";
	var c;

	for (i = 0; i < s.length; i++) {
		c = s.charAt(i);
		if (validChars.indexOf(c) == -1) {
			return false;
		}
	}

	return true;
}



var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG(myImage)
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters))
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ?
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width
                  + "px; height:" + myImage.height
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML
    }
}



function urlencode(url) {
  var SAFECHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.!~*'()";
  var HEX = "0123456789ABCDEF";

  var encoded = "";
  for (var i=0; i<url.length; i++) {
    var ch = url.charAt(i);
    if (ch == " ") {
      encoded += "+";
    } else {
      if (SAFECHARS.indexOf(ch) != -1) {
	encoded += ch;
      } else {
	var charCode = ch.charCodeAt(0);
	if (charCode > 255) {
	  encoded += "+";
	} else {
	  encoded += "%";
	  encoded += HEX.charAt((charCode >> 4) & 0xF);
	  encoded += HEX.charAt(charCode & 0xF);
	}
      }
    }
  }

  return encoded;
}

function get(obj) {
    var getstr = '';

    for(var i = 0; i < obj.elements.length; i++){   // list form elements
        if (obj.elements[i].type == "checkbox"){    // loop through checkboxes
            if(obj.elements[i].checked==true){      // if checked
                getstr +=  '&actors[]=' + urlencode(obj.elements[i].value);
            }
        }
    }
    getstr += '&game_id=' + urlencode(document.getElementById('game_id[0]').value);
    getstr += '&caption=' + urlencode(document.getElementById('caption').value.substring(0,255));
    getstr += '&description=' + urlencode(document.getElementById('desc').value.substring(0,512));
    doRequest('/index2.php?m=media&a=edit_youtube' + getstr, 'video_edit_container');
}