function getVURL(url)
{
	new_win = window.open(url,'_blank','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
	new_win.blur();
}


function AddToFavourite(storeid, to_remove)
{
	if(!storeid) return false;
	
	$.ajax({
	url: "/ajax/add_to_fav.php",
	type: "GET",
	data: "storeid="+storeid+"&to_remove="+to_remove,
	dataType: "script",
	success: function(msg){
		//eval(msg);
		}
   });
	 
}

function AddBookmark(ahref, atitle)
{
if(document.all)
	window.external.AddFavorite(ahref,atitle);
else if(window.sidebar)
	window.sidebar.addPanel(atitle,ahref,'');
}

function checkmail(e){
	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
	return emailfilter.test(e.value)
}


function NewWin(url, name, w, h)
{
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  
  if(win)

  {

    if(!win.closed) win.close();

  }
  
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=no, resizable=yes');
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}

function NewWinScrolls(url, name, w, h)
{
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  
    if(win)

  {

    if(!win.closed) win.close();

  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=yes, resizable=yes');
  // Just in case width and height are ignored
  try
  {
  	win.resizeTo(w, h);
	win.moveTo(wleft, wtop);
  }
  catch(exception)
  {}
  win.focus();
}

function CheckFileType(ctlFileName){
	strFileName = ctlFileName.value;
	var strFN = new String(strFileName);
	var aryFN = Array();
	aryFN = strFN.split(".");
	var strExt = new String(aryFN[aryFN.length-1]);
	strExt = strExt.toLowerCase();
	if ((strExt == 'gif' || strExt == 'jpeg' || strExt == 'jpg' || strExt == 'png')==false){
		ctlFileName.value='';
		alert('Please select an image of type GIF, JPEG or PNG.');
		return false;
	}
	
	return true;
}

function closeRedirect(url)
{
	window.opener.location.href = url;
	window.close();	
	return false; 
}