﻿// JScript File
// For slide show image

function SlideImage()
{
    var obj = document.getElementById("imgDiv");
    var obj1 = document.getElementById("tmpImageDiv2");
    var objlen = obj.offsetWidth;
    if(_moveSpan > 0 && (obj1.offsetWidth - obj.scrollLeft) <= 0){
        //Post image move to right
        obj.scrollLeft = 0;
    }
    if(_moveSpan < 0 && obj.scrollLeft <= 0)
    {
        //Post image move to left
        obj.scrollLeft = obj1.offsetWidth;
    }
    obj.scrollLeft += _moveSpan;
}

function SlideToLeft(){
    if(_moveSpan < 0){
        _moveSpan *= -1;
    }
}
function SlideToRight(){
    if(_moveSpan > 0){
        _moveSpan *= -1;
    }
}

if (window.addEventListener)
{
    window.addEventListener("load", SlideShowOnLoad, false);
}
else if (window.attachEvent)
{
    window.attachEvent("onload", SlideShowOnLoad);
}
else
{
    window.onload=SlideShowOnLoad;
}
function SlideShowOnLoad(){
    var tempObj = document.getElementById("tmpImageDiv1");
    var maxObj = document.getElementById("imgDiv");
    if (tempObj && maxObj) {
        var demoWidth = tempObj.offsetWidth;
        var maxWidth = parseInt(maxObj.style.width);
        if(demoWidth <= maxWidth) {
            //set Move left btn and Move right btn visible = false
            document.getElementById("rollLeftDiv").style.display = "none";
            document.getElementById("rollRightDiv").style.display = "none";
            return;
        }
        document.getElementById("tmpImageDiv2").innerHTML = document.getElementById("tmpImageDiv1").innerHTML;
        startMove();
    }
}
function startMove(){
    if(_MoveMarquee == null)
    {
        _MoveMarquee = "move";
        _MoveMarquee = setInterval(SlideImage,_MoveSpeed);
    }
    return;
}
function stopMove(){
    window.clearInterval(_MoveMarquee);
    window.clearInterval(_MoveMarquee);
    _MoveMarquee = null;
}


function OpenPageOnNewWindow(hostName,regionName,imgurl,evt){
    var hostname = window.location.hostname;
    var path = window.location.search;
    var lang = "";
    if(path.indexOf("&lang=") > -1){
        lang = path.substr(path.indexOf("&lang="),11);
    }
    var url = hostName + "/" + regionName + "/views/photoDetail.aspx?ImgUrl=" + imgurl + lang;
    var objwidth = 100;
    var objheight = 100;
    var feature = "width=" +objwidth +",height=" + objheight + ",toolbar=no,menubar=no,resizeable=no,statusbar=no,location=no,scrollbars=no";
    //window.open(url,"",feature);
}



