// Copyright (c) 1996-1997 Athenia Associates.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.


function pollAnswers(pollid) { 
	var yes = 0; 
	var no = 0;	
	for (var i=1;i<2;i++) { 
		if (eval('document.xlaapmform' + pollid + '_.answer' + i + '.value') !='') { 
				yes++; 
		} 
	} 
	if (yes == 1) { 
  		return true; 
 	} else { 
  		alert('Please answer all the questions before submitting');
  		return false; 
	} 
} 

// arg pollform ie: '274'
function pollformSubmit(pollid) { 
	var pollform = 'xlaapmform' + pollid + '_';
	if (pollAnswers(pollid)) { 
		xlaapmxe = window.open('','xlaapmxe','toolbar=0,location=0,status=1,menubar=1,scrollbars=1,resizable=1,width=415,height=300');
		eval('document.' + pollform + '.submit()'); 
		xlaapmxe.focus(); 
	} 
}

// extra web javascript
function Dancingopen(url) {window.open(url, 'extraplayer', 'height=1006,width=720,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}
function Pollopen(url) {window.open(url, 'extraplayer', 'height=300,width=400,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}
function Poll2open(url) {window.open(url, 'extraplayer', 'height=600,width=400,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}
function Popopen(url) {window.open(url, 'extraplayer', 'height=392,width=760,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=30,top=30');}
function Picopen(url) {window.open(url, 'xpic', 'height=533,width=332,resizable=yes,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=50,top=30');}
function Contestopen2(url) {window.open(url,'xcontest', 'height=700,width=700,resizable=yes,status=no,scrollbars=yes,location=no,menubar=no,toolbar=no,left=50,top=10');}
function Contestopen3(url) {window.open(url,'xcontest', 'height=630,width=610,resizable=yes,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=50,top=10');}
function Info2open(url) {window.open(url,'xinfo', 'height=612,width=900,resizable=no,status=no,scrollbars=yes,location=no,menubar=no,toolbar=no,left=100,top=100');}

function Thumbopen(url) {window.open(url, 'xvideo', 'height=488,width=710,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no');}
function Vidpopopen(url) {window.open(url, 'xvideo', 'height=255,width=320,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no');}
function Vidopen(url) {window.open(url, 'xvideo', 'height=550,width=720,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no');}
function Picopen(url) {window.open(url, 'xpic', 'height=500,width=380,resizable=yes,status=no,scrollbars=no,location=no,menubar=no,toolbar=no');}
function Sendopen(url) {window.open(url, 'xsend', 'height=340,width=500,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no');}
function Contestopen(url) {window.open(url,'xcontest', 'height=530,width=610,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no');}
function Infoopen(url) {window.open(url,'xinfo', 'height=500,width=550,resizable=yes,status=no,scrollbars=yes,location=no,menubar=no,toolbar=no');}
function Textopen(url) {window.open(url,'xinfo', 'resizable=yes,status=yes,scrollbars=yes,location=yes,menubar=yes,toolbar=yes');self.close();}
function Spot(url) {window.open(url,'xspot', 'height=600,width=900,resizable=no,status=no,scrollbars=no,location=no,menubar=no,toolbar=no,left=100,top=60');}


function validate(f)
{
	 var missing = "";
	 if ( document.f.firstname.value == "")
		 missing += "\n First Name";
	 if ( document.f.lastname.value == "")
		 missing += "\n Last Name";
	 if ( document.f.email.value == "" || f.email.value.indexOf("@") == -1)
		 missing += "\n Email Address";
	 if ( document.f.areacode.value == "")
		 missing += "\n Area Code";
	 if ( document.f.phone.value == "")
		 missing += "\n Phone";
	 if ( document.f.city.value == "")
		 missing += "\n City";
	 if ( document.f.zipcode.value == "")
		 missing += "\n Zip Code"
	 if ( document.f.state.value == "")
		 missing += "\n State";
     if ( document.f.message.value == "")
		 missing += "\n Reason";
     if ( document.f.custom2.value == "")
		 missing += "\n Method";		 		 
	 if ( document.f.pic.value == "")
		 missing += "\n Upload Picture";
	 if (missing != "") {
		 alert( "The following must be supplied: " + missing);
		 return false;
	}
	return true;
}


function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") +
        (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberMe (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    now = now.toGMTString();
    if (f.author != undefined)
       setCookie('mtcmtauth', f.author.value, now, '/', '', '');
    if (f.email != undefined)
       setCookie('mtcmtmail', f.email.value, now, '/', '', '');
    if (f.url != undefined)
       setCookie('mtcmthome', f.url.value, now, '/', '', '');
}

function forgetMe (f) {
    deleteCookie('mtcmtmail', '/', '');
    deleteCookie('mtcmthome', '/', '');
    deleteCookie('mtcmtauth', '/', '');
    f.email.value = '';
    f.author.value = '';
    f.url.value = '';
}

function hideDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'none';
}

function showDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'block';
}

var commenter_name;

function individualArchivesOnLoad(commenter_name) {


    hideDocumentElement('trackbacks-info');


 // comments are allowed but not required
    if (commenter_name) {
        hideDocumentElement('name-email');
    } else {
        showDocumentElement('name-email');
    }



    if (document.comments_form) {
        if (!commenter_name && (document.comments_form.email != undefined) &&
            (mtcmtmail = getCookie("mtcmtmail")))
            document.comments_form.email.value = mtcmtmail;
        if (!commenter_name && (document.comments_form.author != undefined) &&
            (mtcmtauth = getCookie("mtcmtauth")))
            document.comments_form.author.value = mtcmtauth;
        if (document.comments_form.url != undefined && 
            (mtcmthome = getCookie("mtcmthome")))
            document.comments_form.url.value = mtcmthome;
        if (document.comments_form["bakecookie"]) {
            if (mtcmtauth || mtcmthome) {
                document.comments_form.bakecookie.checked = true;
            } else {
                document.comments_form.bakecookie.checked = false;
            }
        }
    }
}

function writeTypeKeyGreeting(commenter_name, entry_id) {

    if (commenter_name) {
        document.write('<p>Thanks for signing in, ' + commenter_name +
          '. Now you can comment. '+
          '(<a href="http://extratv.warnerbros.com/cgi-bin/mt-comments.cgi?__mode=handle_sign_in&amp;static=1&amp;logout=1&entry_id=' + entry_id + '">sign out</a>)</p>');
    } else {

        document.write('<p>If you have a TypeKey identity, you can '+
          '<a href="https://www.typekey.com/t/typekey/login?&amp;lang=en_US&amp;t=Wj5Rj22cRZuhLMNcp7Sy&amp;v=1.1&amp;_return=http://extratv.warnerbros.com/cgi-bin/mt-comments.cgi%3f__mode=handle_sign_in%26key=TypeKey%26static=1%26entry_id=' + entry_id + '">sign in</a> '+
          'to use it here.</p>');

    }

}


if ('extratv.warnerbros.com' != 'extratv.warnerbros.com') {
    document.write('<script src="http://extratv.warnerbros.com/cgi-bin/mt-comments.cgi?__mode=cmtr_name_js"></script>');
} else {
    commenter_name = getCookie('commenter_name');
}


function addEvent(obj, evType, fn, useCapture){  if (obj.addEventListener){    obj.addEventListener(evType, fn, useCapture);    return true;  } else if (obj.attachEvent){    var r = obj.attachEvent("on"+evType, fn);    return r;  } else {    alert("Handler could not be attached");  } }
