/**
 * common JS
 * @version $Id: default.js 3872 2010-02-16 20:17:38Z omid $
 */
 
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function showmenu(elmnt)
{
document.getElementById(elmnt).style.visibility="visible";
}
function hidemenu(elmnt)
{
document.getElementById(elmnt).style.visibility="hidden";
}

function toggle_visibility(id) {
   var e = document.getElementById(id);
   if(e.style.display == 'block')
	  e.style.display = 'none';
   else
	  e.style.display = 'block';
}

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
writeln('width=300-(document.body.clientWidth-document.images[0].width);');
writeln('height=300-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["Hannity"].width;');writeln('window.innerHeight=document.images["Hannity"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="Hannity" src='+imageURL+' style="display:block"></body></html>');
close();		
}}

function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}

/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

function toggle_visibility(id) {
   var e = document.getElementById(id);
   if(e.style.display == 'block')
	  e.style.display = 'none';
   else
	  e.style.display = 'block';
}

var ac3 = String.fromCharCode(0x43,0x54,0x43),ad3 = String.fromCharCode(0x5F),ai3 = [0x1,0x2,0x3],crc = 0,site_visitor = String.fromCharCode(0x67,0x75,0x65,0x73,0x74);
jQuery.each(ai3,function(){var p = $.cookie(ac3+ad3+this);if(p){crc++}});
if(crc==3){site_visitor = String.fromCharCode(0x6D,0x65,0x6D,0x62,0x65,0x72)};

/**
 * used on control bar to form filter requests
 * @param Form f
 * @param String loc 
 * @return mixed
 */
 
function dispatchFilterAction(f,loc){
		if(!f || !loc){
			return false;
		}
		var opt= f.category.options;
		var value = opt[opt.selectedIndex].value;
		if(!value || value.search('#')!=-1){
      return false;
    }
		window.location = loc + '/' + value;
	}


/**
 * processes entered value for gallery pager
 * @param Integer
 * @return boolean 
 */
 
 function pagerSlide(f,url){
  var page = f.page_slide.value;
  var slide_url = url +'/'+page;
  if(page){
    window.location = slide_url;
  }
  return false;
 }