//-----------------------post info---------------

    function markAsSpam(cid, mid)
    {
        ModalConfirmMsg(confirmReportMessage, "submitMarkAsSpam(" + cid + "," + mid + ");");
    }

	function confirmAddAdToFav(pid)
	{
		ModalConfirmMsg(addToFavoriteMessage, "addAdToFav(" + pid + ");");
	}

    function addAdToFav(pid)
    {
        document.getElementById("FavPostID").value = pid;
        document.getElementById("aspnetForm").submit();
    }

    function submitMarkAsSpam(cid, mid)
    {
        document.getElementById("SpamCommentID").value = cid;
        document.getElementById("SpamMemberID").value = mid;
        document.getElementById("aspnetForm").submit();
    }
    

	 function showFlagAsInappPopup() {
		if (isMasterDisabled != 1) {  
			var str = '';       
			str += '<font color="#ff850a"><b>' + reportAdWindowTitle + '</b></font>';
			str += '<br />' + reportAdWindowContent + '<br />';
			str += '<br /><input type="radio" name="InappType_Radio" id="R1" value="S">' + reportAdWindowSpam;
			str += '<br /><input type="radio" name="InappType_Radio" id="R2" value="O">' + reportAdWindowOffensive;
			str += '<br /><input type="radio" name="InappType_Radio" id="R3" value="P">' + reportAdWindowProhibited;
			str += '<br /><input type="radio" name="InappType_Radio" id="R4" value="M">' + reportAdWindowMiscategorized;         
			str += '<br /><br /><input type="button" value="' + submitText  + '" onClick="submitFlagAsInapp();return true;" class="Button">';
			str += '<input type="button" value="' + cancelText + '" onClick="YAHOO.example.container.flag.destroy();" class="Button">';
			str += '<br />';    
            YAHOO.example.container.flag = createDialog("Flag", str, true, "280px", null);              
            YAHOO.example.container.flag.show();                
		} 
	}

	function submitFlagAsInapp()
    {    
        var SelectedInappType_Radio = document.getElementById("R1");        
        var r1 = document.getElementById("R1");
        var r2 = document.getElementById("R2");
        var r3 = document.getElementById("R3");
        var r4 = document.getElementById("R4");
    
        if( !r1.checked && !r2.checked && !r3.checked && !r4.checked ) {
            ModalWinMsg("", reportAdWindowMuseSelecteReportTypeMessage, YAHOO.example.container.flag);
        } else {
            if( r1.checked ) {
                document.getElementById("InappFlag").value = "S";
            } else if( r2.checked ) {
                document.getElementById("InappFlag").value = "O";
            } else if( r3.checked ) {
                document.getElementById("InappFlag").value = "P";
            } else if( r4.checked ) {
                document.getElementById("InappFlag").value = "M";
            }            
            document.getElementById("aspnetForm").submit();
        }        
    }

	var mapTimeoutId;	
	function showMap() {
		if (mapTimeoutId) {
			window.clearTimeout(mapTimeoutId);
		}		
		var basicInfoBox = document.getElementById("basicInfoBox");
		basicInfoBox.style.zIndex = 100;
		var mapBox = document.getElementById(postMapBoxId)
		mapBox.style.zIndex = 100;
		var mapBox = document.getElementById(mapBoxClientID);		
		mapBox.style.display = "block";
		mapBox.style.visibility = "visible";
		
		var mapArrow = document.getElementById("mapArrow");
		mapArrow.style.display = "block";
		mapArrow.style.visibility = "visible";
		mapArrow.style.right = "-21px";
		
		//adjust map control button
		var mapCtrolBox = document.getElementById("mapCtrlBox");
			    //if sgmap
		if (isSGMap) {
		    if (document.all) {
		        
		    } else {
		        mapCtrolBox.style.marginTop = "260px";                
            }
            mapCtrolBox.style.marginLeft = "199px";
		} else {		 
		    var pattern = /lang=[^&]+/;
		    var result = pattern.exec(window.location.href);
		    if (result) {
		        //en-us
		        mapCtrolBox.style.paddingLeft = "186px";		    
		    } else {
		        //zh-hk
		        mapCtrolBox.style.paddingLeft = "196px";
		    }
		}
	}
	
	function hideMap(delay) {
		mapTimeoutId = window.setTimeout(function() {
		   var mapBox = document.getElementById(mapBoxClientID);
			mapBox.style.display = "none";
			mapBox.style.visibility = "hidden"; 
			var mapArrow = document.getElementById("mapArrow");
		    mapArrow.style.display = "none";
		    mapArrow.style.visibility = "hidden";
		    var basicInfoBox = document.getElementById("basicInfoBox");
		    basicInfoBox.style.zIndex = 0;
		    var mapBox = document.getElementById(postMapBoxId)
		    mapBox.style.zIndex = 0;
		}, delay);            
	}
	
	function showObjV1(objId) {
	    var obj = document.getElementById(objId);
	    if (obj) {
	        obj.style.display = "block";
	        obj.style.visibility = "visible";
	    }
	}
	
	function hideObjV1(objId) {
	    var obj = document.getElementById(objId);
	    if (obj) {
	        obj.style.display = "none";
	        obj.style.visibility = "hidden";
	    }
	}
	
	var moreInfoTimeoutId;
	function showMoreInfo() {
	    if (moreInfoTimeoutId) {
	        window.clearTimeout(moreInfoTimeoutId);
	    }
	    var moreInfoImage = document.getElementById("moreInfoImage");        
        moreInfoImage.src = moreInfoImageOpened;       
        showObjV1("moreInfoBox");
	}	
	
	function hideMoreInfo(delay) {	    
	    moreInfoTimeoutId = window.setTimeout(function() {	        
	        var moreInfoImage = document.getElementById("moreInfoImage");	    
            moreInfoImage.src = moreInfoImageClosed;
            hideObjV1("moreInfoBox");
	    }, delay);               
	}
	
	var relatedAdTimeoutId;
    function showRelatedAd() {
	    if (relatedAdTimeoutId) {
	        window.clearTimeout(relatedAdTimeoutId);
	    }
        showObjV1("divRelatedAd_c");
	}	
	
	function hideRelatedAd(delay) {
	    relatedAdTimeoutId = window.setTimeout(function() {
	        hideObjV1("divRelatedAd_c");
	    }, delay);               
	}
	
	var paypalTimeoutId;
    function showPaypal() {
        var payPalBox = document.getElementById("payPalBox");  
        payPalBox.style.display = "block";
        DB88.PayPalWindow = new YAHOO.widget.Panel("payPalBox", {
            fixedcenter: true,   
            close: false,                     
            visible: false, 
            modal: true, 
            width: 300,
            draggable: false,
            zIndex: 8889,
            constraintoviewport: true,   
            underlay: "none"   
        });             
        DB88.PayPalWindow.render(document.body);  
        DB88.PayPalWindow.showEvent.subscribe(function() {
            document.getElementById("tbPrice").value = "";
        });
        DB88.PayPalWindow.show();            
        
        var closeButton = document.getElementById("btnClosePaypal");
        closeButton.onclick = function() {
            DB88.PayPalWindow.hide();
            payPalBox.style.display = "none";
        };        
    }
    
    function hidePaypal(delay) {
        paypalTimeoutId = window.setTimeout(function() {
            hideObjV1("paypalBox");
        }, delay);
    }
    
    function payment() {
        var price = document.getElementById("tbPrice").value.replace(/(^\s*)|(\s*$)/g,'');
        if (price == "") {
            return;
        }         
        var href = paypalUrl + price;
        window.open(href);
    }

    function onPayPalKeyPress(e) {
	    var key = window.event ? e.keyCode : e.which;
    	
	    //Backspace and dot
	    if (key == 8 || key == 37 || key == 38 || key == 39 || key == 40 || key ==0) return true;
	    var oTB = e.srcElement ? e.srcElement : e.currentTarget;
        if (key == 48) {        
            var str = oTB.value.replace(/(^\s*)|(\s*$)/g,'');
            if (str == "") return false;
        }

        if (key == 46) {
            var str = oTB.value.replace(/(^\s*)|(\s*$)/g,'');
            if (str == "") return false;
            var hasOneDot = false;
	        var reg = /\./g;	    
	        var arrDot = str.match(reg);
	        if (arrDot) {
	            hasOneDot = arrDot.length > 0 ? true : false; 
	        }
	        return !hasOneDot;
        }
        var keychar = String.fromCharCode(key);
        reg = /\d/;
        return reg.test(keychar);
    }

    var fea1 = "";
    var content = "";   
    var tempStorageOfPopup = "";
    function showEmailToFriendPopup()
    {
        if (isMasterDisabled != 1) {  
            var str = '';     
            str += '        <font color="#ff850a"><b>' + emailAdToFriendTitle + '</b></font>';
		    str += '        <br>' + emailAdToFriend_Content1 + '<br>';
		    str += '        <br><textarea class="FormTextAreaS" style="width:23em;" name="FriendEmailAddresses" ID="FriendEmailAddresses" ></textarea>';
		    str += '        <br>' + emailAdToFriend_Content2;		     
            str += '   <br><br><input type="button" value="' + submitText  + '" onClick="submitEmailToFriend();return true;" class="Button">';
            str += '   <input type="button" value="' + cancelText + '" onClick="YAHOO.example.container.sendEmailWindow.destroy();YAHOO.example.container.sendEmailWindow = null;" class="Button">';
            str += '   <br>';
            YAHOO.example.container.sendEmailWindow = createDialog("Email", str, true, "302px", null);
            content = YAHOO.example.container.sendEmailWindow.body.innerHTML;      
            YAHOO.example.container.sendEmailWindow.show();           
        } 
    }

    function submitEmailToFriend() {
        var feaCtrl = document.getElementById("FriendEmailAddresses");
        var fea = feaCtrl.value;
        fea1 = feaCtrl.value;
    
        tempStorageOfPopup = document.getElementById("overlay").innerHTML;        
        if( fea.length == 0 ) {
            var str = '';        
            str += '   <br><b>' + requiredFieldValidatorFriendEmailAddress + '</b><br>';          
            str += '   <br><br><input type="button" value="' + closeText + '" onClick="YAHOO.example.container.sendEmailWindow.setBody(content);" class="Button">';
            str += '   <br>';     
            YAHOO.example.container.sendEmailWindow.setBody(str); 
            return;
        } else if( fea.length > 200 ) {
            var str = '';         
            str += '   <br><b>' + inputAtMost200CharacterMessage + '</b><br>';          
            str += '   <br><br><input type="button" value="' + closeText + '" onClick="YAHOO.example.container.sendEmailWindow.setBody(content);" class="Button">';
            str += '   <br>';
            YAHOO.example.container.sendEmailWindow.setBody(str);
            return;
        }
       
        var eas = fea.split(",");
        for( var i = 0; i < eas.length; ++i ) {
            var ea = eas[i];
            ea = trimAll(ea);
            if( !checkMail(ea) ) {
                var str = '';         
                str += '   <br><b>' + atLeast1InvalidEmailMessage + '</b><br>';          
                str += '   <br><br><input type="button" value="' + closeText + '" onClick="YAHOO.example.container.sendEmailWindow.setBody(content);" class="Button">';
                str += '   <br>';
                YAHOO.example.container.sendEmailWindow.setBody(str);
                return;
            }
        }
        document.getElementById(EmailToFriend_FriendEmailAddressesClientID).value = document.getElementById("FriendEmailAddresses").value;        
        document.getElementById("aspnetForm").submit();
    }
    
    function checkMail(ea) {
	    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	    if (filter.test(ea)) {
	        return true;
	    } else {
	        return false;
	    }
    }
    
    function trimAll(sString) {
        while (sString.substring(0,1) == ' ') {
            sString = sString.substring(1, sString.length);
        }
        while (sString.substring(sString.length-1, sString.length) == ' ') {
            sString = sString.substring(0,sString.length-1);
        }
        return sString;
    }
    
    function AddFavPost(pid, eventObj, ps) {
        eventObj = eventObj ? eventObj : (window.event ? window.event : null);    
        var DateObj = new Date();
        var url = "ConfirmPopup.aspx?Caption=" + addToFavoriteCaptionText + "&OKAction=OpenAddFavAdPopup(" + pid + "," + eventObj.clientX
                        + "," + eventObj.clientY + "," + ps + ");&CurrentDateTime"+DateObj.getMilliseconds();    
        loadpage('PopupDetailLayer',GetContainLangUrl(url));  
        var popup = document.getElementById("PopupDetailLayer");
        popup.style.posTop = eventObj.clientY + document.body.scrollTop - 140;
        popup.style.posLeft =eventObj.clientX + document.body.scrollLeft + 30;
        popup.style.top = eventObj.clientY + document.body.scrollTop - 140;
        popup.style.left = eventObj.clientX + document.body.scrollLeft + 30;
        popup.style.display = "block";
        popup.style.visibility = "visible";
    }

    function OpenAddFavAdPopup(pid, cx, cy, ps) {
        var DateObj = new Date();
        var url = "AddFavADPopup.aspx?PostID="+pid+"&CurrentDateTime"+DateObj.getMilliseconds() + "&ps=" +ps;
        loadpage('PopupDetailLayer',GetContainLangUrl(url));    
        var popup = document.getElementById("PopupDetailLayer");
        popup.style.posTop = cy + document.body.scrollTop - 140;
        popup.style.posLeft = cx + document.body.scrollLeft + 30;
        popup.style.top = cy + document.body.scrollTop - 140;
        popup.style.left = cx + document.body.scrollLeft + 30;
        popup.style.display = "block";
        popup.style.visibility = "visible";  
    }
    
    function RateThisPost() {
        loginOnClick('false', canRatePostMessage, '');
    }    
    
    function showMediaWindow(mediaBoxId, closedId) {
        var mediaBox = document.getElementById(mediaBoxId);
        var boxWidth  = parseInt(mediaBox.style.width, 0);
        showObjV1(mediaBoxId);        
        var mediaWindow = new YAHOO.widget.Panel(mediaBoxId, {
            fixedcenter: true,   
            close: false,                     
            visible: false, 
            modal: true, 
            width: boxWidth,
            draggable: false,
            zIndex: 8889,
            constraintoviewport: true,   
            underlay: "none"   
        });  
        mediaWindow.render(document.body);                
        mediaWindow.show();
        if (document.getElementById(closedId)) {   
            YAHOO.util.Event.on(closedId, "click", function() {                    
                mediaWindow.hide(); 
            });                          
        }
    }      
    
    function gotoReply() {
        ShowObj('replyCommentDiv');
        if (window.location.href.indexOf("#PostReply") == -1) {
            window.location.href += '#PostReply';        
        } else {
            window.location.href = window.location.href;
        }
    }


    function postVoteLogin() {
        document.getElementById("hidPostVoteLogin").value = viewPostId;
        loginOnClick('false', postVoteSuccessMessage, '');
    }
  
    function postVote() {
        if(document.getElementById('PostAttributes')!=null)
        {
	        loadpage('PostAttributes', postVoteUrl);
        }
     }


