/*************************************/
//        accountLogout()
/*************************************/
function accountLogout(dir)
{ var resure = confirm("Are you sure you want to logout Download Account?      ");
  if(resure)
    window.location = '/logout/?dir=' + dir;
}

/***************************************/
//       openImageViewer()
/***************************************/
function openImageViewer(addr, title)
{ if(popupwin)
    popupwin.close();

  var winwidth  = 430;
  var winheight = 360;

  var ststus   = 'no';
  var scrollbar = 'no';
  var tool_bar  = 'no';

  var leftpos = 0;
  var toppos  = 0;

	if(!leftpos)
	{ var scrwidth  = screen.availWidth
    leftpos= (scrwidth/2) -(winwidth/2);
  }
  if(!toppos)
  { var scrheight = screen.availHeight
    toppos = (scrheight/2)-(winheight/2);
  }

  var url = '/viewcart/imageviewer.php?addr=' + addr
                                                + '&title=' + title;

  popupwin = window.open(
  url
  , 'popupwin'
  , config='width='+winwidth
  +',height='+winheight
  +',left='+leftpos
  +',top='+ toppos
  +',modal=yes' 
  +',toolbar='+tool_bar+', menubar=no, '
  +',scrollbars='+scrollbar+', resizable=yes, '
  +',location=no, directories=no, status=' + ststus );
  
  popupwin.focus();
}

/***************************************/
//       openPopupWin()
/***************************************/
function openPopupWin(addr, winwidth, winheight, scrollbar)
{ if(popupwin)
    popupwin.close();

  var ststus   = 'no';
  var tool_bar  = 'no';
  if(!scrollbar)
    var scrollbar = 'no';

  var leftpos = 0;
  var toppos  = 0;

	if(!leftpos)
	{ var scrwidth  = screen.availWidth
    leftpos= (scrwidth/2) -(winwidth/2);
  }
  if(!toppos)
  { var scrheight = screen.availHeight
    toppos = (scrheight/2)-(winheight/2);
  }

  popupwin = window.open(
  addr
  , 'popupwin'
  , 'width='+winwidth
  +',height='+winheight
  +',left='+leftpos
  +',top='+ toppos
  +',toolbar='+tool_bar+', menubar=no, '
  +',scrollbars='+scrollbar+', resizable=yes, '
  +',location=no, directories=no, status=' + ststus );

  popupwin.focus();
}

/***************************************/
//       palyPreviewMovie()
/***************************************/
function palyPreviewMovie(movie_id, count)
{ if(popupwin)
    popupwin.close();

  var winwidth  = 510;
  var winheight = 490;
  //var winwidth  = 500;
  //var winheight = 480;

  var ststus   = 'no';
  var scrollbar = 'no';
  var tool_bar  = 'no';

  var leftpos = 0;
  var toppos  = 0;

	if(!leftpos)
	{ var scrwidth  = screen.availWidth
    leftpos= (scrwidth/2) -(winwidth/2);
  }
  if(!toppos)
  { var scrheight = screen.availHeight
    toppos = (scrheight/2)-(winheight/2);
  }

  var addr = '/movies/play/?movie_id=' + movie_id
                        + '&count='    + count;

  popupwin = window.open(
  addr
  , 'popupwin'
  , config='width='+winwidth
  +',height='+winheight
  +',left='+leftpos
  +',top='+ toppos
  +',modal=yes' 
  +',toolbar='+tool_bar+', menubar=no, '
  +',scrollbars='+scrollbar+', resizable=no, '
  +',location=no, directories=no, status=' + ststus );
  
  popupwin.focus();
}

/***************************************/
//       palyFullScreenMovie()
/***************************************/
function palyFullScreenMovie(num)
{ if(popupwin)
    popupwin.close();

  var winwidth  = 662;
  var winheight = 630;

  var ststus   = 'no';
  var scrollbar = 'no';
  var tool_bar  = 'no';

  var leftpos = 0;
  var toppos  = 0;

	if(!leftpos)
	{ var scrwidth  = screen.availWidth
    leftpos= (scrwidth/2) -(winwidth/2);
  }
  if(!toppos)
  { var scrheight = screen.availHeight
    toppos = (scrheight/2)-(winheight/2)-20;
  }

  var addr = '/previews/play_fullscreen_movie.php?num=' + num;

  popupwin = window.open(
  addr
  , 'popupwin'
  , config='width='+winwidth
  +',height='+winheight
  +',left='+leftpos
  +',top='+ toppos
  +',modal=yes' 
  +',toolbar='+tool_bar+', menubar=no, '
  +',scrollbars='+scrollbar+', resizable=yes, '
  +',location=no, directories=no, status=' + ststus );
  
  popupwin.focus();
}

/***************************************/
//       openPopupPage()
/***************************************/
function openPopupPage(dir)
{ var winwidth  = 798
  var winheight = 379;
  
  openPopupWin('/'+dir+'/popup/', winwidth, winheight, 'yes');
}

/***************************************/
//       openPopupPageEvents()
/***************************************/
function openPopupPageEvents(dir)
{ var winwidth  = 798
  var winheight = 379;
  openPopupWin('/events/'+dir+'/regulations/', winwidth, winheight, 'yes');
}

/***************************************/
//       validateEmail()
/***************************************/
function validateEmail(emailInput, inputTitle)
{	var theStr = new String(emailInput.value);
  var index = theStr.indexOf("@");
  var pindex = theStr.indexOf(".",index);

  if(inputTitle.length==0) inputTitle = "Email Address";

  if(theStr == "")
  { alert("Please enter [" + inputTitle + "].      ");
    emailInput.focus();
    return false;
  }
  else if(theStr.indexOf("@") <= 0)
  { alert("Please enter valid [" + inputTitle + "].      \n\n"
        + "( yourname@yourdomain.com )" );
    emailInput.focus();
    return false;
  }
  else if ( !((pindex > index+1) && (theStr.length > pindex+1)) )
  { alert("Please enter valid [" + inputTitle + "].      \n\n"
        + "( yourname@yourdomain.com )" );
    emailInput.focus();
    return false;
  }

	return true;
}//end validate email address