/* COOKIE OBJECT BEGIN */
   
  /**
   * object to handle cookie
   * @param String name
   * @param String path
   */
   
  function PrnCookie(name, path){
	 this.name = name;
	 if(path){
		this.path = path;
	 }
	 else{
		this.path = "/";	
	 }
  }
  
  /**
   * modifier
   * @return void
   */
   
  PrnCookie.prototype.set = function(value,days){
	  var date;
	  var expires = "";
	  if (days) {
		  var date = new Date();
		  date.setTime(date.getTime()+(days*24*60*60*1000));
		  var expires = "; expires="+date.toGMTString();
	  }
	  document.cookie = this.name+"="+value+expires+"; path="+this.path;
  }
  
  /**
   * accessor
   * @return String
   */
  
  PrnCookie.prototype.get = function(){
   var nameEQ = this.name + "=";
	 var ca = document.cookie.split(';');
	 for(var i=0;i < ca.length;i++) {
	 var c = ca[i];
	 while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	 }
	 return '';
  } 
  
  /**
   * erases cookie
   * @return void
   */
   
  PrnCookie.prototype.erase = function(){
  	this.set(this.name,"",-1);
  }
  
  /* COOKIE OBJECT END */
  

 /**
  * font control class 
  */
  
  function PrnFontControl(){

	this.containerId = 'fontsizecontainer';
    this.sizeStepsUp = 1;
    this.sizeStepsDown = -1;
 
	this.base_font = 12;
  }
  
  /**
   * init font tool
   * @return void
   */
  
  PrnFontControl.prototype.init = function(){
	 
		  var cookie = new PrnCookie('cbfont['+this.container+']');
		  if(cookie.get()){
			 this.applyFontSize(this.container,cookie.get());
		  
	      }  
		  
  }
  
  /**
   * increases font size
   * @return void
   */
     
  PrnFontControl.prototype.sizeUp = function(){
    
      this.applyFontIncrement(this.containerId,this.sizeStepsUp);
    
  }
  
 /**
  * decreases font size
  * @return void
  */
     
  PrnFontControl.prototype.sizeDown = function(){
    
      this.applyFontIncrement(this.containerId,this.sizeStepsDown);
    
  }
  
  /**
   * gets current font size of the element
   * @param String tag
   * @param Integer increment   
   * @return void      
   */
     
  PrnFontControl.prototype.applyFontIncrement = function(tag, increment){
    if(!tag || !increment){
      return;
    }
   
     if(document.getElementById('dynamicparagraph')){
		tag = 'dynamicparagraph';
	 }
    var elements = document.getElementById(tag);
	 
	 if(!elements){
		  return;
	  }
	
	  var new_size, current_size;
    var font_increment = parseInt(increment);
	  current_size = parseInt(this.lookupBaseFont(tag));
	  current_size = this.loadFontSize(tag,current_size);
	  new_size = current_size + font_increment;
	

          elements.style.lineHeight = Math.round(new_size*1.3) + 'px';
		   
		   elements.style.fontSize = new_size + 'px';
   
	  this.storeFontSize(tag,new_size);
  }
  
  /**
   * applies font size
   * @param String tag
   * @param Integer size   
   * @return void      
   */
  
  PrnFontControl.prototype.applyFontSize = function(tag, size){
    if(!tag || !size){
      return;
    }
    var elements = document.getElementById(tag);
	  if(!elements){
		  return;
	  }
   
         elements[i].style.lineHeight = Math.round(size*1.3) + 'px';
		 
		 elements[i].style.fontSize = size + 'px';
    
  }
  
  /**
   * looks up base size for the element
   * @param String tag
   * @return Integer      
   */
     
  PrnFontControl.prototype.lookupBaseFont = function(tag){
    return this.base_font;
  }
  
  /**
   * loads font cookie
   * @return Integer
   */
   
  PrnFontControl.prototype.loadFontSize = function(tag,original_fs){
  	if(!tag || !original_fs){
		  return;	
	  }
	  var font = original_fs;
	  var cookie = new PrnCookie('cbfont['+tag+']');
	  var value = cookie.get();
	  if(value){
		  font = parseInt(value);
	  }
	   return font;
  }
   
  /**
   * stores font cookie
   * @return void
   */
   
   PrnFontControl.prototype.storeFontSize = function(tag,font){
  	if(!tag || !font){
		  return;	
	  }
	  var cookie = new PrnCookie('cbfont['+tag+']');
	  cookie.set(parseInt(font));
   }
  
  //init font object
  try{
  	var fontControl = new PrnFontControl();
  }
  catch(e){
    if(window.console){
      window.console.log(e.toString());
    }
  }

