function searchTarget(parent, url, newWindow, newTarget) {
    form = $(parent + ' form')[0];
    // Set the target for the form
    form.action = url;
    if (newWindow) {
        form.target = '_blank';
    } else {
        form.target = '';
    }

    $(parent + ' .searchCatBg').removeClass('searchCatBg');
    document.getElementById(newTarget).className = 'searchCatBg';

    return false;
}

function submitHeaderSearch(parent, event) {
    if (event == "onclick" || eventIsEnterKey(event)) {
        return srchSub2(parent);
    } else {
        return true;
    }
}

function srchSub2(parent) {
    var frm = $(parent + ' form')[0];
    var queryval = frm.query.value.trim();
    queryval = queryval.replace( /\+/, " ");
    var newurl = frm.action + queryval;
    if (frm.target == '_blank') {
        window.open(newurl, '_blank', '');
    } else {
        window.location = newurl;
    }
    return false;
}


<!-- Validator for TMZ Alerts -->

//"Accept terms" form submission- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var checkobj

function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}

function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please read/accept terms to submit form")
return false
}
}
}

//for tmz email alerts
function validate_policy_agreement() {
  if(document.forms.alertsform.alertspolicycheck.checked) {
    return true;
  } else {
    alert("Please confirm that you have read and agree to the TMZ.com Privacy Policy by checking the box before you click subscribe.");
    return false;
  }
}

function makehomepage(target) {
	// sniff user agent for browser
	var exclude=1;
	var agt=navigator.userAgent.toLowerCase();
	var win=0;var mac=0;var lin=1;
	if(agt.indexOf('win')!=-1){win=1;lin=0;}
	if(agt.indexOf('mac')!=-1){mac=1;lin=0;}
	var lnx=0;if(lin){lnx=1;}
	var ice=0;
	var ie=0;var ie4=0;var ie5=0;var ie6=0;var com=0;var dcm;
	var op5=0;var op6=0;var op7=0;
	var ns4=0;var ns6=0;var ns7=0;var mz7=0;var kde=0;var saf=0;
	if(typeof navigator.vendor!="undefined" && navigator.vendor=="KDE"){
		var thisKDE=agt;
		var splitKDE=thisKDE.split("konqueror/");
		var aKDE=splitKDE[1].split("; ");
		var KDEn=parseFloat(aKDE[0]);
		if(KDEn>=2.2){
			kde=1;
			ns6=1;
			exclude=0;
			}
		}
	else if(agt.indexOf('webtv')!=-1){exclude=1;}
	else if(typeof window.opera!="undefined"){
		exclude=0;
		if(/opera[\/ ][5]/.test(agt)){op5=1;}
		if(/opera[\/ ][6]/.test(agt)){op6=1;}
		if(/opera[\/ ][7-9]/.test(agt)){op7=1;}
		}
	else if(typeof document.all!="undefined"&&!kde){
		exclude=0;
		ie=1;
		if(typeof document.getElementById!="undefined"){
			ie5=1;
			if(agt.indexOf("msie 6")!=-1){
				ie6=1;
				dcm=document.compatMode;
				if(dcm!="BackCompat"){com=1;}
				}
			}
		else{ie4=1;}
		}
	else if(typeof document.getElementById!="undefined"){
		exclude=0;
		if(agt.indexOf("netscape/6")!=-1||agt.indexOf("netscape6")!=-1){ns6=1;}
		else if(agt.indexOf("netscape/7")!=-1||agt.indexOf("netscape7")!=-1){ns6=1;ns7=1;}
		else if(agt.indexOf("gecko")!=-1){ns6=1;mz7=1;}
		if(agt.indexOf("safari")!=-1 || (typeof document.childNodes!="undefined" && typeof document.all=="undefined" && typeof navigator.taintEnabled=="undefined")){mz7=0;ns6=1;saf=1;}
		}
	else if((agt.indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=4)){
		exclude=0;
		ns4=1;
		if(typeof navigator.mimeTypes['*']=="undefined"){
			exclude=1;
			ns4=0;
			}
		}
	if(agt.indexOf('escape')!=-1){exclude=1;ns4=0;}
	if(typeof navigator.__ice_version!="undefined"){exclude=1;ie4=0;}

	// if IE make this the homepage
	if(ie) {
		target.style.behavior='url(#default#homepage)';
		target.setHomePage('http://www.tmz.com/');
	}

	// if safari go to safari page
	if(saf) {
		window.location = "http://www.tmz.com/maketmzmyhomepage_safari"
	}

	// if firefox go to firefox page
	if(mz7) {
		window.location = "http://www.tmz.com/maketmzmyhomepage_firefox"
	}

	return false;
}

