
var orig_width = -1;
var orig_height = -1;


function imgscale(a,name) 
  {
  var imgs = document.images;

  var  timg=document.getElementById('the_picture');

//  alert ("image = " + timg.src );

  var w=timg.width, h=timg.height;
  timg.width = a*w;
  timg.height = a*h;
//
//  for (var i=0; i<imgs.length; i++) 
//    {
//    var w=imgs[i].width, h=imgs[i].height;
//alert ("looking at name " + imgs[i].id + " v " + name );
//imgs[i].src.indexOf (name) );
//    if ( imgs[i].src.indexOf (name) > 0 )
//      {
//      imgs[i].width = a*w;
//      imgs[i].height = a*h;
//      }
//    }
  }

function UserImageFit() 
  {
  fit_type=getCookie ( "UserImageFit" );

  //  alert ( 'a got here ' + fit_type );

  if ( fit_type == null )
    {

    //  alert ( 'b got here ' + fit_type );
    setCookie ( "UserImageFit" , "fit" , '' , '' , '' );
    ImageFit ();
    return;
    }
  else if ( fit_type < "fit" || fit_type > "fit" )
    {
    // Then it's full
    ImageFitFullSize(0);    
    }
  else 
    {
    // Then it's fit
    ImageFit(0);    
    }
  }

function ImageFit(SETCOOKIE) 
  {
  if ( SETCOOKIE == 1 )
    {
    setCookie ( "UserImageFit" , "fit" , '' , '' , '' );    
    }
  var  timg=document.getElementById('the_picture');

  var  window_width = f_clientWidth();
  var  window_height = f_clientHeight() - 196;

  //  alert ("image = " + timg.src + " " + window_width + " "+ window_height );

  var iw=timg.width, ih=timg.height;

  if ( orig_width < 0 && ih > 0 )
    { 
    orig_width = iw;
    orig_height = ih;
    }

  if ( ih > 0 && iw > 0 && window_width > 0 && window_height > 0 )
    {
    var ratiow = window_width / iw;
    var ratioh = window_height / ih;
    var ratio = Math.min ( ratiow , ratioh );

//    alert ( iw + " " + ih + " " + window_width + " "+ window_height + " " + ratiow + " " + window.pageYOffset);
//alert ( document.documentElement.scrollTop + " " +  document.body.scrollTop);
    ratio = Math.min ( ratio , 1 );



    timg.width = ratio * iw;
    timg.height = ratio * ih;
    }
  }

function ImageFitFullSize(SETCOOKIE) 
  {
  if ( SETCOOKIE == 1 )
    {
    setCookie ( "UserImageFit" , "full" , '' , '' , '' );    
    }
  var  timg=document.getElementById('the_picture');

  if ( orig_width > 0 )
    {
    timg.width= orig_width;
    timg.height = orig_height;
    }

  }

function setCookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


// this function gets the cookie, if it exists
function getCookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}


/***********************************************
* Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var defaultMenuWidth="150px" //set default menu width.

var linkset=new Array()
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT

//linkset[0]='<a href="http://www.yurpics.com/s/makefriend.php">Make a friend</a>';
//linkset[0]+='<a href="http://www.yurpics.com/s/makefriend.php">Make a foe</a>';
//linkset[0]+='<a href="http://www.yurpics.com/s/makefriend.php">Remove relationship</a>';

/*
linkset[1]='<a href="http://msnbc.com">MSNBC</a>'
linkset[1]+='<hr>' //Optional Separator
linkset[1]+='<a href="http://cnn.com">CNN</a>'
linkset[1]+='<a href="http://news.bbc.co.uk">BBC News</a>'
linkset[1]+='<a href="http://www.washingtonpost.com">Washington Post</a>'
*/

////No need to edit beyond here

var ie5=document.all && !window.opera
var ns6=document.getElementById

if (ie5||ns6)
  {
  document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')
  }
    
function iecompattest()
  {
  return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
  }