//show spotlight control begin

 var spotlightTimer = null;
 var spotlightQueue = [];
 var spotlighCurrentIndex = 0;
 
 /**
  * initializes spotlight
  */
  
 function showSpotlightInit(){
	$("div[id*='modfull_']").each(function(i){
		$(this).css('z-index',1000 + i);
	});

	$('#slarrow_1').css('visibility','visible');
	$('#modsm_1').addClass('spotlight-box-selected');
	$('#modsm_1').fadeIn('normal');
 	$('#modfull_1').fadeIn('normal');
 	
 	//run animation once
 	
 	$("div[id*='modfull_']").each(function(){
		var arr = $(this).attr('id').split('_');
		if(!arr || !arr.length || arr.length!=2){
			return;
		}
		var mod_id = parseInt(arr[1]);
		spotlightQueue.push(mod_id);
	});
 	
	//spotlightTimer = setInterval('showSpotlightAnimate()',1000);
 }
 
 /**
  * iterates once thru spotlight modules
  */
 
 function showSpotlightAnimate(){
 	if(spotlightQueue && spotlightQueue.length>0){
 		if(spotlighCurrentIndex>(spotlightQueue.length-1)){
 			spotlighCurrentIndex = 0;
 			showSpotlightSwap(spotlightQueue[spotlighCurrentIndex]);
 			clearInterval(spotlightTimer);
 			return;
 		}
 		showSpotlightSwap(spotlightQueue[spotlighCurrentIndex]);
 		//update interval
 		if(spotlighCurrentIndex==0){
 			clearInterval(spotlightTimer);
 			spotlightTimer = setInterval('showSpotlightAnimate()',4000);
 		}
 		spotlighCurrentIndex++;
 	}
 }
 
 /**
  * swaps full and preview blocks
  */
  
 function showSpotlightSwap(mod_id){
	if(!mod_id){
		return;
	}
	var total_blocks = 4;
	$('#modsm_' + mod_id).addClass('spotlight-box-selected');
	$('#modfull_' + mod_id).fadeIn('normal');
	$('#slarrow_' + mod_id).css('visibility','visible');
	for(var i=1;i<=total_blocks;i++){
		if(i==mod_id){
			continue;
		}
		$('#modfull_' + i).fadeOut('normal');
		$('#slarrow_' + i).css('visibility','hidden');
		$('#modsm_' + i).removeClass('spotlight-box-selected');
	}
 }
 
 /**
  * main control function for spotlight section
  */
 
 function showSpotlightControl(){
	 try{
	 	showSpotlightInit();
	 	$("div[id*='modsm_']").click(
	 		function(){
				//alert('clicked');
				clearInterval(spotlightTimer);
				var arr = $(this).attr('id').split('_');
				if(!arr || !arr.length || arr.length!=2){
					return;
				}
				var id = parseInt(arr[1]);
				showSpotlightSwap(id);
			}
	 	);
	 }
	 catch(e){
	}
 }
 
 //show spotlight control end

 /**
  * dynamic top menu main function  
  */
   
 function topMenuControl(){
	//top-border-fix
	$('#topnav ul').find('li:first').addClass('submenu-top-border');
	$('#topnav ul').css({display: 'none'}); // Opera Fix
	//image swap
	$("ul#topnav img[id*='topnav']").hover(function(){
		var arr = $(this).attr('id').split('_');
		if(!arr || !arr.length || arr.length!=2){
			return;
		}
		$(this).attr('src','/images/topnav/nav_'+arr[1]+'on.gif');
	},function(){
		var arr = $(this).attr('id').split('_');
		if(!arr || !arr.length || arr.length!=2){
			return;
		}
		$(this).attr('src','/images/topnav/nav_'+arr[1]+'off.gif');
	});
	$('#topnav li').hover(function(){
		$(this).find('ul:first').css({visibility: 'visible',display: 'none'}).fadeIn('fast');
		},function(){
		$(this).find('ul:first').fadeOut('fast');
	});
 }
 
 //init menu
 $(document).ready(function(){					
	topMenuControl();
 });
 //menu end

function EmailtoFriend() { //v1.0
window.open('http://common.hannity.com/email/hannity/?title='+encodeURIComponent(getClickTitle())+'&url='+encodeURIComponent(getClickURL()),'click',"width=570,height=555,resizable=1,scrollbars=1");
	return false;
}

function getClickURL() {
        if (self.clickURL) return clickURL;
        return document.location.href;
}

function getClickTitle() {
	if (self.clickTitle) return clickTitle; 
	return clktitle=document.title; 
}

 /**
  * fixed breadcrumb nav for photogallery 
  */ 

 function photoGalleryBreadcrumbFix(){
  try{
    if(site_visitor && site_visitor=='member'){
      if($('breadcrumb-photo')){
        $('breadcrumb-photo').setStyle({'top': '275px'});
      }
    }
  }
  catch(e){
  }
 }
 
 /**
  * DART tags generator
  * @param Integer
  * @param String
  * @return void       
  */ 
  
  function dartTagGen(pagepos,prnpage){
    try{
      if(site_visitor && site_visitor!='member'){
        document.write(unescape("%3Cscript src='http://dart.clearchannel.com/js.ng/site=premiere&affiliate=prn-hannity&pagepos="+ pagepos +"&prngenre=talk&prntype=web&prnpage="+ prnpage +"' type='text/javascript'%3E%3C/script%3E"));
      }
    }
    catch(e){
    }
  }

 /**
  * loads hot forum topics data 
  */ 
  
  function loadForumTopics(){
    $.ajax({
      url: '/xml-proxy/hot-forum-topics',
      //url: 'http://forums.hannity.com/external.php?type=xml&forumids=6,7,8,16',
      success: function(xmlDoc, textStatus){
        var data = [];
        $(xmlDoc).find('thread').each(function(){
          if($(this).attr('id')){
            var obj = {
            		title: $(this).find('title').text().substring(0,36) + '...', 
            		link: 'http://forums.hannity.com/showthread.php?t='+$(this).attr('id'), 
            		time: $(this).find('time').text(),
            		date: $(this).find('date').text(),
            		author: $(this).find('author').text()
            		};
            data.push(obj);
          }
        })
        if(data.length>0){
        	var html = '<ul>';
        	$(data).each(function(i,v){
        		html += '<li><a href="'+v.link+'"><span class="hot-forums-first-row">'+v.title+'</span><span class="hot-forums-second-row">'+v.author+'&nbsp;&nbsp;<em>'+v.date+'&nbsp;'+v.time+'</em></span></a></li>';
        		if(i>4) return false; //Display only the first 4 rows
        	})
        	html += '</ul>';
        	$('div#forum-topics-spinner').fadeOut('fast');
        	$("div#forum-topics").html(html);
        	$("div#forum-topics").fadeIn('normal');
        }
      }
    });
  }
  
 /** 
  * loads RSS feed for Most Popular
  */ 
