﻿// JavaScript Document
//<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
function FAddMyFav()
{
document.write('<a href="javascript:window.external.addFavorite(\''+ document.location + '\',\'兩岸通國際貨運公司\')"><img src="img/icon_myfavority.gif" alt="加入我的最愛" border="0"></a>') ;
}

function FAddMyFavority(name)
{
document.write('<a href="javascript:window.external.addFavorite(\''+ document.location + '\',\'' + name +'\')"><img src="img/icon_favorite_en.gif" alt="Add to My Favorite" border="0"></a>') ;
}

function FPrint()
{
document.write('<a href="javascript:print()"><img src="img/icon_print_en.gif" alt="Print This Page" border="0"></a>') ;
}

function isPPC() {
if (navigator.appVersion.indexOf("PPC") != -1) return true;
else return false;
}

function FMailFriend(){
if(isPPC()) {
  //document.write('<a href=\"mailto:\?subject\=Take a look at this page I found, ' + document.title + '?body=You can see this page at: ' + window.location + '\" ; return true">Tell Friend<\/A>');
}else { 
  document.write('<a href=\"mailto:\?subject\=Take a look at this page I found&body=You can see this page at: ' + window.location + '\" ; return true"><img src="img/icon_friend_en.gif" alt="Tell A Friend" border="0"><\/A>');
}
}

var sl_head='style="color:#990000;font-weight:bold;font-size:16px;"';
var sl_body='style="color: #990000; font-weight: normal; font-size: 16px;"';
var sl_g8 = 'gwls888.com';
var sl_g = 'gwls.com.tw';
var sl_hot = 'hotmail.com';
var sl_yahoo = 'yahoo.com.tw';
var sl_gm = 'gmail.com' ;
var sl_gicn = 'ginifab.com.cn' ;
var sl_163 = '163.com' ;
var sl_addlines = '%0A%0A%0A%0A%0A%0A%0A%0A%0A';
var sl_clickemail = '<span ' + sl_body + '>(請直接點選左邊超連結寫信)</span>';
var nl_oiladd = 13.5 ;
var sl_gini = 'ginifab.com';

//skype counter
function pause(numberMillis) {
  var now = new Date();
  var exitTime = now.getTime() + numberMillis;
  while (true) {
    now = new Date();
     if (now.getTime() > exitTime) return;
  }
}
function countskype(skypename)
{
location.href = "http://www.3ccafe.com/forwarder/bill/skypecounter.php?skypename=" + skypename  + "&pageurl=" + window.location ;
pause(500);
}

function skypebutton(name,method){
  return '<a title="" href="skype:'+ name +'?'+ method +'" onClick="countskype(\'' + name + '\');" onMouseOver="skypeonMouseOver(this); return true;" onmouseout="window.status=\'\'; return true;"><img src="img/skypeme_btn_small_white.gif" border="0"></a>';
}

function clickemail(email,cc){
  window.location.href = 'mai' + 'lt' + 'o:' + email.replace(/~NoSpam~/g,"@") + js_subject + sl_addlines + window.location + '&cc='+ cc.replace(/~NoSpam~/g,"@")  ;
}

function emailbutton(email,cc){
  return '<a href="javascript:void(0)" onMouseOver="emailonMouseOver(this); return true;" onmouseout="window.status=\'\'; return true;" onclick="clickemail(\'' + email.replace(/@/g,"~NoSpam~") + '\',\'' + cc.replace(/@/g,"~NoSpam~") + '\');"><img src=\'img/icon_email.gif\' border=0></a>' ; 
}

function emailonMouseOver(anc){
  anc.title = '請點擊這裡寫信給我，感謝您。^^' ;
  window.status= '請點選這裡.並在詢問的電子郵件中填寫相關資訊,建議您善用Email與我們聯絡,將有專人盡快回覆您' ;
}

function skypeonMouseOver(anc){
  anc.title = '點擊這裡使用Skype網上通話軟體與我交談。\n若無人接聽，建議改用Email與我聯系，感謝您。^^' ;
  window.status= '若您使用SKYPE網上通話軟體,歡迎點選這裡與我交談,若離線或忙線中,建議您利用Email與我聯絡' ;
}

function telno(no){
  today = new Date();
  hours = today.getHours();
  if ((today.getDay()==0) || (today.getDay()==6) || (hours >= 18) || (hours < 8) ) {
    return '<font color="#BBBBBB" onMouseOver="telonMouseOver(this); return true;" onmouseout="window.status=\'\'; return true;" >' + no + '</font>' ;
  } else {
    return '<font onMouseOver="telonMouseOver(this); return true;" onmouseout="window.status=\'\'; return true;" >' + no + '</font>' ;
  }
}

function telonMouseOver(anc){
  today = new Date();
  hours = today.getHours();
  hint = '若目前為休息時間或例假日，建議您改用Email與我聯繫，我們將有專人與您盡快聯絡，謝謝。'
  hint2 = '如無人接聽或電話忙線中，建議您改用Email與我聯繫，我們將有專人與您盡快聯絡，謝謝。'
  if ((today.getDay()==0) || (today.getDay()==6) || (hours >= 18) || (hours < 8) ) {
	anc.title = hint ;
	window.status = hint ;
  } else {
	anc.title = hint2 ;
	window.status = hint2 ;
  }
}
//