function createMenu(rel_type, c_yp_uid , comment_count , website , e, which, optWidth)
  {
  // rel_type = 0 for no current relationship, 1 = currently a friend, 2 = currently a foe
  var nlinkset=new Array();

  //  nlinkset[0]='<a href="http://www.yurpics.com/s/makefriend.php?friend=' + c_yp_uid + '" onclick="testit()">Make a friend</a>';
  if ( rel_type == 0 )
    {    
    nlinkset[0]='<a onclick="establishRelationShip( 0 , ' + c_yp_uid +',' + comment_count + ')" ><IMG SRC="http://www.' + website + '.com/images/friend.gif">&nbsp;Make a friend</a>';
    nlinkset[0]+='<a onclick="establishRelationShip( 1 , ' + c_yp_uid +',' + comment_count + ')"><IMG SRC="http://www.' + website + '.com/images/foe.gif">&nbsp;Make a foe</a>';
    nlinkset[0]+='<a onclick="establishRelationShip( 2 , ' + c_yp_uid +',' + comment_count + ')"><IMG SRC="http://www.' + website + '.com/images/neutral.gif">&nbsp;Remove relationship</a>';
    nlinkset[0]+='<hr>';
    nlinkset[0]+='<a onclick="establishRelationShip( 3 , ' + c_yp_uid +',' + comment_count + ')" ><IMG SRC="http://www.' + website + '.com/images/star_blue.gif">&nbsp;Best friend</a>';
    nlinkset[0]+='<a onclick="establishRelationShip( 4 , ' + c_yp_uid +',' + comment_count + ')" ><IMG SRC="http://www.' + website + '.com/images/star_red.gif">&nbsp;Worst enemy</a>';
    }
  else if ( rel_type == 1 )
    {    
    //    nlinkset[0]='<a onclick="establishRelationShip( 0 , ' + c_yp_uid +')">Make a friend</a>';
    nlinkset[0]='<a onclick="establishRelationShip( 1 , ' + c_yp_uid +',' + comment_count + ')"><IMG SRC="http://www.' + website + '.com/images/foe.gif">&nbsp;Make a foe</a>';
    nlinkset[0]+='<a onclick="establishRelationShip( 2 , ' + c_yp_uid +',' + comment_count + ')"><IMG SRC="http://www.' + website + '.com/images/neutral.gif">&nbsp;Remove relationship</a>';
    nlinkset[0]+='<hr>';
    nlinkset[0]+='<a onclick="establishRelationShip( 3 , ' + c_yp_uid +',' + comment_count + ')" ><IMG SRC="http://www.' + website + '.com/images/star_blue.gif">&nbsp;Best friend</a>';
    nlinkset[0]+='<a onclick="establishRelationShip( 4 , ' + c_yp_uid +',' + comment_count + ')" ><IMG SRC="http://www.' + website + '.com/images/star_red.gif">&nbsp;Worst enemy</a>';
    }
  else if ( rel_type == 2 )
    {    
    nlinkset[0]='<a onclick="establishRelationShip( 0 , ' + c_yp_uid +',' + comment_count + ')"><IMG SRC="http://www.' + website + '.com/images/friend.gif">&nbsp;Make a friend</a>';
    //    nlinkset[0]+='<a onclick="establishRelationShip( 1 , ' + c_yp_uid +')">Make a foe</a>';
    nlinkset[0]+='<a onclick="establishRelationShip( 2 , ' + c_yp_uid +',' + comment_count + ')"><IMG SRC="http://www.' + website + '.com/images/neutral.gif">&nbsp;Remove relationship</a>';
    nlinkset[0]+='<hr>';
    nlinkset[0]+='<a onclick="establishRelationShip( 3 , ' + c_yp_uid +',' + comment_count + ')" ><IMG SRC="http://www.' + website + '.com/images/star_blue.gif">&nbsp;Best friend</a>';
    nlinkset[0]+='<a onclick="establishRelationShip( 4 , ' + c_yp_uid +',' + comment_count + ')" ><IMG SRC="http://www.' + website + '.com/images/star_red.gif">&nbsp;Worst enemy</a>';
    }

  //  nlinkset[0]+='<a href="http://www.yurpics.com/s/makefriend.php?foe=' + c_yp_uid + '">Make a foe</a>';
  //  nlinkset[0]+='<a href="http://www.yurpics.com/s/makefriend.php?remove=' + c_yp_uid + '">Remove relationship</a>';
  showmenu ( e , nlinkset , optWidth );
  }

function showmenu(e, which, optWidth)
  {
  if (!document.all&&!document.getElementById)
    {
    return;
    }
  clearhidemenu();
  menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
  menuobj.innerHTML=which
  menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
  menuobj.contentwidth=menuobj.offsetWidth
  menuobj.contentheight=menuobj.offsetHeight
  eventX=ie5? event.clientX : e.clientX
  eventY=ie5? event.clientY : e.clientY
  //Find out how close the mouse is to the corner of the window
  var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
  var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
  //if the horizontal distance isn't enough to accomodate the width of the context menu
  if (rightedge<menuobj.contentwidth)
  //move the horizontal position of the menu to the left by it's width
  menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
  else
  //position the horizontal position of the menu where the mouse was clicked
  menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
  //same concept with the vertical position
  if (bottomedge<menuobj.contentheight)
  menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
  else
  menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
  menuobj.style.visibility="visible"
  return false
  }