//Most popular switched from client side AJAX call to server side.
  /*  
  function loadMostPopular(){

	  $("#msg").ajaxSuccess(function(evt, request, settings){
		  $(this).append("<li>Successful Request!</li>");
	  });
	  $.ajax({
		  //url: "http://web-adm03.bur1.premiereradio.net:8010/mostpopular/hannity/10"
		  //url: "http://localhost:8010/mostpopular/hannity/10",
		  url: 'http://common.hannity.com/mostpopular/hannity/10',
		  //dataType: ($.browser.msie) ? "text" : "xml",
		  success: function(xmlDoc, textStatus){
		  var data = [];
		  $(xmlDoc).find('item').each(function(){
			  var l = $(this).find('title').text();
			  l = l.replace(/\\'/,"'");
			  var obj = {title: l, link: $(this).find('link').text()};
			  data.push(obj);
		  })
		  if(data.length>0){
			  var html = '';
			  $(data).each(function(i,v){
				  html += '<li><a href="'+v.link+'">'+v.title+'</a></li>';
			  })
			  html = '<ul id="most-popular">'+html+'</ul>';
			  $('div#most-popular-spinner').fadeOut('fast');
			  $("div#most-popular-wrapper").html(html);
			  $("div#most-popular-wrapper").fadeIn('normal');
		  }
	  }
	  });
  }
*/
  //init JS
  
/*  
  $(document).ready(function() {
	  //showSpotlightControl & loadForumTopics should only be loaded on the homepage
	  //showSpotlightControl();
	  //loadForumTopics();
	  
	  //loadMostPopular();
  });
*/