//-----------------end post info--------------------------

//for Message replay
function ShowObj(objId)
{
    var obj = document.getElementById(objId);
    if(obj != null)
    {
        obj.style.display = "block";
    }
    return;
}

function HiddenObj(objId)
{
    var obj = document.getElementById(objId);
    if(obj != null)
    {
        obj.style.display = "none";
    }
    return;
}

function ShowAndHiddenObj(showId,hidId)
{
    var hidobj = document.getElementById(hidId);
    var showobj = document.getElementById(showId);
    if(hidobj != null && showobj != null)
    {
        hidobj.style.display = "none";
        showobj.style.display = "block";
    }
    return;
}

function SubmitReplyToMessage(postCommentID,submitBtnClientID)
{
    //check date
    var replyToIDObj = document.getElementById("replyToID");
    var replyToContentObj = document.getElementById("replyToContent");
    var replyToIsPrivateObj = document.getElementById("replyToIsPrivate");
    var replyToMemberIDObj = document.getElementById("replyToMemberID");
    replyToIDObj.value = postCommentID;
    replyToContentObj.value = document.getElementById("textarea_" + postCommentID).value;
    var msgObj = document.getElementById("prmsg_" + postCommentID);
    replyToIsPrivateObj.value = msgObj == null ? "0" : document.getElementById("prmsg_" + postCommentID).checked ? "1" : "0";
    replyToMemberIDObj.value = document.getElementById("commentMemberID_" + postCommentID).value;
    
    document.getElementById(submitBtnClientID).click();
}
function ClearData()
{
    var obj = document.getElementById(textAreaClientID);
    if(obj != null)
    {
        obj.value = "";
    }
    CheckMaxInput(textAreaClientID,textAreaMaxLength,"leavingsCharacter");
    return;
}
function ResetReplyToMessage(id)
{
    var replyTextArea = document.getElementById("textarea_" + id);
    if(replyTextArea != null)
    {
        replyTextArea.value = "";
    }
    CheckMaxInput("textarea_" + id,textAreaMaxLength,"leavingsCharacter_" + id);
    return;
}
function CheckMaxInput(checkInputObjId,maxLength,errorObjId)
{
    
    var checkInputObj = document.getElementById(checkInputObjId);
    var errorObj = document.getElementById(errorObjId);
    var textarea_color = checkInputObj.style.color.toLowerCase();
    textarea_color = ColorToHex(textarea_color);
    //if(textarea_color == "#c0c0c0" || textarea_color == "rgb(192, 192, 192)")
    if(textarea_color == silverHexColor)
    {
        errorObj.innerHTML = maxLength;
        
        return;
    }
    
    var currentlength = checkInputObj.value.length;
    var realCharacterLength = currentlength;
    var objStr = checkInputObj.value;
    var j = 0;
    for(i = 0;i < currentlength;i++)
    {
        if(objStr.charCodeAt[i] < 0 || objStr.charCodeAt[i] > 161)
        {
            realCharacterLength += 1;
            if(i < maxLength)
            {
                j += 1;
            }
        }
    }
    if(realCharacterLength > maxLength)
    {
        checkInputObj.value = objStr.substring(0,maxLength - 1);
        errorObj.innerHTML = "0";
    }else{
        errorObj.innerHTML = (maxLength - realCharacterLength);
    }
}