function contains_ns6(a, b) 
  {
  //Determines if 1 element in contained in another- by Brainjar.com
  while (b.parentNode)
  if ((b = b.parentNode) == a)
  return true;
  return false;
  }

function hidemenu()
  {
  if (window.menuobj)
  menuobj.style.visibility="hidden"
  }

function dynamichide(e)
  {
  if (ie5&&!menuobj.contains(e.toElement))
  hidemenu()
  else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
  hidemenu()
  }

function delayhidemenu()
  {
  delayhide=setTimeout("hidemenu()",500)
  }

function clearhidemenu()
  {
  if (window.delayhide)
  clearTimeout(delayhide)
  }

if (ie5||ns6)
  {
  document.onclick=hidemenu
  }

function changePrivacyVisibility ( whichone )
  {
  if ( whichone == 0 )
    {
    changeObjectVisibility('ppfriends', false);
    changeObjectVisibility('ppfamily', false);
    //    changeObjectVisibility('ppfriends', 'inline');
    //    changeObjectVisibility('ppfamily', 'inline');
    changeObjectColor('aab', '#000000');
    changeObjectColor('aah', '#000000');
    }
  else
    {
    changeObjectVisibility('ppfriends', true);
    changeObjectVisibility('ppfamily', true);
    //    changeObjectVisibility('ppfriends', 'none');
    //    changeObjectVisibility('ppfamily', 'none');
    changeObjectColor('aab', '#bbbbbb');
    changeObjectColor('aah', '#bbbbbb');
    }
  //  var  object=document.getElementById('');
  //  changeObjectVisibility('pprivate', 'hidden');
  }

function changeObjectVisibility(objectId, newVisibility)
  {
  //var styleObject = getStyleObject(objectId, document);
  var styleObject =document.getElementById(objectId);
  if(styleObject) 
    {
    //styleObject.visibility = newVisibility;
    //    styleObject.style.display = newVisibility;
    styleObject.disabled = newVisibility;
    //    styleObject.style.display='none';
    return true;
    }
  else 
    {
    return false;
    }
  }

function changeLicenseVisibility ( whichone )
  {
  if ( whichone == 0 )
    {
    changeObjectVisibility('aaliccc1', true);
    changeObjectVisibility('aaliccc2', true);

    changeObjectVisibility('aaliccc3', true);
    changeObjectVisibility('aaliccc4', true);

    changeObjectVisibility('aaliccc5', true);
    changeObjectVisibility('aaliccc6', true);

    changeObjectColor('aliccc1', '#bbbbbb');
    changeObjectColor('aliccc2', '#bbbbbb');

    changeObjectColor('aliccc3', '#bbbbbb');
    changeObjectColor('aliccc4', '#bbbbbb');

    changeObjectColor('aliccc5', '#bbbbbb');
    changeObjectColor('aliccc6', '#bbbbbb');

    changeObjectColor('attribute', '#bbbbbb');
    changeObjectVisibility('attribute', true);

    changeObjectColor('tattribute', '#bbbbbb');
    changeObjectVisibility('tattribute', true);
    }
  else
    {
    changeObjectVisibility('aaliccc1', false);
    changeObjectVisibility('aaliccc2', false);

    changeObjectVisibility('aaliccc3', false);
    changeObjectVisibility('aaliccc4', false);

    changeObjectVisibility('aaliccc5', false);
    changeObjectVisibility('aaliccc6', false);

    changeObjectColor('aliccc1', '#000000');
    changeObjectColor('aliccc2', '#000000');

    changeObjectColor('aliccc3', '#000000');
    changeObjectColor('aliccc4', '#000000');

    changeObjectColor('aliccc5', '#000000');
    changeObjectColor('aliccc6', '#000000');

    changeObjectColor('attribute', '#000000');
    changeObjectVisibility('attribute', false );
    changeObjectColor('tattribute', '#000000');
    changeObjectVisibility('tattribute', false );
    }
  //  var  object=document.getElementById('');
  //  changeObjectVisibility('pprivate', 'hidden');
  }


function changeObjectColor(objectId, newVisibility)
  {
  //var styleObject = getStyleObject(objectId, document);
  var styleObject =document.getElementById(objectId);
  if(styleObject) 
    {
    //styleObject.visibility = newVisibility;
    styleObject.style.color = newVisibility;
    //    styleObject.style.display='none';
    return true;
    }
  else 
    {
    return false;
    }
  }