function FSuperSales_English()
{
document.write('<table width="80%" border="1" cellspacing="1" cellpadding="1"><tr '+sl_head+'><td nowrap>Location</td><td nowrap>Sales Rep.</td><td nowrap >EMail</td><td nowrap >Skype</td><td nowrap >Phone No.</td></tr>') ;
document.write('<tr><td '+ sl_head+'">DongGuan, China</td><td '+ sl_head+'">David Wang</td><td nowrap '+ sl_head+'>'+ emailbutton_english('dw4363@'+ sl_gm , 'promoia@'+ sl_hot ) + '</td><td '+ sl_body +'>'+ skypebutton('dw4363','chat') +'</td><td nowrap>' + telno('+86-13689549119') + '</td></tr>') ;
document.write('<tr><td '+ sl_head+'">Suzhou, China</td><td '+ sl_head+'">David Wang</td><td nowrap '+ sl_head+'>'+ emailbutton_english('dw4363@'+ sl_gm , 'promoia@'+ sl_hot ) + '</td><td '+ sl_body +'>'+ skypebutton('dw4363','chat') +'</td><td nowrap>' + telno('&nbsp;') + '</td></tr>') ;
document.write('<tr><td '+ sl_head+'">Taipei</td><td '+ sl_head+'">Eric Lin</td><td '+ sl_head +'>' + emailbutton_english('promoia@'+ sl_hot, 'dw4363@'+ sl_gm ) + '</td><td '+ sl_body +'>'+ skypebutton('cableeric','chat') +'</td><td nowrap>' + telno('+886-920909163') + '</td></tr>') ;
document.write('</table>');
}

function FSuperSales()
{
document.write('<table width="80%" border="1" cellspacing="1" cellpadding="1"><tr '+sl_head+'><td nowrap>&nbsp;</td><td nowrap>洽詢窗口</td><td nowrap >EMail(電子郵件)</td><td nowrap >線上通訊</td><td nowrap >行動電話</td></tr>') ;
document.write('<tr><td '+ sl_head+'">台北</td><td '+ sl_head+'">林先生</td><td '+ sl_head +'>' + emailbutton('promoia@'+ sl_hot, 'dw4363@'+ sl_gm ) + '</td><td '+ sl_body +'>'+ skypebutton('cableeric','chat') +'</td><td nowrap>' + telno('0920909163') + '</td></tr>') ;
document.write('<tr><td '+ sl_head+'">蘇州</td><td '+ sl_head+'">王先生</td><td nowrap '+ sl_head+'>'+ emailbutton('dw4363@'+ sl_gm , 'promoia@'+ sl_hot ) + '</td><td '+ sl_body +'>'+ skypebutton('dw4363','chat') +'</td><td nowrap>' + telno('') + '</td></tr>') ;
document.write('<tr><td '+ sl_head+'">東莞</td><td '+ sl_head+'">王先生</td><td nowrap '+ sl_head+'>'+ emailbutton('dw4363@'+ sl_gm , 'promoia@'+ sl_hot ) + '</td><td '+ sl_body +'>'+ skypebutton('dw4363','chat') +'</td><td nowrap>' + telno('+86-13689549119') + '</td></tr>') ;
document.write('</table>');
}

function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}

function FGiftSales()
{
document.write('<div id="divContactInfo">');
document.write('<table width="80%" border="1" cellspacing="1" cellpadding="1"><tr '+sl_head+'><td nowrap>地點</td><td nowrap>洽詢窗口</td><td nowrap >EMail(電子郵件)</td><td nowrap >線上通訊</td><td nowrap>行動電話</td></tr>') ;
document.write('<tr><td '+ sl_head+'">蘇州</td><td '+ sl_head+'">王先生</td><td nowrap '+ sl_head+'>'+ emailbutton('dw4363@' + sl_gm,'promoia@' + sl_hot ) +'</td><td '+ sl_body +'>'+ skypebutton('dw4363','chat') +'</td><td nowrap>' + telno('+86-137-7604-4400') +'</td></tr>') ;
document.write('<tr><td '+ sl_head+'">台北</td><td '+ sl_head+'">林先生</td><td '+ sl_head +'>' + emailbutton('promoia@'+ sl_hot, 'dw4363@'+ sl_gm ) + '</td><td '+ sl_body +'>'+ skypebutton('cableeric','chat') +'</td><td nowrap>'+ telno('+886-920909163') +'</td></tr>') ;
document.write('</table>');
document.write('</div>');
loadcontactinfo('13',"divContactInfo","gb");
}

function FAD_in_Taiwan_Sales()
{
document.write('<div id="divContactInfo">');
document.write('</div>');
loadcontactinfo('25',"divContactInfo","gb");
}

var xmlHttp = false;
function  createRequest() {
	if(window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} else if(window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
	if (!xmlHttp) {
		//alert('can not creat ajax');
		return false;
	}
}

function loadcontactinfo(id,dContact,lang) {
	createRequest();
	var url = "promo/ajax_proxy.php?url=ajax_contactinfo.php?id=" + id + "&lang=" + lang;
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = 
	function(){
		if(xmlHttp.readyState!=4){return; }
		if(xmlHttp.status==200){
			document.getElementById(dContact).innerHTML = xmlHttp.responseText;
		}
	};
	xmlHttp.send(null);
}