/*function CheckCommentValue()
{
    var obj = document.getElementById(textAreaClientID);
    if(obj)
    {
        if(obj.value == warningMessageToSender)
        {
            obj.style.color = "#C0C0C0";
        }else if(obj.value == ""){
            obj.value = warningMessageToSender;
            obj.style.color = "#C0C0C0";
        }else{
            obj.style.color = "#000000";
        }
    }
    return;
}*/

function CheckCommentValueById(objId)
{
    var obj = document.getElementById(objId);
    if(obj)
    {
        if(obj.value == warningMessageToSender)
        {
            obj.style.color = silverHexColor;
            //obj.style.color = "#C0C0C0";
        }else if(obj.value == ""){
            obj.style.color = silverHexColor;
            //obj.style.color = "#C0C0C0";
            obj.value = warningMessageToSender;
        }else{
            //obj.style.color = "#000000";
            obj.style.color = blackHexColor;
        }
    }
    return;
}

function CheckWarningMessage(objId)
{
    var obj = document.getElementById(objId);
    if(obj)
    {
        if(obj.value == warningMessageToSender || obj.value == "")
        {
            obj.value = "";
            //obj.style.color = "#000000";
            obj.style.color = blackHexColor;
        }
    }
    return;
}
function CheckIsWarningMessage(objId)
{
    var obj = document.getElementById(objId);
    if(obj)
    {
        if(obj.value == warningMessageToSender)
        {
            obj.value = "";
        }
    }
    return;
}

function ColorToHex(rgbColor)
{
    rgbColor = rgbColor.toLowerCase();
    if(rgbColor.indexOf("rgb(") == -1)
    {
        return rgbColor;
    }
    var rgbArr = rgbColor.replace("rgb(","").replace(")","").split(",");
    var r,g,b;
    r = parseInt(rgbArr[0]).toString(16);
    g = parseInt(rgbArr[1]).toString(16);
    b = parseInt(rgbArr[2]).toString(16);
    r = r.length == 1 ? ('0' + r) : r;
    g = g.length == 1 ? ('0' + g) : g;
    b = b.length == 1 ? ('0' + b) : b;
    var hexColor = "#" + r + g + b;
    return hexColor.toLowerCase();
}

//slow show div

var intervalFunc = null;
var intervalMessageBoxFunc = null;
var intervalRelativeADFunc = null;
var intervalMoreInfoFunc = null;
function slowShowDiv(innerDivId,slowshowDivId,span,interval,type)
{
	var obj_inner = document.getElementById(innerDivId);
	obj_inner.style.display = "block";
	var obj_outer = document.getElementById(slowshowDivId);
	obj_outer.style.display = "block";
	//obj_outer.style.height = "1px";
	//var maxHeight = obj_inner.offsetHeight;
	var maxHeight = obj_inner.scrollHeight;
	var spanHeight = span;
	var interval = interval;
	var nowHeight = 0;
	if(spanHeight > 0){
	    if(obj_outer.style.height)
	    {
	        nowHeight = parseInt(obj_outer.style.height);
	        if(nowHeight >= maxHeight)
	        {
	            return;
	        }
	    }
	    obj_inner.style.marginTop = (-1) * maxHeight + "px";
	}else{
	    if(obj_outer.style.height)
	    {
	        nowHeight = parseInt(obj_outer.style.height);
	        if(nowHeight < 0)
	        {
	            return;
	        }
	    }
	    obj_inner.style.marginTop = maxHeight + "px";
	}
	if(type == "messagebox"){
	    window.clearInterval(intervalMessageBoxFunc);
	    intervalMessageBoxFunc = null;
	    intervalMessageBoxFunc = window.setInterval(function(){
							    intervalSlowShow(innerDivId,slowshowDivId,maxHeight,spanHeight,type);
						    },
						    interval);
    }else if(type == "relativead"){
        window.clearInterval(intervalRelativeADFunc);
        intervalRelativeADFunc = null;
        intervalRelativeADFunc = window.setInterval(function(){
							    intervalSlowShow(innerDivId,slowshowDivId,maxHeight,spanHeight,type);
						    },
						    interval);
    }else if(type == "moreinfo"){
        window.clearInterval(intervalMoreInfoFunc);
        intervalMoreInfoFunc = null;
        intervalMoreInfoFunc = window.setInterval(function(){
							    intervalSlowShow(innerDivId,slowshowDivId,maxHeight,spanHeight,type);
						    },
						    interval);
    }
    
}

function intervalSlowShow(innerObjId,objId,maxHeight,spanHeight,type)
{
	var innerObj = document.getElementById(innerObjId);
	var obj = document.getElementById(objId);
	var nowHeight = 1;
	if(obj.style.height){
		nowHeight = parseInt(obj.style.height);
	}else{
		nowHeight = 1;
	}
	var changeHeight = nowHeight + spanHeight;
	if(spanHeight > 0){
	    if(changeHeight < maxHeight)
	    {
		    obj.style.height = changeHeight + "px";
		    innerObj.style.marginTop = (changeHeight - maxHeight) + "px";
		    //innerObj.style.marginBottom = (maxHeight - changeHeight) + "px";
	    }else{
	        obj.style.height = maxHeight + "px";
	        innerObj.style.marginTop = 0 + "px";
	        if(type == "messagebox"){
	            window.clearInterval(intervalMessageBoxFunc);
	            intervalMessageBoxFunc = null;
	        }else if(type == "relativead"){
	            window.clearInterval(intervalRelativeADFunc);
	            intervalRelativeADFunc = null;
	            //document.getElementById('ImgClose').style.visibility='visible';
	            document.getElementById('ImgClose').parentNode.style.cursor='pointer';
	        }else if(type == "moreinfo"){
	            window.clearInterval(intervalMoreInfoFunc);
	            intervalMoreInfoFunc = null;
	        }
	    }
    }else{
        if(changeHeight > 0)
        {
            obj.style.height = changeHeight + "px";
	        innerObj.style.marginTop = (changeHeight - maxHeight) + "px";
        }else{
            obj.style.height = "0px";
            innerObj.style.marginTop = maxHeight + "px";
            obj.style.display = "none";
            if(type == "messagebox"){
	            window.clearInterval(intervalMessageBoxFunc);
	            intervalMessageBoxFunc = null;
	        }else if(type == "relativead"){
	            window.clearInterval(intervalRelativeADFunc);
	            intervalRelativeADFunc = null;
	            //document.getElementById('ImgClose').style.visibility='hidden';
	            document.getElementById('ImgClose').parentNode.blur();
	            document.getElementById('ImgClose').parentNode.style.cursor='pointer';
	        }else if(type == "moreinfo"){
	            window.clearInterval(intervalMoreInfoFunc);
	            intervalMoreInfoFunc = null;
	        }
        }
    }
}

