// Copyright (c)2002-2003 VirtualTourist.com, Inc. All rights reserved.

var VT_DYNA_PATH = "http://members.virtualtourist.com/";

function _win(l,n,u,w,h,p,c,m) {
  try {
    var w=window.open(u,n,'resizable=1,scrollbars=1'+(w?',width='+w:'')+(h?',height='+h:'')+(p?','+p:''));
    w.focus();
    return w;
  } catch(e) {
    var t='';
    //    for(var n in e)t+=n+' -> '+e[n]+'\n';
    alert((m?m:'The '+(l?l:'popup window')+' has been blocked by a popup blocker.\nTo use all the features of this site, please allow popups.')+'\n\nThanks,\nyour VT Team.'+(c?'\n\n[code:'+c+']':'')+(t!=''?'\n\n'+t:''));
  }
  return null;
}

// start

var cookie_map=null;
function getCookie(n){
  if(!document.cookie)return null;
  if(!cookie_map){
    cookie_map=new Object();
    var cs=document.cookie.split(/; ?/);
    for(var i=0;i<cs.length;i++){
      var c=cs[i].indexOf('=');
      cookie_map[cs[i].substr(0,c)]=unescape(cs[i].substr(c+1));
    }
  }
  return cookie_map[n];
}
function setCookie(n,v,t,d){
  var e=(t?new Date(new Date().getTime()+(3600000*24*t)):null);
  document.cookie=n+'='+v+((e)?'; expires='+e.toGMTString():'')+'; path=/'+((d)?'; domain='+d:'');
  if(cookie_map)cookie_map[n]=v;
}
function checkConsole(){
  
  try{
    var now=new Date();
    var vt=null;
    var id=null;
    try{
      vt=getCookie('VT').split('|');
      id=vt[0].split('.')[0];
    }catch(e){}
    if(id){
      var val=vt[0];
      for(var i=1;(i<vt.length)||(i<=6);i++)val+='|'+(i==6?now.getTime():vt[i]);
      setCookie('VT',val,(Number(vt[7])?300:0),'.virtualtourist.com');
      if(now-(Number(vt[6])||0)>1800000){
        var c=getCookie('VTC_'+id);
        var p=(c?Number(c.split('|')[0]):1<<7);
        if(((1<<7)&p)>0)showConsole(false);
      }
      window.setTimeout('checkConsole();',600000);
    }
  }catch(e){
    var es='';
    for(var n in e)es+=n+'='+e[n]+'\n';
    alert('CHECK: there was an error,please mail feedback@virtualtourist.com with this message.\n\n'+es);
  }
}

function showConsole(m){
  var w = _win('VT Notice Console','VTConsole',VT_DYNA_PATH+'m/cn/',350,450,null,'console',
    (m?null:'VT Notice Console was blocked by a popup blocker.\n\nIf you want your console to open automatically when you login, please disable your pop up blocker.\n\nIf you want to open the Notice Console manually, click the "notices console" link at the top of this page. You do NOT need to disable pop ups to use the Notices Console.\n\nTo control your Notices Console, simply adjust Preferences found in your console.'));
   if(w==null) { 
    	setTimeout("consoleBlinkOn()",100);
    }
}

function showConsoleClick(m) {
	 var w = _win('VT Notice Console','VTConsole',VT_DYNA_PATH+'m/cn/',350,450,null,'console',
    (m?null:'VT Notice Console was blocked by a popup blocker.\n\nIf you want your console to open automatically when you login, please disable your pop up blocker.\n\nIf you want to open the Notice Console manually, click the "notices console" link at the top of this page. You do NOT need to disable pop ups to use the Notices Console.\n\nTo control your Notices Console, simply adjust Preferences found in your console.'));
   if(w==null) {
		var nc = getObject("nconsole");
		if(nc==null) return;
   	nc.href = VT_DYNA_PATH+"m/cn/";
   	nc.target = "_blank";	
    }
}

function consoleBlinkOn() { 
	if(blinktimes++>10) { blinktimes=0; return; }
	var el = getObject("nconsole");
	if(el==null) return;
	el.className = "blinkOn";
	setTimeout("consoleBlinkOff()",100);
}
function consoleBlinkOff() { 
	var el = getObject("nconsole");
	if(el==null) return;
	el.className = "blinkOff";
	setTimeout("consoleBlinkOn()",200);
}

//end

function pc(pid) {
  _win('Post Card','PCARD_WIN',VT_DYNA_PATH+'vt/ps/'+pid+'/0/',640,600,null,'pc');
}

