function externallinks () {
   if ( document.getElementsByTagName ) {
      var links = document.getElementsByTagName ( 'a' );
      for (var i = 0; i < links.length; i++ ) {
         var link = links[i];
         if ( ( link.getAttribute ( 'href' ) ) && ( link.getAttribute ( 'rel' ) == 'external' ) ) {
            link.target = '_blank';
         }
      }
   }
}

function swap ( item, type ) {
   if ( document.images ) {
      var newimage = new Image();
      if ( type == 'active' ) {
         newimage.src = '../../public/images/' + item + '_active.jpg';
      }

      else {
         newimage.src = '../../public/images/' + item + '.jpg';
      }

      navitem = document.getElementById ( item );
      if (navitem) {
         navitem.src = newimage.src;
      }
   }
}

function vistoggle ( item ) {
   if ( document.getElementById ( item ) ) {
      if ( document.getElementById ( item ).style.display == 'none' ) {
         document.getElementById ( item ).style.display = 'block';
         if ( item == 'sidepanel' ) {
            swap ( 'expandbtn', 'active' );
            document.getElementById ( 'innercontentwrapper' ).className = 'sidepanelopen';
         }
      }

      else {
         document.getElementById ( item ).style.display = 'none';
         if ( item == 'sidepanel' ) {
            swap ( 'expandbtn', 'inactive' );
            document.getElementById ( 'innercontentwrapper' ).className = 'sidepanelclosed'; 
         }
      }
   }
}

function setwidth ( width ) {
   var newwidth = width + 350;
   var windowsize;
   if ( window.innerWidth ) { 
       windowsize = window.innerWidth;
   } else if ( document.body.clientWidth ) { 
       windowsize = document.body.clientWidth;
   } 
   
   if ( newwidth > windowsize ) {
      if ( document.getElementById ( 'mainwrapper' ) ) {
         document.getElementById ( 'mainwrapper' ).style.width = newwidth + 'px';
      }
   }
}


function toggleAddComments ( ) {							
	if ( typeof ( window['commentarray'] ) != 'undefined' ) {
		for ( var i = 0; i < commentarray.length; i++ ) {
			vistoggle('post' + commentarray[i]);
		}
	}
}

var action = 'hide';
function toggleComments() {
   if ( typeof ( window['commentarray'] ) != 'undefined' ) {
      if ( action == 'hide' ) {
         action = 'show';
         swap ( 'btn_viewcomments', 'inactive' );
         for ( var i = 0; i < commentarray.length; i++ ) {
            var comment = document.getElementById(commentarray[i]);
            if ( comment.style.display == 'block' ) {
               comment.style.display = 'none';
            }
         }
      } else {
         action = 'hide';
         swap ( 'btn_viewcomments', 'active' );
         for ( var i = 0; i < commentarray.length; i++ ) {
            var comment = document.getElementById(commentarray[i]);
            if ( comment.style.display == 'none' ) {
               comment.style.display = 'block';
            }
         }
      }
   }
}


// The following was copied on 05/30/2007 from:
//  http://www.sonypictures.com/groups/system/documents/system_file/global.js

//***************************************************
function popFull(url,name){
//***************************************************
var w = 480, h = 340;

if (document.all || document.layers) {
   w = screen.availWidth;
   h = screen.availHeight;
}else{
 w = screen.width;
 h = screen.height;
}

var url;
var popW;
var popH;

window.open(url,name,'width=' + w + ',height=' + h + ',top=0,left=0');
}