function hidSlowShowDiv(objId)
{
    var obj = document.getElementById(objId);
    if(obj)
    {
        obj.style.display = "none";
        obj.style.height = "1px";
    }
}

function setObjectPaddingByObjId(objId,paddingLen,direction)
{
    var obj = document.getElementById(objId);
    if(!obj) return;
    var paddingLenPx = parseInt(paddingLen) + "px";
    var direction = direction.toLowerCase();
    var dirArr = direction.split(',');
    for(i = 0;i < dirArr.length;i++)
    {
        var temdirection = dirArr[i];
        switch(temdirection)
        {
            case "left" :
            case "l" :
                obj.style.paddingLeft = paddingLenPx;
                break;
            case "right" :
            case "r" :
                obj.style.paddingRight = paddingLenPx;
                break;
            case "top" :
            case "t" :
                obj.style.paddingTop = paddingLenPx;
                break;
            case "bottom":
            case "b":
                obj.style.paddingBottom = paddingLenPx;
                break;
        }
    }
}

var setTimeFunVal = null;
function setTimeFun(innerDivId,outerDivId,span,interval,type,hidImgId)
{
	setTimeFunVal = window.setTimeout(function(){
	    var moreInfoImage = document.getElementById(hidImgId);	    
        moreInfoImage.src = moreInfoImageClosed;
		slowShowDiv(innerDivId,outerDivId,span,interval,type);
	},100);
}

function clearTimeFun()
{
	window.clearTimeout(setTimeFunVal);
	setTimeFunVal = null;
}

//--------------contact now---------------------------------

var contactSelectBox;
var emailContactBox;
var smsContactBox;

function getEl(objId) {
    return document.getElementById(objId);
}

function createContactBox(objId) {
    var box = createBox(objId);
    box.subscribe("show", function() {
        var container = getEl(this.id);
        container.className = "overlayContainer yui-panel-container";
    });
    return box;
}

function showContactSelectBox() {
    getEl("contactSelectBox").style.display = "block";
    if (!contactSelectBox) {
        contactSelectBox = createContactBox("contactSelectBox");        
    }          
    contactSelectBox.show();        
    getEl("btnCloseContactSelectBox").onclick = function() {
        contactSelectBox.hide();
    }
}


function showEmailContactBox() {  
    getEl("emailContactBox").style.display = "block";
    if (!emailContactBox) {
        emailContactBox = createContactBox("emailContactBox");        
    }
    var imgCode = document.getElementById("imgCode");
    if (imgCode) {
        imgCode.src = "";
        var src = "ValidCode.aspx?SessionID=";
        if(sessionMailID != null)
        {
            src += sessionMailID;
        }
        imgCode.src = src + "&t=" + (new Date()).getTime();
    }
    YAHOO.util.Event.on("btnCancelEmail", "click", function() {
        emailContactBox.hide();
    });    
    emailContactBox.show(); 
    contactSelectBox.hide();
}

function restoreEmailContactBox() {
    contactBoxBody.innerHTML = contactBodyHtml;
}

function sendContactMessage() {    
    var yourName = "";
    var yourEmail = ""
    var verificationCode = "";
    var emailContent = getEl("taEmailContent").value;
    
    var requiredYourNameMessage = "";
    var requiredYourEmailMessage = "";
    var requiredVerificationCodeMessage = "";
    var requiredEmailContentMessage = document.getElementById("requiredEmailContentLabel").innerHTML;        
    var requiredMessageContainerHtml = document.getElementById("requiredMessageContainer").innerHTML;    
    var wrongEmailFormat = document.getElementById("wrongEmailFormat").innerHTML;
    
    var isAuthenticated = getEl("hfIsAuthenticated").value == "true";    
    if (!isAuthenticated) {      
        yourName = getEl("tbYourName").value;
        yourEmail = getEl("tbYourEmail").value;                                
        verificationCode = getEl("tbVerificationCode").value;
        if (yourName == "") {
            requiredYourNameMessage = document.getElementById("requiredYourNameLabel").innerHTML;            
            requiredYourNameMessage = requiredMessageContainerHtml.replace("[#Content]", requiredYourNameMessage);
            showModalMessage(requiredYourNameMessage, emailContactBox);
            return;
        }
        if (yourEmail == "") {
            requiredYourEmailMessage = document.getElementById("requiredYourEmailLabel").innerHTML;
            requiredYourEmailMessage = requiredMessageContainerHtml.replace("[#Content]", requiredYourEmailMessage);
            showModalMessage(requiredYourEmailMessage, emailContactBox);            
            return;
        }
        var email_re = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
        if (!email_re.test(yourEmail))
        {
            requiredYourEmailMessage = requiredMessageContainerHtml.replace("[#Content]", wrongEmailFormat);
            showModalMessage(requiredYourEmailMessage, emailContactBox);
            return;
        }
        if (verificationCode == "") {
            requiredVerificationCodeMessage = document.getElementById("requiredVerificationCodeLabel").innerHTML;
            requiredVerificationCodeMessage = requiredMessageContainerHtml.replace("[#Content]", requiredVerificationCodeMessage);
            showModalMessage(requiredVerificationCodeMessage, emailContactBox);            
            return;   
        }        
        getEl("hfYourName").value = yourName;
        getEl("hfYourEmail").value = yourEmail;
        getEl("hfVerificationCode").value = verificationCode;
    }
    if (emailContent == "") {
        requiredEmailContentMessage = requiredMessageContainerHtml.replace("[#Content]", requiredEmailContentMessage);
        showModalMessage(requiredEmailContentMessage, emailContactBox);            
        return;
    }
    getEl("hfEmailContent").value = emailContent;    
    var form = document.getElementById("aspnetForm");
    form.submit();
}

function showSMSContactBox() {
    getEl("SMSContactBox").style.display = "block";    
    clearData(getEl("SMSContactBox"))
    if (!smsContactBox) {
        smsContactBox = createContactBox("SMSContactBox");        
    }
    resetCheckCode("imgSMSCode");
    YAHOO.util.Event.on("btnCancelSMS", "click", function() {
        smsContactBox.hide();
    });    
    smsContactBox.show(); 
    if (contactSelectBox) contactSelectBox.hide();
}

function checkSMSData() {
    var result = true;
    
    var SMSYourName = getEl("tbSMSYourName"); 
    var SMSYourMobile = getEl("tbSMSYourMobile");
    var SMSYourEmail = getEl("tbSMSYourEmail");
    var SMSVerifyCode = getEl("tbSMSVerifyCode");
    var SMSMessage = getEl("taSMSMessage");
    
    if (SMSYourName.value == "" || SMSYourMobile.value == "" || (SMSYourEmail && SMSYourEmail.value == "") || SMSMessage.value == "" 
             || (SMSVerifyCode && SMSVerifyCode.value == ""))
    {
        result = false;
    }
    
    return result;
}