//BEGIN MOBILE ALERTS AJAX FORM
  var tmz_malerts_xreq = false;
  var TMZ_QWAPI_PROXY = "http://www.tmz.com/qwapi_proxy.php";

  function tmz_init_request() {
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
      tmz_malerts_xreq = new XMLHttpRequest();
      if (tmz_malerts_xreq.overrideMimeType) { tmz_malerts_xreq.overrideMimeType('text/html'); }
      } else if (window.ActiveXObject) { // IE
         try {tmz_malerts_xreq = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {
            try {tmz_malerts_xreq = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {}}}
    if (!tmz_malerts_xreq) {return false;}
    return true; }
  function tmz_make_request(url, params) {
    if(!tmz_init_request()) { tmz_malerts_failed("Error, please try again."); return false; }
    tmz_malerts_xreq.open("POST", url, true);
    tmz_malerts_xreq.onreadystatechange = tmz_ajax_statechange;
    tmz_malerts_xreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    tmz_malerts_xreq.setRequestHeader("Content-length", params.length);
    tmz_malerts_xreq.setRequestHeader("Connection", "close");
    tmz_malerts_xreq.send(params);
    return true; }
  function tmz_ajax_statechange() {
    if (tmz_malerts_xreq.readyState == 4) {
      if (tmz_malerts_xreq.status == 200) { tmz_malerts_success(); }
      else { tmz_malerts_failed("Submission Failed. Try again."); }}}
  function tmz_malerts_submit() {
    if((phoneNumber = tmz_malerts_number_validate())) {
      tmz_malerts_editable(false);
      tmz_malerts_status("Please wait...");
      tmz_make_request(TMZ_QWAPI_PROXY, "phoneNumber=" + phoneNumber); }
    else {
      tmz_malerts_failed("Invalid Number."); }}
  function tmz_malerts_number_validate() {
    re = /^[\s]*1?[\s\(]*(\d\d\d)[\s\.\-\)]*(\d\d\d)[\s\.\-]*(\d\d\d\d)[\s]*$/m;
    match = re.exec(document.getElementById("malerts-number").value);
    if (!match) { return false; }
    else { return match[1] + match[2] + match[3]; }}
  function tmz_malerts_success() { document.getElementById("malerts-wrap").innerHTML = "<p>You will now receive TMZ alerts on your phone!</p>"; }
  function tmz_malerts_failed(err) { tmz_malerts_editable(true); tmz_malerts_status(err); }
  function tmz_malerts_status(err) { document.getElementById("malerts-status").innerHTML = err; }
  function tmz_malerts_editable(b) {
    document.getElementById("malerts-number").disabled = !b;
    document.getElementById("malerts-button").disabled = !b; }
  function tmz_fix_height(id) { d = document.getElementById(id); d.style.height = d.offsetHeight+"px";}
//END MOBILE ALERTS AJAX FORM

//CRZ: makes the heights the same of all tags with id's in arr. Will not set tallest element's style.height.
  function tmz_equalize_heights (arr) {
    var largesse = 0, i=0;
    for (i=0; i< arr.length; i++) {
      if(document.getElementById(arr[i]).offsetHeight > largesse) {
        largesse = document.getElementById(arr[i]).offsetHeight;  }}
    for (i=0; i< arr.length; i++) {
      if(document.getElementById(arr[i]).offsetHeight != largesse) {
        document.getElementById(arr[i]).style.height = largesse.toString() + "px"; }}}

//CRZ: sets a negative margin for sidebar-bottom if needed. removes it if not needed.
//     should be run after onload and immediately after sidebar-bottom tag.
  function tmz_fix_bottomsidebar() {
    sbb = document.getElementById("sidebar-bottom");
    delta = document.getElementById("main").offsetHeight - document.getElementById("sidebar").offsetHeight;
    if(delta <= sbb.offsetHeight) { sbb.style.marginTop = "0px"; }
    else {
      sbb.style.marginTop = "-" + sbb.offsetHeight + "px"; }}


/* BCSinglePlayer.js
This script generates single title brightcove players for use on the TMZ main page and blog entry pages.  The player can be parameterized with a titleID to play.  Insert this call in the HTML where you want a player to appear:
 <script>insertBCSinglePlayer(000000000);</script>
where 0000000000 is the titleID of the title you want this player to display.
*/

// n stores the number of BC single title players that have been created so far, so we can generate
// unique ids for each one.
var n = 0;

function insertBCSinglePlayer(videoId) {

	var flashId = "f" + String(n);

	var str = '';
        str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="480" height="316" id="inline" align="middle">';
        str += '<param name="allowScriptAccess" value="always" />';
        str += '<param name="allowFullScreen" value="true" />';
        str += '<param name="movie" value="http://tmz.vo.llnwd.net/o28/player/inline.swf?mediaKey=' + videoId + '"/>';
        str += '<param name="wmode" value="opaque">';
        str += '<param name="quality" value="high" />';
        str += '<param name="bgcolor" value="#ffffff" />';
        str += '<embed src="http://tmz.vo.llnwd.net/o28/player/inline.swf?mediaKey=' + videoId + '" quality="high" bgcolor="#ffffff" width="480" height="316" name="inline" align="middle" allowScriptAccess="always" wmode="opaque" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>';
        str += '</object>';


	// write the flash obj to the page
	document.write(str);

	// increment the counter
	n++;

}

// n stores the number of BC single title players that have been created so far, so we can generate
// unique ids for each one.
var n = 0;
// tmztv_embed_video : {% asset version?src=/swf/tmztv_embed_video.swf %}
function insertTMZTVpromovideo(videoId,tmztv_embed_video) {

	var flashId = "f" + String(n);

	var str = '';
	str += '<center>';
	str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
	str += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
	str += 'width="300" height="254" id="' + flashId + '" align="middle">';
	str += '<param name="allowScriptAccess" value="always" />';
	str += '<param name="movie" value="'+tmztv_embed_video+'?videoId=' + videoId + '&flashId=' + flashId + '" />';
        str += '<param name="wmode" value="opaque">';
	str += '<param name="quality" value="high" />';
	str += '<param name="bgcolor" value="#ffffff" />';
	str += '<embed src="'+tmztv_embed_video+'?videoId=' + videoId + '&flashId=' + flashId + '" quality="high" bgcolor="#ffffff" ';
	str += 'width="300" height="254" name="' + flashId + '" ';
	str += 'align="middle" allowScriptAccess="always" wmode="opaque" ';
	str += 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	str += '</object>';
	str += '</center>';

	// write the flash obj to the page
	document.write(str);

	// increment the counter
	n++;
}

// n stores the number of BC single title players that have been created so far, so we can generate
// unique ids for each one.
var n = 0;
// tmztv2_embed_video : {% asset version?src=/swf/tmztv2_embed_video.swf %}
function insertTMZTVembeddedvideo(videoId,tmztv2_embed_video) {

	var flashId = "f" + String(n);

	var str = '';
	str += '<center>';
	str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
	str += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
	str += 'width="465" height="349" id="' + flashId + '" align="middle">';
	str += '<param name="allowScriptAccess" value="always" />';
	str += '<param name="movie" value="'+tmztv2_embed_video+'?videoId=' + videoId + '&flashId=' + flashId + '" />';
        str += '<param name="wmode" value="opaque">';
	str += '<param name="quality" value="high" />';
	str += '<param name="bgcolor" value="#ffffff" />';
	str += '<embed src="'+tmztv2_embed_video+'?videoId=' + videoId + '&flashId=' + flashId + '" quality="high" bgcolor="#ffffff" ';
	str += 'width="465" height="349" name="' + flashId + '" ';
	str += 'align="middle" allowScriptAccess="always" wmode="opaque" ';
	str += 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	str += '</object>';
	str += '</center>';

	// write the flash obj to the page
	document.write(str);

	// increment the counter
	n++;
}