var picwindow = null;
function wopic(path,w,h) {
	var maxw = (screen.width>=800 ? screen.width : 800)-40;
	var maxh = (screen.height>=600 ? screen.height : 600)-80;
	var xpos = 0;
	var ypos = 0;
	if(w+150>maxw) { w = maxw; xpos=1; }
	else if(w<=350) { w = 500; xpos = Math.round((maxw-w)/2); }
	else { w = w + 150; xpos = Math.round((maxw-w)/2); }
	if (h+250 > maxh) { h = maxh; ypos=1; }
	else { h = h + 250; ypos = Math.round((maxh-h)/2); }
	try { 
		if(picwindow!=null && !picwindow.closed) {
			picwindow.location = VT_DYNA_PATH+path;
			picwindow.resizeTo(w,h);
		} else {
		  picwindow=_win('picture window','PIC_WIN',VT_DYNA_PATH+path,w,h,null,'wopic-'+path);
		}
		picwindow.moveTo(xpos,ypos);
		picwindow.focus();
	} catch(e) { }
}

function pic(pid,w,h) {
	wopic('m/p/m/'+pid+'/',w,h);
}

function cnpic(pid,w,h) {
	wopic('m/p/c/'+pid+'/',w,h);
}

function mpic(mpid,w,h) {
	wopic('m/p/p/'+mpid+'/',w,h);
}

function wo(url) {
  _win('text window','COPY_WIN',url,550,500,null,'wo-'+url);
}

function mapwin(url) {
  _win('map window','EXP_CITY',VT_DYNA_PATH+'l/'+url,800,530,'toolbar=1,status=1','mapwin-'+url);
}

function vtmapwin(url) {
  _win('map window','EXP_CITY',url,800,700,'toolbar=1,status=1','mapwin-'+url);
}

function comment(mid,lid) {
  _win('comments window','COMMENT_WIN',VT_DYNA_PATH+'m/cm/'+mid+'/'+lid+'/',500,400,'dependent=1','cmt-'+mid+'-'+lid);
}

function comment(mid,lid,url) {
  _win('comments window','COMMENT_WIN',VT_DYNA_PATH+'m/cm/'+mid+'/'+lid+'/?'+url,500,400,'dependent=1','cmt-'+mid+'-'+lid);
}

function tellfriend(lid,cid,tgid) {
  _win('message window','TF_WIN',VT_DYNA_PATH+'vt/tf/1/'+lid+'/'+cid+'/'+tgid+'/',530,540,'status=1','tf-'+lid+'-'+cid+'-'+tgid);
}

function addtocustomtravelguide(tid,lid) {
  _win('Custom Travel Guide window','ADD_WIN',VT_DYNA_PATH+'/ptg/pa/0/1/'+tid+'/'+lid+'/?-vt-9',500,400,null,'ctg-'+tid+'-'+lid);
}

function vote(tip,vote,mode,source) {
  _win('vote','VOTE_WIN',VT_DYNA_PATH+'m/tv/'+tip+'/'+mode+'/'+vote+'/'+source+'/',240,200,'dependent=1','vote-'+tip+'-'+mode);
}

function deleteTip(tipid) {
	if(true==confirm("Delete this tip?")) {
		_win('delete tip window','DELETE_WIN',VT_DYNA_PATH+'vt/y/3/'+tipid+'/0/',550,500,null,'delete-'+tipid);
	}
}

function removePicFromRotation(picid) {
	if(true==confirm("Remove this picture from rotation?")) {
			_win('remove  from rotation window','REMOVE_WIN',VT_DYNA_PATH+'vt/y/9/'+picid+'/0/',550,500,null,'remove-'+picid);
	}
}

var _t='tim', _w='www', _h='http://', _o='on', _e='e', _c='com', _dot='.';
function othotellink(sid,hid,lid) { 
 var url = _h+_w+_dot+_o+_e+_t+_e+_dot+_c+'/hotels?'+ (hid? 'nhid='+hid+'&' : '') + (lid? 'location='+lid+'&' : '') +'sid='+sid;
 window.status = url;
 _win('ot hotel window','OT_HOTEL_WIN',url,800,600,'toolbar=1,status=1,menubar=1,directories=1,location=1',''); }
function otflightlink(sid,to,lid) {
var url = _h+_w+_dot+_o+_e+_t+_e+_dot+_c+'/flights?'+ (to? 'to='+to+'&' : '') + (lid? 'tid='+lid+'&' : '') +'sid='+sid;
window.status = url;
_win('ot flight window','OT_FLIGHT_WIN',url,800,600,'toolbar=1,status=1,menubar=1,directories=1,location=1','');} 

function checkEmail(e){ if (e.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)) return true; alert('Please provide a valid email address'); return false;}
var blinktimes = 0;

function opSrvA(){
  num = Math.random()
  try{
  srvA = getCookie('srvA');
  	if(srvA == null || srvA =='' ) {
  		if( num >= .9 ) {
  		
  		  swin = window.open('http://members.virtualtourist.com/vt/sy/9/','SYWIN','width=550,height=525,dependent=yes,scrollbars=yes').focus();
 
  		}
  		
  		setCookie('srvA','op',30,'virtualtourist.com');
 
  	}		
  } catch(e){}
}

//opSrvA();

var cm8pr_plugin = null; // to fix firefox and mozzilla problem with point roll ads
if (self.location!=top.location) top.location=self.location;