function sendSMS() {
    
    if (checkSMSData()) {
        var postUrl = "../Views/AjaxPage/SendSMS.aspx";
        var ajaxPost = new AjaxPost("SMSContactBox", postUrl);
                        
        var smsEmail = document.getElementById("tbSMSYourEmail");
        if (smsEmail && smsEmail.value != "" && !isEmail(smsEmail.value)) {    
            showPrompt(emailFormatIncorrect);
            return;
        }
        
        var btnResend = getEl("btnSendSMS");
        btnResend.disabled = true;
        var waitingMessage = getEl("sendSMSWaitingMessage");
        waitingMessage.style.display = "block";
        waitingMessage.innerHTML = waitingText;
        var sendButton = document.getElementById("btnSendSMS");
        sendButton.disabled = true;

        var postUrl = "./AjaxPage/SendSMS.aspx";
        var ajaxPost = new AjaxPost("SMSContactBox", postUrl);
        
        ajaxPost.onSuccess = function(xmlHttp) {         
			var sendSuccessFlag = "send success"; 
            var checkCodeMismatchFlag = "Verify code mismatch";
            var sendFailureFlag = "send failure";
            var emailNotRegisterFlag = "email not register";
            var quotaNotEnoughFlag = "quota not enough";
            var SMSErrorFlag = "SMSError:";
            
            var responseText = xmlHttp.responseText;      
			if (responseText.indexOf(sendSuccessFlag) != -1) {
                //success
                showPrompt(submitSuccessText);  
                smsContactBox.hide();    
			} else if (responseText.indexOf(checkCodeMismatchFlag) != -1) {
                showPrompt(verifyCodeMismatch);                  
            } else if (responseText.indexOf(sendFailureFlag) != -1) {
                showPrompt(submitFailureText);                  
            } else if (responseText.indexOf(emailNotRegisterFlag) != -1) {
                showPrompt(emailNotRegisterText);                
            } else if (responseText.indexOf(SMSErrorFlag) != -1) {
                var pattern = /SMSError:#.+#/i;
                var result = pattern.exec(responseText);                                
                var smsErrorMessage = result[0];
                smsErrorMessage = smsErrorMessage.replace(/#/g, "");
                showPrompt(smsErrorMessage);
            } else if (responseText.indexOf(quotaNotEnoughFlag) != -1) {
                showPrompt(quotaNotEnoughText);                
            } else {         
                showPrompt(submitFailureText);  
                //smsContactBox.hide();                 
            }     
            resetCheckCode("imgSMSCode"); 
            waitingMessage.style.display = "none";
            sendButton.disabled = "";                        
        };
        
        ajaxPost.onFailure = function(xmlHttp) {
            resetCheckCode("imgSMSCode");
            waitingMessage.style.display = "none";
            sendButton.disabled = "";
            showPrompt(submitFailureText);
        };
        
        ajaxPost.post();
    } else {
        showPrompt(requiredFieldPromptText);
    }
}

//--------------end contact now-----------------------------


function toggleRelatedImage() {
    var path = "../images/";
    var closeImage = "icon_close.gif";
    var openImage = "icon_arrow_details_right.gif";
    var imgClose = document.getElementById('ImgClose'); 
    if (imgClose.src.indexOf(openImage) != -1) { 
        imgClose.src = path + closeImage; 
    } else {
        imgClose.src = path + openImage;
    };
    imgClose.style.display = "block";
    imgClose.style.visibility = "visible";
}

function getCheckCodeAndDisplay(url,imgId)
{
    var d = new Date();
    url += "?currTime=" + d.getTime();
    var objImg = document.getElementById(imgId);
    if(objImg)
    {
        objImg.src = url;
        objImg.style.display = '';
    }
}
/* special for CheckCode Error */
function showModalCheckCodeError(content,username,email,mailcontent) {
    var win = CreateModalCheckCodeError(content, true, true, "280px", null,username,email,mailcontent);
    win.show();
    return win;
}
function CreateModalCheckCodeError(content, modal, lastButtonCancel, width, props,username,email,mailcontent) {     
    var win = createDialog("Information", content, modal, width, props);

    if (lastButtonCancel) {
        var inputs = win.body.getElementsByTagName("input");   
        var buttons = [];
        for (var i in inputs) {                
            if (inputs[i].type == "button") {
                buttons.push(inputs[i]);
            }            
        }        
        if (buttons[buttons.length-1] != null) {               
            YAHOO.util.Event.on(buttons[buttons.length-1], "click", function() {                                         
                win.destroy();    
                document.getElementById("tbYourName").value = username;
                document.getElementById("tbYourEmail").value = email;
                document.getElementById("taEmailContent").value = mailcontent;
                showEmailContactBox();
            });
        }  
    }

    win.hideEvent.subscribe(function() {       
        if (parentWindow && parentWindow instanceof YAHOO.widget.Module) {          
            parentWindow.show();                             
        }         
    });   
    return win;  
}

//------------------------------directory ad----------------------------

var enquiryBox;
var updateInfoBox;
var bizClaimBox;

function showPrompt(message) {
    var body = "";    
    body += '<div style=\"text-align:center;\"><p>' + message + '</p><input type="button" value="' + closeText + '" /></div>';
    var promptBox = showModalMessage(body, null, function() {
        this.hideMask();
        this.cfg.setProperty("zIndex", 9010);
    });
}

function showServiceEnquiryBox() {
    if (getEl("imgEnquiryCode")) {
        resetCheckCode("imgEnquiryCode");    
    }
    document.getElementById("btnCancelEnquiry").onclick = function() {
        enquiryBox.hide();
    }    
    if (!enquiryBox) enquiryBox = createPopupBox("serviceEnquiryBox");            
    clearData(getEl("serviceEnquiryBox"));
    enquiryBox.show();     
    enquiryBox.stackMask();       
}

function checkServiceEnquiry() {
    var result = false;
    
    var yourName = document.getElementById("tbEnquiryYourName");    
    var yourEmail = document.getElementById("tbYourEnquiryEmail");    
    var verificationCode = document.getElementById("tbEnquiryVerificationCode");
    var question = document.getElementById("tbEnquiryQuestion");
    
    if (yourName && yourEmail && verificationCode) {
        if (yourName.value != "" && yourEmail.value != "" && verificationCode.value != "" && question.value != "") {
            result = true;
        }
    } else {
        if (question.value != "") {
            result = true;
        }
    }
        
    return result;
}

function sendServiceEnquiry() {
    
    if (checkServiceEnquiry()) {
        var enquiryEmail = document.getElementById("tbYourEnquiryEmail");
        if (enquiryEmail && !isEmail(enquiryEmail.value)) {    
            showPrompt(emailFormatIncorrect);
            return;
        }
        var waitingMessage = document.getElementById("serviceEnquiryWaitingMessage");
        waitingMessage.style.display = "block";
        var sendButton = document.getElementById("btnSendEnquiry");
        sendButton.disabled = true;

        var postUrl = "./AjaxPage/ServiceEnquiry.aspx";
        var ajaxPost = new AjaxPost("serviceEnquiryBox", postUrl);
        
        ajaxPost.onSuccess = function(xmlHttp) {            
            var checkCodeMismatchFlag = "Verify code mismatch";
            var responseText = xmlHttp.responseText;        
            if (responseText.indexOf(checkCodeMismatchFlag) != -1) {
                showPrompt(verifyCodeMismatch);  
                resetCheckCode("imgEnquiryCode"); 
            } else {         
                enquiryBox.hide();
                showPrompt(submitSuccessText);   
            }     
            waitingMessage.style.display = "none";
            sendButton.disabled = "";                        
        };
        
        ajaxPost.onFailure = function() {
            resetCheckCode("imgEnquiryCode");
            waitingMessage.style.display = "none";
            sendButton.disabled = "";
            showPrompt(submitFailureText);
        };
        
        var postMemberId = document.getElementById("PostMemberId").value;
        ajaxPost.additionalData = "PostMemberId=" + postMemberId;
        ajaxPost.post();
    } else {
        showPrompt(requiredFieldPromptText);
    }
}

var bizPrimaryNo;
var bizPrimaryNoInitialValue;
var bizSecondNo;
var bizSecondNoInitialValue;

function showUpdateInfoBox() {
    if (!updateInfoBox) updateInfoBox = createPopupBox("updateInfoBox");
    YAHOO.util.Event.on("btnCancelUpdate", "click", function() {
        updateInfoBox.hide();
    });    
    
    bizPrimaryNo = getEl("tbBizPrimaryNo");
    if (!bizPrimaryNoInitialValue) {
        bizPrimaryNoInitialValue = bizPrimaryNo.value;
    }
    bizSecondNo = getEl("tbBizSecondNo");
    if (!bizSecondNoInitialValue) {
        bizSecondNoInitialValue = bizSecondNo.value;
    }
    clearData(getEl("updateInfoBox"));
    var infoCategory = getEl("updateInfoCategory");
    var firstItem = infoCategory.options[0];
    infoCategory.options.length = 0;
    infoCategory.options[0] = firstItem;
    
    var primayNoWatermark = new WatermarkText("tbBizPrimaryNo", bizPrimaryNoInitialValue);
    var secondNoWatermark = new WatermarkText("tbBizSecondNo", bizSecondNoInitialValue);   
    
    updateInfoBox.show();    
    document.getElementsByName("bizStatus")[0].checked = true;
}

function checkUpdateInfo() {

    var bizName = document.getElementById("tbBizName").value;
    var bizPrimaryNo = getEl("tbBizPrimaryNo").value;
    var bizSecondNo = getEl("tbBizSecondNo").value;
    var bizAddress = getEl("tbBizAddress").value;
    var channelId = getEl("updateInfoChannel").options[getEl("updateInfoChannel").selectedIndex].value;
    var categoryId = getEl("updateInfoCategory").options[getEl("updateInfoCategory").selectedIndex].value;
    var yourName = getEl("tbBizYourName").value;
    var yourEmail = getEl("tbBizYourEmail").value;
    
    if (bizName.length == 0) {
        showPrompt(requiredBusinessNameText);
        return false;
    }
    
    if ((bizPrimaryNo.length == 0 || bizPrimaryNo == bizPrimaryNoInitialValue) 
                && (bizSecondNo.length == 0 || bizSecondNo == bizSecondNoInitialValue) ) {
        showPrompt(requiredBusinessPhoneText);
        return false;
    }
    
    if (bizAddress.length == 0) {
        showPrompt(requiredAddressText);
        return false;
    }
    
    if (channelId == 0) {
        showPrompt(requiredBusinessChannelText);
        return false;
    }
    
    if (categoryId == 0) {
        showPrompt(requiredBusinessCategoryText);
        return false;
    }
    
    if (yourName.length == 0) {
        showPrompt(requiredBusinessYourNameText);
        return false;
    }
    
    if (yourEmail.length == 0) {
        showPrompt(requiredBusinessYourEmailText);
        return false;
    }
    
    return true;
}

function updateBizInfo() {

    if (checkUpdateInfo()) {
        var yourEmail = getEl("tbBizYourEmail").value;
        if (!isEmail(yourEmail)) {
            showPrompt(emailFormatIncorrect);
            return;
        }
        
        var waitingMessage = document.getElementById("waitingMessage");
        waitingMessage.style.display = "block";
        var sendButton = document.getElementById("btnUpdateInfo");
        sendButton.disabled = true;

        var postUrl = "./AjaxPage/UpdateBizInfo.aspx";
        var ajaxPost = new AjaxPost("updateInfoBox", postUrl);
        
        ajaxPost.onSuccess = function() {
            waitingMessage.style.display = "none";
            sendButton.disabled = "";
            updateInfoBox.hide();
            showPrompt(submitSuccessText);
        };
        
        ajaxPost.onFailure = function() {
            sendButton.disabled = "";
            waitingMessage.style.display = "none";
            showPrompt(submitFailureText);
        };
        var postMemberId = document.getElementById("PostMemberId").value;
        ajaxPost.additionalData = "PostMemberId=" + postMemberId;
        ajaxPost.post();
    }
}

function fillCategory(channel, el) {
    var firstOption = el.options[0];
    el.options.length = 0;
    el.options.add(firstOption);
    for (var i=0; j = channel.length, i<j; i++) {
        var category = channel[i];
        el.options.add(new Option(category.Name, category.Id), el.length);
    }
}

function loadCategoryList(lang) {    
    if (!getEl("CategoryListBox")) {        
        
        var url = "../Handler/ChannelArray.ashx?lang=" + lang; 
        var ajaxGet = new AjaxGet(url, {success: function(xmlHttp) {                        
            var startTagIndex = xmlHttp.responseText.indexOf("<!--");   //remove server exec time      
            var script = xmlHttp.responseText.substr(0, startTagIndex);
            if (window.execScript){        	
	            window.execScript(script);
            }else{        	
                window.setTimeout(script,0);
            }
            //fillCategorySelect(getEl('updateInfoChannel'), getEl('updateInfoCategory'));
            getEl('updateInfoChannel').disabled = "";
            getEl('updateInfoCategory').disabled = "";
        }, failure: function() {
            getEl('updateInfoChannel').disabled = true;
            getEl('updateInfoCategory').disabled = true;
        }});
        ajaxGet.get();
    }
}

function fillCategorySelect(channelSel, categorySel) {
    var channelId = channelSel.options[channelSel.selectedIndex].value;
    var channel = categoryList[channelId];
    if (channel) {
        fillCategory(channel, categorySel);
    } else {
        var firstOption = categorySel.options[0];
        categorySel.options.length = 0;
        categorySel.options.add(firstOption);
    }
}

var claimPrimaryNo;
var claimPrimaryNoInitialValue;
var claimSecondNo;
var claimSecondNoInitialValue;
var claimPersonPrimayNo;
var claimPersonPrimayNoInitialValue;
var claimPersonSecondNo;
var claimPersonSecondNoInitialValue;

function showBizClaimBox() {    
    if (!bizClaimBox) bizClaimBox = createPopupBox("bizClaimBox");        
    YAHOO.util.Event.on("tbCancelClaim", "click", function() {
        bizClaimBox.hide();
    });  
    
    claimPrimaryNo = getEl("tbClaimPrimaryNo");
    if (!claimPrimaryNoInitialValue) {
        claimPrimaryNoInitialValue = claimPrimaryNo.value
    }
    claimSecondNo = getEl("tbClaimSecondNo");
    if (!claimSecondNoInitialValue) {
        claimSecondNoInitialValue = claimSecondNo.value;
    }
    claimPersonPrimayNo = getEl("tbClaimPersonPrimayNo");
    if (!claimPersonPrimayNoInitialValue) {
        claimPersonPrimayNoInitialValue = claimPersonPrimayNo.value;
    }
    claimPersonSecondNo = getEl("tbClaimPersonSecondNo");
    if (!claimPersonSecondNoInitialValue) {
        claimPersonSecondNoInitialValue = claimPersonSecondNo.value;
    }
    clearData(getEl("bizClaimBox"));
    
    var claimPrimaryNoWatermark = new WatermarkText("tbClaimPrimaryNo", claimPrimaryNoInitialValue);
    var claimSecondNoWatermark = new WatermarkText("tbClaimSecondNo", claimSecondNoInitialValue);
    var claimPersonPrimayNoWatermark = new WatermarkText("tbClaimPersonPrimayNo", claimPersonPrimayNoInitialValue);
    var claimPersonSecondNoWatermark = new WatermarkText("tbClaimPersonSecondNo", claimPersonSecondNoInitialValue);
    
    bizClaimBox.show();
    updateInfoBox.hide();
}

function checkUpdateClaimBiz() {
    var result = false;
    
    var bizName = getEl("tbClaimBizName").value;
    var claimPrimaryNo = getEl("tbClaimPrimaryNo").value;
    var claimSecondNo = getEl("tbClaimSecondNo").value;
    var claimAddress = getEl("tbClaimAddress").value;
    var channelId = getEl("claimBizChannel").options[getEl("claimBizChannel").selectedIndex].value;
    var categoryId = getEl("claimBizCategory").options[getEl("claimBizCategory").selectedIndex].value;
    var claimContactPerson = getEl("tbClaimContactPerson").value;
    var claimPersonPrimayNo = getEl("tbClaimPersonPrimayNo").value;
    var claimPersonSecondNo = getEl("tbClaimPersonSecondNo").value;
    var claimPersonEmail = getEl("tbClaimPersonEmail").value;
    
    if (bizName != "" && claimPrimaryNo != "" && claimSecondNo != "" && claimAddress != "" && channelId > 0 && categoryId > 0
                && claimContactPerson != "" && claimPersonPrimayNo != "" && claimPersonSecondNo != "" && claimPersonEmail != "")
    {
        result = true;
    }    
    
    return result;
}

function updateClaimBiz() {

    if (checkUpdateClaimBiz()) {
        var waitingMessage = document.getElementById("claimWaitingMessage");
        waitingMessage.style.display = "block";
        var sendButton = document.getElementById("btnSendClaim");
        sendButton.disabled = true;

        var postUrl = "./AjaxPage/ClaimBiz.aspx";
        var ajaxPost = new AjaxPost("bizClaimBox", postUrl);
        
        ajaxPost.onSuccess = function() {
            waitingMessage.style.display = "none";
            sendButton.disabled = "";
            bizClaimBox.hide();
            showPrompt(submitSuccessText);
        };
        
        ajaxPost.onFailure = function() {
            waitingMessage.style.display = "none";
            sendButton.disabled = "";
            showPrompt(submitFailureText);
        };
        var postMemberId = document.getElementById("PostMemberId").value;
        ajaxPost.additionalData = "PostMemberId=" + postMemberId;
        ajaxPost.post();
    } else {
        showPrompt(requiredFieldPromptText);
    }
}
//----------------------------------------------------------------------------------------------

var deleteCommentBox;
function showDeleteCommentBox(cId, pId) {
    var deleteConfirmMessage = getEl("hdDeleteConfirmMessage").value;
    var okJs = "deletePostComment(" + cId + ", " + pId + ");";

    deleteCommentBox = ModalConfirmMsg(deleteConfirmMessage, okJs);    
}

function deletePostComment(cId, pId) {
    var url = "../Views/AjaxPage/UpdatePostComment.aspx?commentId=" + cId;
    var ajaxGet = new AjaxGet(url, {success: function(xmlHttp) {
        var postMessageUrl = "../Views/GetPostReplayMessage.aspx?PostID=" + pId;
        
        var lang = "";
        var pattern = /lang=[^&,\s]+/;
        var result = pattern.exec(window.location.href);
        if (result) {
            lang = "&" + result;
        }
        
        postMessageUrl = postMessageUrl + lang + "&t=" + (new Date().getTime());                      
        
        var ajax = new AjaxGet(postMessageUrl, {success: function(xmlHttp) {
            getEl("replayMessageAndPaging").innerHTML = xmlHttp.responseText;
            deleteCommentBox.hide();
        }, failure: function(xmlHttp) {
            
        }});
        ajax.get();
        
    }, failure: function(xmlHttp) {
        
    }});
    ajaxGet.get();
}


function showMessageConfirmBox(pId, hide, msg) {
    //var message = document.getElementById("hdMessagePrompt").value;
    var hideMessageJs = "toggleMessageSection(" + pId + ", " + hide + ");" ;
    ModalConfirmMsg(msg, hideMessageJs);    
}

function toggleMessageSection(pId, hide) {
    var url = "../Views/AjaxPage/HidePostMessage.aspx?PostId=" + pId + "&hide=" + hide + "&t=" + (new Date()).getTime();
    
    var ajaxGet = new AjaxGet(url, {success: function(xmlHttp) {
        window.location.href = window.location.href;
    }, failure: function(xmlHttp) {
        
    }});
    ajaxGet.get();
}


//process post title
//if (typeof YAHOO != "undefined") {


 function adjustPostTitle() {
     YAHOO.util.Dom.getElementsByClassName("adDetailTitOver", null, null, function trimDesc(box) {        
            var offset = 4; //2
            if (box.clientHeight + offset < box.scrollHeight) {
                YAHOO.util.Dom.insertAfter("<div class=\"adDetailTitMore\">...</div>", box);
            } else {
                box.style.display = "none";                
                YAHOO.util.Dom.getElementsByClassName("adDetailTit", null, null, function trimDesc(titleTable) { 
                    titleTable.style.display = "block";
                }, null, false);
            }
    }, null, false); 
 }

if (window.addEventListener)
{
    window.addEventListener("load", adjustPostTitle, false);
}
else if (window.attachEvent)
{
    window.attachEvent("onload", adjustPostTitle);
}
else
{
    window.onload=adjustPostTitle;
}
     

        
     



/* build 9004.9 */