var par = parent.top.document;
var cp = par.getElementById('dnn_ControlPanel');
var pic_div = '';

function resize_iframe(frm)
{
  try
  {
    innerDoc = (frm.contentDocument) ? frm.contentDocument : frm.contentWindow.document;
    objToResize = (frm.style) ? frm.style : frm;
    px = (frm.style) ? 'px' : '';
    objToResize.height = (innerDoc.body.scrollHeight + 10)+px;
  }
  catch(er)
  {
    // skip it!
  }
}

function show_pic(d,ty,w,h,t,u,uid)
{
  var preload = new Image(1,1);
  var pending = "";
  
  if(arguments.length>7 && arguments[7]=='N')
  {
    pending  = "<br>This image has not been verified and is not visible to the public"
    pending += "<br>You may upload over this image or <a href='javascript:void(0)' onclick='del_pic(" + d + ",\"" + u + "\"," + ty + ")'>delete it</a> if needed"
  }
  if(typeof(pic_div)=='string')
  {
    pic_div = par.createElement('div');
    pic_div.style.position='fixed';
    pic_div.style.top='20px';
    pic_div.style.left='20px';
    pic_div.style.border='5px solid silver';
    pic_div.style.background='silver';
    pic_div.style.color='black';
    pic_div.style.textAlign='center';
    pic_div.style.display='none';
    cp.appendChild(pic_div);
  }
  pic_div.innerHTML  = '';
  if(t != '') 
  {
    if(uid>0)
    {
      pic_div.innerHTML += '<b>Picture provided by <a href="http://bikernw.com/Default.aspx?tabid=59&g=profile&u=' + uid + '" style="color:red; font-size:larger; margin-bottom:5px;"><b>' + u + '</b><\/a> and taken on ' + t + '</b><br>';
    }
    else
    {
      pic_div.innerHTML += '<a href="http://bikernw.com/DinerTour/tabid/131/Default.aspx?diner=' + d + '" style="color:red; font-size:larger; margin-bottom:5px;">' + t + '<\/a>' + pending + '<br>';
    }
  }
  img = '/DinerTour/pics/' + d + '/' + u + '/' + ty + '.jpg';
  preload.src = img;
  pic_div.innerHTML += '<img src="' + img + '" alt="image" width="' + w + '" height="' + h + '" style="margin-bottom:5px;">';
  pic_div.innerHTML += '<br><a href="javascript:void(0)" onclick="this.parentNode.style.display=\'none\'" style="color:red; font-weight:bold">close this picture<\/a>';
  pic_div.innerHTML += '<a href="javascript:void(0)" onclick="this.parentNode.style.display=\'none\'" style="color:red; font-weight:bold; border:1px solid red; position:absolute; top:-1px; right:-1px;" title="close this picture">X<\/a>';
  pic_div.style.display = '';
}

function del_pic(tk,user,ty)
{
  var img = new Image(1,1);
  if(confirm('If you delete this image it can not be recovered.'))
  {
    img.src = "http://BikerNW.com/tools/diners/del_verify.asp?mode=udp&d=" + tk + "&u=" + user + "&y=" + ty;
    self.location = self.location;
  }
}

function show(id)
{
	document.getElementById(id).style.display='';
}

function hide(id)
{
	document.getElementById(id).style.display='none';
}

function LimitInput(field, countfield, maxlimit) 
{
	if (field.value.length > maxlimit)
	{
		alert("This input box is full!");
		field.value = field.value.substring(0, maxlimit);
	}
	document.getElementById(countfield).innerHTML = "(you have used " + field.value.length + " of " + maxlimit + " characters)";
}