/********************	
	COMMON.JS		
	INDEX.HTM
	CITYWEBSTER		
 ********************/


//Variables used in browser detection
var isIE = 0;
var isNS = 0;
var isMac = 0;
var browserVersion = parseInt(navigator.appVersion);
var browser = navigator.appName;

//------------------------------------------------------------ Browser General
function checkBrowser()
{
	isIE = (browser == 'Microsoft Internet Explorer') ? 1 : 0;
	isNS = (browser == 'Netscape') ? 1 : 0;
	isMac = (navigator.appVersion.indexOf("Mac") != -1) ? 1 : 0;
	if(!isIE && !isNS ){
		alert('This system requires Internet Explorer or Netscape Navigator, Versions 4.0+');
		return(false);
	}
	else if(browserVersion < 4){
		alert('This application requires a browser version 4.0 or above.');
		return(false);
	}
	return(true);
}

function MM_reloadPage(init) {
	if (init==true) with (navigator) {
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
			document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
			onresize=MM_reloadPage;
		}
	}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) 
		location.reload();
}
MM_reloadPage(true);

function MM_preloadImages()
{
	var d=document; 
	if(d.images)
	{ 
		if(!d.MM_p)
			d.MM_p=new Array();
		var i,j=d.MM_p.length, a=MM_preloadImages.arguments; 
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0)
			{
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
	}
}

function MM_findObj(n, d)
{
	var p,i,x;  
	if(!d) 
		d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all)
		x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++)
		x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
		x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById)
		x=document.getElementById(n); 
	return x;
}

//------------------------------------------------------------ onMouserOver Effects
function MM_swapImage()
{
	var i,j=0,x,a=MM_swapImage.arguments; 
	document.MM_sr=new Array; 
	for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null)
		{
			document.MM_sr[j++]=x;
			if(!x.oSrc) 
				x.oSrc=x.src; 
			x.src=a[i+2];
		}
}

function MM_swapImgRestore()
{
	var i,x,a=document.MM_sr; 
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
		x.src=x.oSrc;
}

function MM_changeBgcolor(obj, col, textCol)
{
	obj.style.backgroundColor = col;
	obj.style.color = textCol;
}

//------------------------------------------------------------ onFocus Effects
function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}

function restoreDefault(el) {
  if (el.value=="") el.value = el.defaultValue
}


//------------------------------------------------------------ onClick Effects
function MM_changeLocation() 
{
	var sUrl = selCity.options[selCity.selectedIndex].value;
	window.location = sUrl;
}

function MM_gotoLocation(sUrl) 
{
	window.location = sUrl;
}

function MM_openLocation(sUrl) 
{
	window.open(sUrl);
}

function MM_popMsg(url, type)
{
	var winWidth=520, winHeight=280, posLeft, posTop;
	if (type == 0) {
		posLeft = (screen.width - winWidth) / 2;
    	posTop = (screen.height - winHeight - 75) / 2;

		if (navigator.appName == "Netscape")
			msgWindow = window.open(url, 'msgWindow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,directories=0,width='+winWidth+',height='+winHeight+',screenX='+posLeft+',screenY='+posTop);
		else
			msgWindow = window.open(url, 'msgWindow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,directories=0,width='+winWidth+',height='+winHeight+',left='+posLeft+',top='+posTop);
	}
	else
		msgWindow = window.open(url, 'msgWindow');
	
	window.msgWindow.focus();
}

function MM_popWin(url, type, winWidth, winHeight)
{
	var posLeft, posTop, wWidth, wHeight;
	wWidth = winWidth;
	wHeight = winHeight;
	if (type == 0) {
		posLeft = (screen.width - winWidth) / 2;
    	posTop = (screen.height - winHeight - 75) / 2;

		if (navigator.appName == "Netscape")
			popWin = window.open(url, 'popWin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,directories=0,width='+wWidth+',height='+wHeight+',screenX='+posLeft+',screenY='+posTop);
		else
			popWin = window.open(url, 'popWin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,directories=0,width='+wWidth+',height='+wHeight+',left='+posLeft+',top='+posTop);
	}
	else
		popWin = window.open(url, 'msgWindow');
	
	window.popWin.focus();
}

function MM_showHideLayers()
{
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-1); i+=2) 
		if ((obj=MM_findObj(args[i]))!=null) 
		{
			v=args[i+1];
			if (obj.style) 
			{
				obj=obj.style; 
				v=(v=='show')?'block':(v='hide')?'none':v;
			}
			obj.display=v;
		}
}

function MM_toggleVisibility(arg)
{
	if ((obj=MM_findObj(arg))!=null) 
	{
		if (obj.style.display=="none") 
		{
			obj.style.display = "block"; 
		}
		else 
			obj.style.display="none";
	}
}

function wop(obj) {
	document.getElementById(obj).style.visibility="hidden";
}
function unWop(obj) {
	if (document.getElementById(obj).style.visibility=="visible")
		document.getElementById(obj).style.visibility="hidden";
	else if (document.getElementById(obj).style.visibility=="hidden")
		document.getElementById(obj).style.visibility="visible";
}

//------------------------------------------------------------ Scroll Effects
function movstar(a,time) {
	movx=setInterval("mov("+a+")",time)
}

function movover() {
	clearInterval(movx)
}

function mov(a) {
	scrollx=new_date.document.body.scrollLeft
	scrolly=new_date.document.body.scrollTop
	scrolly=scrolly+a
	new_date.window.scroll(scrollx,scrolly)
}

function wback() {
	if(new_date.history.length==0){window.history.back()}
	else{new_date.history.back()}
}

function goImgWin(myImage,myWidth,myHeight,
 origLeft,origTop) {
myHeight += 250;
myWidth += 250;
TheImgWin = window.open(myImage,'image','height=' +
myHeight + ',width=' + myWidth +
',toolbar=no,directories=no,status=no,' +
'menubar=no,scrollbars=no,resizable=no');
TheImgWin.resizeTo(myWidth+2,myHeight+30);
TheImgWin.moveTo(origLeft,origTop);
TheImgWin.focus();
}


var link = "http://www.yes411.com";
var title = "Yes411 全球華人首選生活資訊網"; 
function fav()
{
if(document.all)
window.external.AddFavorite(link,title)
}



//------------------------------------------------------------ Right Click / Select Lock
// oncontextmenu="return false" ondragstart="return false" onselectstart="return false" onselect=document.selection.empty() oncopy=document.selection.empty() onbeforecopy="return false"
