//如果是WinXPSP2 就會出現 SV1 字樣
var quotewin = null;
var framewinx = null;
function isWinXPSP2(){
	if (window.navigator.userAgent.indexOf("SV1") != -1)
		return true;
	else
		return false;
}
function get_cookie(name){
  var ary1 = document.cookie.split(";");
  var ary2;
  var value = null;
  for(i=0;i<ary1.length;i++){
    ary2 = ary1[i].split("=");
    if(ary2[0].replace(/(^\s*)/g, "") == name){
      value = ary2[1].replace(/(^\s*)/g, "");
    }

  }
  return value;
}
function openTbbURL(aURL, winname, first, id, conPath){
	//var first = get_cookie("firstLogin");
	//alert(get_cookie("firstLogin"));
	if(first=="Y"){//第一次使用本系統
		window.location = conPath+"/account/layout.jsp?type=4";
		window.focus();		
	}else{
    var aScreenWidth = screen.width;
    var aScreenHeight = screen.height;
	var xp = "";
    if(aScreenWidth>=1024){
      aScreenWidth=1024;
      
      if(isWinXPSP2()){
        aScreenHeight=680;
        xp = "y";
      }else{
        aScreenHeight=710;
      }
    }else{
      //aScreenWidth=800;
      //aScreenHeight=590;
      aScreenWidth=790;
      aScreenHeight=550;
    }
    aURL += "?xScreenWidth="+aScreenWidth+"&xScreenHeight="+aScreenHeight+"&xp="+xp;
    //alert(aURL);
    if(quotewin && winname=="Quote"){
    	 quotewin.close();
    	 quotewin = null;
    }
    if(framewinx && winname=="frame"){
    	 framewinx.close();
    	 framewinx = null;
    }
    if(winname=="frame"){
    	framewinx = window.open(aURL,winname+id,"top=0,left=0,height="+aScreenHeight+",width="+aScreenWidth+",scrollbars='no',resizable='yes',status=no");
    	framewinx.focus();
    }else if(winname=="Quote"){
    	quotewin = window.open(aURL,winname+id,"top=0,left=0,height="+aScreenHeight+",width="+aScreenWidth+",scrollbars='no',resizable='yes',status=no");
    	quotewin.focus();
    }
    }
}
function openTbbBuy(){
    var aScreenWidth = screen.width;
    var aScreenHeight = screen.height;
    var aURL = "https://www.tbbstock.com.tw/ASPOrder/q301.asp";
	var xp = "";
    if(aScreenWidth>=1024){
      aScreenWidth=1024;
      
      if(isWinXPSP2()){
        aScreenHeight=680;
        xp = "y";
      }else{
        aScreenHeight=710;
      }
    }else{
      aScreenWidth=790;
      aScreenHeight=550;
    }
    window.open(aURL,"buy","top=0,left=0,height="+aScreenHeight+",width="+aScreenWidth+",scrollbars='no',resizable='yes',status=no");
}