/* @version $Id: default.js 2662 2009-09-17 23:14:24Z alex $ */
// JavaScript Document

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function getEmailURL() {
	if (self.emailURL)
		return emailURL;
	else	
		return document.location.href;
}

function getEmailTitle() {
	if (self.emailTitle)
		return emailTitle;
	else	
		return document.title;
}

function getEmailLink() {
	return "/email?mode=email" + "&url=" + escape(getEmailURL()) + "&title=" + escape(getEmailTitle());	
}

function SwitchMenu1(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("showdates").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function SwitchMenu2(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("togglebox").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}
	}
}

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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(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 amazonPopUp(URL,NAME) {
	amznwin=window.open(URL,NAME,'location=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes,width=380,height=450,screenX=10,screenY=10,top=10,left=10');
	amznwin.focus();
}

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;
}

// 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["George"].width;');writeln('window.innerHeight=document.images["George"].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="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}


/***********************************************
* 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);
ai3.each(function(i){var c=new Cookies();var p=c.get(ac3+ad3+i);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 */
  
var firstCall = true;

function changeFontsize(fSize, increment) {
  if (firstCall) {
    firstCall = false;
    if (increment != "")
      changeFontsize('12', '');
  }
  if (document.getElementsByTagName) {
    tags = new Array ( "p", "li", "h2", "h3", "h4", "h5", "h6", "div" );
    for (j=0; j<tags.length; j++) {
      var getElement = document.getElementsByTagName(tags[j]);
      var eachElement, currentFontSize, fontIncrease, newFontSize;
      for (i=0; i<getElement.length; i++) {
        eachElement = getElement[i];
        if (increment != "") {
          currentFontSize = parseInt(eachElement.style.fontSize);
          fontIncrease = parseInt(increment);
          newFontSize = currentFontSize + fontIncrease;
          }
        else if (fSize != "")
          newFontSize = parseInt(fSize);
        if (tags[j] == "li")
          eachElement.style.lineHeight = Math.round(newFontSize*1.2) + "px";
        else
          eachElement.style.lineHeight = Math.round(newFontSize*1.3) + "px";
        if (fSize != "") {
          switch(tags[j]) {
          case "h2":
            newFontSize += 12;
            var cookie = new PrnCookie('cbfont[h2]');
            cookie.set(newFontSize); 
            break;
          case "h3": 
            newFontSize += 2;
            var cookie = new PrnCookie('cbfont[h3]');
            cookie.set(newFontSize);
            break;
          case "h4": 
            newFontSize += 1;
            var cookie = new PrnCookie('cbfont[h4]');
            cookie.set(newFontSize);
            break;
          case "h5": 
            newFontSize += 1;
            var cookie = new PrnCookie('cbfont[h5]');
            cookie.set(newFontSize);
            break;
          case "h6": 
            var cookie = new PrnCookie('cbfont[h6]');
            cookie.set(newFontSize);
            newFontSize += 1;
          }
        }
        var cookie = new PrnCookie('cbfont[base]');
        cookie.set(newFontSize);
        eachElement.style.fontSize = newFontSize + "px";
      }
    }
  }
}

 /**
  * font control class 
  */
  
  function PrnFontControl(){
    this.tagGroup = new Array('p','li','h2','h3','h4','h5','h6','div');
    //settings per tag
    this.sizeStepsUp = new Array(1,1,1,1,1,1,1,1);
    this.sizeStepsDown = new Array(-1,-1,-1,-1,-1,-1,-1,-1);
    this.sizeBase = new Array(12,12,22,15,12,12,12,12);
	  this.base_font = 12;
  }
  
  /**
   * init font tool
   * @return void
   */
  
  PrnFontControl.prototype.init = function(){
	  for (var i=0; i<this.tagGroup.length; i++){
		  var cookie = new PrnCookie('cbfont['+this.tagGroup[i]+']');
		  if(cookie.get()){
			 this.applyFontSize(this.tagGroup[i],cookie.get());
		  }
	  }  
  }
  
  /**
   * increases font size
   * @return void
   */
     
  PrnFontControl.prototype.sizeUp = function(){
    for (var i=0; i<this.tagGroup.length; i++){
      this.applyFontIncrement(this.tagGroup[i],this.sizeStepsUp[i]);
    }
  }
  
 /**
  * decreases font size
  * @return void
  */
     
  PrnFontControl.prototype.sizeDown = function(){
    for (var i=0; i<this.tagGroup.length; i++){
      this.applyFontIncrement(this.tagGroup[i],this.sizeStepsDown[i]);
    }
  }
  
  /**
   * 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;
    }
    
    var elements = document.getElementsByTagName(tag);
	  if(!elements || elements.length < 1){
		  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;
	
    for (var i=0; i<elements.length; i++) {
      if (tag == 'li'){
          elements[i].style.lineHeight = Math.round(new_size*1.2) + 'px';
		   }
       else{
          elements[i].style.lineHeight = Math.round(new_size*1.3) + 'px';
		   }
		   elements[i].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.getElementsByTagName(tag);
	  if(!elements || elements.length < 1){
		  return;
	  }
    for (var i=0; i<elements.length; i++) {
         if (tag == 'li'){
          elements[i].style.lineHeight = Math.round(size*1.2) + 'px';
		 }
         else{
          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){
    for (var i=0; i<this.tagGroup.length; i++){
      if(tag == this.tagGroup[i]){
        return this.sizeBase[i];
      }
    }
    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());
    }
  }
/**
 * banner control
 */
 
 function toggleAds(el_id){
  if(!el_id){
    return;
  }
  try{
    if(site_visitor){
      if(site_visitor!='member'){
        if($(el_id)){
          $(el_id).show();
        }
      }
      else{
        //this fixes breadcrumb div position
        if($('breadcrumb-photo')){
          $('breadcrumb-photo').setStyle({'top': '260px'});
        }
      }
    }
  }
  catch(e){
  }
 }
 
 /**
  * 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-coast&pagepos="+ pagepos +"&prngenre=talk&prntype=web&prnpage="+ prnpage +"' type='text/javascript'%3E%3C/script%3E"));
      }
    }
    catch(e){
    }
  }