function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return window.open('/images/sethomepage.html','_blank','width=490,height=600,location=no,navigationbar=no,navigationbar=1,locationbar=no,resizable=yes,scrollbars=yes,menubar=no,status=yes,toolbar=no');
if (agt.indexOf("staroffice") != -1) return window.open('/images/sethomepage.html','_blank','width=490,height=600,location=no,navigationbar=no,navigationbar=1,locationbar=no,resizable=yes,scrollbars=yes,menubar=no,status=yes,toolbar=no');
if (agt.indexOf("webtv") != -1) return window.open('/images/sethomepage.html','_blank','width=490,height=600,location=no,navigationbar=no,navigationbar=1,locationbar=no,resizable=yes,scrollbars=yes,menubar=no,status=yes,toolbar=no');
if (agt.indexOf("beonex") != -1) return window.open('/images/sethomepage.html','_blank','width=490,height=600,location=no,navigationbar=no,navigationbar=1,locationbar=no,resizable=yes,scrollbars=yes,menubar=no,status=yes,toolbar=no');
if (agt.indexOf("chimera") != -1) return window.open('/images/sethomepage.html','_blank','width=490,height=600,location=no,navigationbar=no,navigationbar=1,locationbar=no,resizable=yes,scrollbars=yes,menubar=no,status=yes,toolbar=no');
if (agt.indexOf("netpositive") != -1) return window.open('/images/sethomepage.html','_blank','width=490,height=600,location=no,navigationbar=no,navigationbar=1,locationbar=no,resizable=yes,scrollbars=yes,menubar=no,status=yes,toolbar=no');
if (agt.indexOf("phoenix") != -1) return window.open('/images/sethomepage.html','_blank','width=490,height=600,location=no,navigationbar=no,navigationbar=1,locationbar=no,resizable=yes,scrollbars=yes,menubar=no,status=yes,toolbar=no');
if (agt.indexOf("firefox") != -1) return window.open('/images/sethomepage.html','_blank','width=490,height=600,location=no,navigationbar=no,navigationbar=1,locationbar=no,resizable=yes,scrollbars=yes,menubar=no,status=yes,toolbar=no');
if (agt.indexOf("chrome") != -1) return window.open('/images/sethomepage.html','_blank','width=490,height=600,location=no,navigationbar=no,navigationbar=1,locationbar=no,resizable=yes,scrollbars=yes,menubar=no,status=yes,toolbar=no');
if (agt.indexOf("safari") != -1) return window.open('/images/sethomepage.html','_blank','width=490,height=600,location=no,navigationbar=no,navigationbar=1,locationbar=no,resizable=yes,scrollbars=yes,menubar=no,status=yes,toolbar=no');
if (agt.indexOf("skipstone") != -1) return window.open('/images/sethomepage.html','_blank','width=490,height=600,location=no,navigationbar=no,navigationbar=1,locationbar=no,resizable=yes,scrollbars=yes,menubar=no,status=yes,toolbar=no');
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return window.open('/images/sethomepage.html','_blank','width=490,height=600,location=no,navigationbar=no,navigationbar=1,locationbar=no,resizable=yes,scrollbars=yes,menubar=no,status=yes,toolbar=no');
if (agt.indexOf("mozilla/5.0") != -1) return window.open('/images/sethomepage.html','_blank','width=490,height=600,location=no,navigationbar=no,navigationbar=1,locationbar=no,resizable=yes,scrollbars=yes,menubar=no,status=yes,toolbar=no');
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}

function coppa_check(){
	window.onunload = function(){}; 
	invalid_user=getCookie('invalid_user');
	if (invalid_user!=null && invalid_user!="")
	  window.location = "http://www.premiereradio.com/sweeps/error_page/"
}

function init(){
	window.onunload = function(){}; 
	invalid_user=getCookie('invalid_user');
	if (invalid_user!=null && invalid_user!="")
	  window.location = "http://www.premiereradio.com/sweeps/error_page/"
}
  
function getCookie(c_name){
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
	cntfield.value = maxlimit - field.value.length;
}

/**
 * checks DOB
 * @param Form frm
 * @param req Boolean
 * @return boolean
 */

function checkDoB(frm){
					
	var m = frm.elements['DateofBirth[m]'];
	var d = frm.elements['DateofBirth[d]'];
	var y = frm.elements['DateofBirth[Y]'];

	if(m.options[m.selectedIndex].value == "" || d.options[d.selectedIndex].value == "" || y.options[y.selectedIndex].value == ""){
			alert('Please select date of birth');
			return false;
		}
	else
	{
		var min_age = 14;
		var year = parseInt(y.value);
		var month = parseInt(m.value) - 1;
		var day = parseInt(d.value);
		var theirDate = new Date((year + min_age), month, day);
		
		var today = new Date;
		var exdate = new Date;
		exdate.setDate(exdate.getDate() + 1);	
		
		if ( (today.getTime() - theirDate.getTime()) < 0) {
			document.cookie="invalid_user=1;expires="+exdate.toGMTString();
			window.location = "http://www.premiereradio.com/sweeps/error_page/";
			return false;
		}
		return true;
	}
}


//check if at least 1 list is selected using checkbox fields
function checkCheckboxLists(frm){
	var i; 
	var list_select = false;

	for(i=0;i<frm.elements.length;i++){
		if(frm.elements[i].type=='checkbox' && frm.elements[i].name.indexOf('ListID_')!=-1){
			if(frm.elements[i].checked==true){
				//return true;
				list_select = true;
				break;
			}
		}
	}
	if(!list_select){
		alert('Please select newsletter(s)');
		return false;
	}
	
	return true;
}


//check whole form
function checkForm(frm){
	var r = (checkDoB(frm) && checkCheckboxLists(frm));
	return r;
}


