var TypeOfMSN = 0; var TypeOfSkype = 1; var TypeOfQQ = 2; var TypeOfICQ = 3; var TypeOfYahoo = 4; var TypeOfAOL = 5; var TypeOfGTalk = 6; var bMsnInstalled = null; var bSkypeInstalled = null; var bQQInstalled = null; var bYmInstalled = null; var bAimInstalled = null var IMInstalled = function(type){ switch (type){ case TypeOfMSN:{ if(bMsnInstalled == null){ bMsnInstalled = msnInstalled(); } return bMsnInstalled; break; } case TypeOfSkype:{ if(bSkypeInstalled == null){ bSkypeInstalled = skypeInstalled(); } return bSkypeInstalled; break; } case TypeOfQQ:{ if( bQQInstalled == null ){ bQQInstalled = qqInstalled(); } return bQQInstalled; break; } case TypeOfICQ:{ return true; break; } case TypeOfYahoo:{ if ( bYmInstalled == null ) { bYmInstalled = ymInstalled(); } return bYmInstalled; break; } case TypeOfAOL:{ if ( bAimInstalled == null ) { bAimInstalled = aimInstalled(); } return bAimInstalled; break; } case TypeOfGTalk:{ return false; break; } } return false; } var TypeOfIMToName = function(type){ switch (type){ case TypeOfMSN:{ return "MSN"; break;} case TypeOfSkype:{ return "Skype"; break;} case TypeOfQQ:{ return "QQ"; break; } case TypeOfICQ:{ return "ICQ"; break; } case TypeOfYahoo:{ return "YM"; break; } case TypeOfAOL:{ return "AIM"; break; } case TypeOfGTalk:{ return "GTalk"; break; } } return ""; } var IMDownloadLind = function(type){ switch (type){ case TypeOfMSN:{ return "http://www.msn.com"; break;} case TypeOfSkype:{ return "http://www.skype.com"; break;} case TypeOfQQ:{ return "http://im.qq.com"; break; } case TypeOfICQ:{ return "http://www.icq.com"; break; } case TypeOfYahoo:{ return "http://cn.messenger.yahoo.com/"; break; } case TypeOfAOL:{ return "http://www.aim.com/"; break; } case TypeOfGTalk:{ return "http://www.google.com/talk/"; break; } } return ""; } var IMNotInstalledMsg = function(type){ return ("$1 not installed or not logged in.\nPlease make sure latest $1 installed and logged in with your $1 account.".replace(/\$1/g , TypeOfIMToName(type))); } var IMConfirmInstalledMsg = function(type){ return ("Have you installed $1 yet?".replace(/\$1/g , TypeOfIMToName(type))) ; } var IM_Popup = function( type , cmd ){ IM_Click_Log(type , cmd); try { var downloadLink = ""; if (isIEBrowser() == true){ var bInstalledIm = IMInstalled(type) ; if (type == TypeOfAOL || type == TypeOfGTalk){ IM_InstallConfirmPopup(type , cmd) }else if (bInstalledIm == true){ if ( type == TypeOfMSN && bOSForMsnLive() != true ){ objMessenger.InstantMessage(cmd); }else if( type == TypeOfMSN ){ im_popup2( "msnim:chat?contact=" + cmd ); }else{ im_popup2( cmd ) } }else{ alert( IMNotInstalledMsg(type) ); } }else{ // Non-IE Browser if(type == TypeOfICQ){ im_popup2( cmd ); }else{ IM_InstallConfirmPopup(type , cmd) } } } catch(e) { alert(IMNotInstalledMsg(type)); //alert(e.name + " : " + e.message); } } var IM_InstallConfirmPopup = function( type , cmd ){ if( type == TypeOfMSN ){ cmd = "msnim:chat?contact=" + cmd ; } window.open( ( "/member/IMInstallConfirmMessage.asp?type=" + type + "&cmd=" + cmd ) , "im_confirm" , "scrollbar=yes,location=no,width=320,height=80,toolbar=no" ); } var im_popup2 = function(link){ var winImPopup = window.open( link , "im_popup" ) if(winImPopup){ }else{ //alert("Popup Blocked"); } } var isIEBrowser = function(){ if( navigator.userAgent.indexOf("MSIE") > 0 ){ return true; }else if(window.XMLHttpRequest){ return false; }else{ return true; } } var msnInstalled = function() { if(bOSForMsnLive() == true){ return msnLiveInstalled(); }else{ return msn7Installed(); } return false; } var msn7Installed = function(){ return true; /* try { var total = objMessenger.UnreadEmailCount(0); return true; }catch(e){ if(!(e.number && 2148139390) == 2148139390)return false; } if(objMessenger.MyStatus == 1){ return false; } return true;*/ } var msnLiveInstalled = function(){ return true; /* try { new ActiveXObject("MSNMessenger.P4QuickLaunch"); return true; } catch (e) { return false; }*/ } var qqInstalled = function() { return true; /*try { new ActiveXObject("TimwpDll.TimwpCheck"); return true; } catch (e) { return false; }*/ } var skypeInstalled = function(){ try{ new ActiveXObject("Skype.Detection"); return true; } catch (e) { return false; } } var ymInstalled = function(){ return true; try{ new ActiveXObject("YPagerChecker.MessengerChecker"); return true; } catch(e) { return false; } } var aimInstalled = function(){ var aimMime = navigator.mimeTypes["application/x-aim"]; if( aimMime == "object" ){ return true; }else{ return false; } } var bOSForMsnLive = function(){ var tmpOS = BrowserDetect2.searchOS() ; tmpOS = tmpOS.toString(); if( tmpOS.indexOf( "Windows" ) >= 0 ){ if(tmpOS.indexOf( "2000" ) >= 0 ){ return false; }else{ return true; } }else{ return false; } } var checkIMValid = function(obj , ElementIDOfIMType , bShowAlertMsg){ var IMType = document.getElementById( ElementIDOfIMType ).value; var IMValue = obj.value; var bIsValid = true; if(IMType == "" && IMValue != ""){ bIsValid = false; if( bShowAlertMsg == true ){ alert("Please select Instant Messager type!"); } }else if(IMType == "M"){ bIsValid = isMsnFormat(IMValue) if(bIsValid == false && bShowAlertMsg == true){ alert(("Your $1 ID contains invalid format, please re-enter!".replace("$1", "MSN") )); } }else if(IMType == "Y"){ bIsValid = isYmFormat(IMValue) if(bIsValid == false && bShowAlertMsg == true){ alert(("Your $1 ID contains invalid format, please re-enter!".replace("$1", "YM") )); } }else if(IMType == "I"){ bIsValid = isICQFormat(IMValue) if(bIsValid == false && bShowAlertMsg == true){ alert(("Your $1 ID contains invalid format, please re-enter!".replace("$1", "ICQ") )); } }else if(IMType == "S"){ bIsValid = isSkypeFormat(IMValue) if(bIsValid == false && bShowAlertMsg == true){ alert(("Your $1 ID contains invalid format, please re-enter!".replace("$1", "Skype") )); } }else if(IMType == "Q"){ bIsValid = isQQFormat(IMValue) if(bIsValid == false && bShowAlertMsg == true){ alert(("Your $1 ID contains invalid format, please re-enter!".replace("$1", "QQ") )); } }else if(IMType == "A"){ bIsValid = isAIMFormat(IMValue) if(bIsValid == false && bShowAlertMsg == true){ alert(("Your $1 ID contains invalid format, please re-enter!".replace("$1", "AIM") )); } } if(bIsValid == false){ InValidIMFieldAction(obj , bShowAlertMsg); }else{ ValidIMFieldAction(obj); } return bIsValid; } var checkAllIMValid = function(){ var tmpReuslt = true; for(i = 1 ; i < 5 ; i++){ var InfoObj = document.getElementById("cinfo"+i); var sTypeObj = ("ctype"+i); tmpReuslt = checkIMValid(InfoObj , sTypeObj , true); if( tmpReuslt == false ){ var alertMSG = "Instant Messaging $1 contains invalid character"; tmpReuslt = false; return tmpReuslt; } } return tmpReuslt; } var InValidIMFieldAction = function(obj , bShowAlertMsg){ obj.style.background = "#FFDCE6" if(bShowAlertMsg == true ){ obj.focus(); } } var ValidIMFieldAction = function(obj){ obj.style.background = "white" } var isMsnFormat = function(v){ if(v == ""){ return false; } return isValidEmailAddress(v); } var isICQFormat = function(v){ if(v == ""){ return false; } v = v.replace(/\s/g , ""); var tmpresult = /^\d*$/i.test(v); return tmpresult; } var isQQFormat = function(v){ if(v == ""){ return false; } v = v.replace(/\s/g , ""); var tmpresult = /^\d*$/i.test(v); return tmpresult; } var isAIMFormat = function(v){ var tmpresult = /^[a-zA-Z][\w\d]{2,15}$/i.test(v); return tmpresult; } var isSkypeFormat = function(v){ var tmpresult = /^[a-zA-Z][\w\d._-]{5,150}$/i.test(v); return tmpresult; } var isYmFormat = function(v){ if(v == ""){ return false; } return isValidEmailAddress(v); } var IM_Click_Log = function(t , cmd){ var http; if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); } var data = "type=" + t + "&cmd=" + ( cmd.replace(/\&/g , "%26") ) http.open("GET", "/public/IM_Click_Log.asp?" + data, true); http.onreadystatechange=function() { if(http.readyState == 4) { } } http.send(null); }