//Fade
function getObject(obj) {
	var o;
	if(document.getElementById) o = document.getElementById(obj);
	else if(document.all) o = document.all.obj;	
	return o;	
}

function fade(amt,obj) {
	if(amt <= 100) {
		setFade(amt,obj);
		amt += 10;
		setTimeout("fade("+amt+",'"+obj+"')", 5);
    }
}

function setFade(amt,obj) {
	var obj = getObject(obj);
	amt = (amt == 100)?99.999:amt;
	obj.style.filter = "alpha(opacity:"+amt+")";
	obj.style.KHTMLOpacity = amt/100;
	obj.style.MozOpacity = amt/100;
	obj.style.opacity = amt/100;
}

function retype(el)
{
  if(el.id=='username'){
    if(el.value=='Username'){
      el.value='';
    }else if(el.value==''){
      el.value='Username';
    }
  }
}


var newWindow;
function openPopup(popup_width,popup_height,popup_url,var_name){
	var windowHeight = popup_height;
	var windowWidth = popup_width;
	var windowName = var_name;
	var windowUri = popup_url;

	var centerWidth = (window.screen.width - windowWidth) / 2;
	var centerHeight = (window.screen.height - windowHeight) / 2;

	if ( !newWindow || newWindow.closed ){
		try{
		newWindow = window.open(windowUri, windowName,'addressbar=0,menubar=0,location=0,status=0,scrollbars=yes,resizable=yes,width=' + windowWidth + 
			',height=' + windowHeight + 
			',left=' + centerWidth + 
			',top=' + centerHeight);
			//newWindow.location.href; // throws exception if after reload
			//newWindow.location = windowUri;
		}catch(e){};
	}else if ( newWindow && ! newWindow.closed ){
		newWindow.location.replace(windowUri);
		newWindow.focus();
	}
}

function gotoURL(popup_url , target ,popup_width,popup_height){
		if(target.toLowerCase() == "_self"){
			window.location.replace(popup_url);
		}else if(target.toLowerCase() == "_blank" && popup_width && popup_height){
			openPopup(popup_width,popup_height,popup_url);
		}else{
			if ( !newWindow || newWindow.closed ){
				try{
					newWindow = window.open(popup_url,"newWindow")
				}catch(e){};
			}
			 if ( newWindow && ! newWindow.closed ){
				newWindow.location.replace(windowUri);
				newWindow.focus();
			}
		}
	
	}
function showpoll(id){
	openPopup(800,700,'question.aspx?psid='+ id );
}

function popupWindow() {
	openPopup(800, 600, 'http://support.truecorp.co.th/truecarechat/chat?ch=support.truecorp', 'trueChat');
	// window.open("http://support.truecorp.co.th/truecarechat/chat?ch=support.trueinternet", "_blank", "directories=no,location=no,menubar=no,resizable=yes,status=no,titlebar=no,toolbar=no,width=600,height=500");
	// window.open("http://support.truecorp.co.th/truecarechat/chat?ch=support.truecorp", "_blank", "directories=no,location=no,menubar=no,resizable=yes,status=no,titlebar=no,toolbar=no,width=600,height=500");
}



