var win = null;
function NewWindow(mypage, myname, w, h, scroll, pos)
{
   if(pos == "random")
   {
      LeftPosition = (screen.width) ? Math.floor(Math.random() * (screen.width - w)) : 100;
      TopPosition = (screen.height) ? Math.floor(Math.random() * ((screen.height - h) - 75)) : 100;
   }
   if(pos == "center")
   {
      LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100;
      TopPosition = (screen.height) ? (screen.height - h) / 2 : 100;
   }
   else if((pos != "center" && pos != "random") || pos == null)
   {
      LeftPosition = 0;
      TopPosition = 20
   }
   settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=' + scroll + '';
   win = window.open(mypage, myname, settings);
}
function AddNewsletter(ID)
{
   NewWindow('Newsletter.php?do=add&ID=' + ID, 'Newsletter', '550', '560', 'yes', 'center');
}

function VoteUser(ID,IDVote)
{
   NewWindow('Vote.php?User=' + ID + '&Rate='+ IDVote, 'Vote', '450', '400', 'no', 'center');
}

function ChatUsers(ID)
{
   NewWindow('chat.php?do=Chat&user=' + ID, ID, '450', '400', 'yes', 'center');
}

function Chating(ID,UserID)
{
   NewWindow('chat.php?ChatID=' + ID, UserID, '450', '400', 'yes', 'center');
}

function PrintItem(ID)
{
   NewWindow('popup.php?action=print&ID=' + ID, 'print', '500', '560', 'yes', 'center');
}

function AddComment(ID)
{
   NewWindow('comment.php?do=add&ID=' + ID, 'AddComment', '500', '560', 'yes', 'center');
}
function SaveItem(ID)
{
   NewWindow('popup.php?action=pdf&ID=' + ID, 'pdf', '500', '560', 'yes', 'center');
}

function SendToFriend(ID)
{
   NewWindow('popup.php?action=s2f&ID=' + ID, 'SendToFriend', '500', '560', 'no', 'center');
}

function AddToFevoret(ID, type)
{
   NewWindow('popup.php?action=fav&type=' + type + '&ID=' + ID, 'AddToFevoret', '500', '560', 'no', 'center');
}

function PrintPage(ID)
{
   NewWindow('popup.php?action=printpage&ID=' + ID, 'PrintPage', '500', '560', 'yes', 'center');
}
