﻿var sysWording;
var sysWordingRead = false;
var intSysWordingCheckSpeed = 100;
XML_Reader("Localization.xml", "Localization");
function Localization(xml) {
    sysWording = $("content", xml);
    sysWordingRead = true;
}


function querySt(strName) {
    hu = window.location.search.substring(1);
    var rtn = "";
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0].toUpperCase() == strName.toUpperCase()) {
            rtn = ft[1];
        }
    }
    return rtn;
}

function getURLId() {
    hu = window.location.href.substring(0);
    gy = hu.split("#");
    if (gy[1] != null) {
        return gy[1];
    }
    else {
        return "";
    }
}

function isMultipleLanguageWebsite() {
	return false;
}

function getcookiedata(cookieName) {
    theData = "";
    theCookie = document.cookie + ";";
    start = theCookie.indexOf(cookieName+"=");
    if (start != -1) {
        end = theCookie.indexOf(";", start);
        theData = unescape(theCookie.substring(start + cookieName.length + 1, end));
    }
    return theData.replace(";","");
}

function add_compare_model(cookieName, product_id, model_name) {
    theData = getcookiedata(cookieName);
    if (theData.indexOf(product_id + ".") != -1) {
    }
    else {
        document.cookie = cookieName + "=" + escape(theData + product_id + "." + model_name + ",");
    }
}

function add_cookie(cookieName,cookieContent){
    document.cookie = cookieName + "=" + cookieContent;
}

function remove_compare_model(cookieName, product_id, model_name) {
    theData = getcookiedata(cookieName);
    theData = theData.replace(product_id + "." + model_name + ",", "");
//    if (theData.length == 1) {
//        document.cookie = cookieName + "=" + escape(theData) + ";expires=1990/1/1";
//    }
//    else {
        document.cookie = cookieName + "=" + escape(theData);
//    }
}

function itemcount(strValue) {
    var items = new Array;
    items = strValue.split(",");
    return items.length;
}

var fileIsExistedreturnvalue;
function fileIsExisted(path) {
    var checkCNT=0;
    var objXHR = createAJAX();
    if (!objXHR) return false;
    try {
        objXHR.open("get", path, false);
        objXHR.send(null);
        while (objXHR.readyState != 4 || checkCNT <= 50) {
            checkCNT = checkCNT + 1;
        }
        return (objXHR.status == 200) ? true : false;
    }
    catch (er) {
        return false;
    }
}

function fileIsExisted_onreadystatechange(obj) {
    if (objXHR.readyState == 4) {
        if (objXHR.status == 200) {
            objXHR.onreadystatechange = null;
            return true;
        }
        else {
            return false;
        }
    }
}


function createAJAX(){
    var HttpRequest = false;
    try {
        HttpRequest = new XMLHttpRequest();
        // for almost all browsers. (Maybe included M$IE7)   
    } catch (tryMSIE) {
        try {
            HttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (tryMSIE2) {
            try {
                HttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (NotSupported) {
                HttpRequest = false;
            }
        }
    }
    return HttpRequest;
}

function flash_palyer(strFilename, intHeight, intWidth) {
    var objectflash = "";
    objectflash += "<object codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,12,36' width='" + intWidth + "' height='" + intHeight + "' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'>";
	objectflash += "        <param name='FlashVars' value='' />";
	objectflash += "        <param name='Movie' value='" + strFilename + "' />";
	objectflash += "        <param name='Src' value='" + strFilename + "' />";
	objectflash += "        <param name='WMode' value='Transparent' />";
	objectflash += "        <param name='Play' value='-1' />";
	objectflash += "        <param name='Loop' value='-1' />";
	objectflash += "        <param name='Quality' value='High' />";
	objectflash += "        <param name='SAlign' value='' />";
	objectflash += "        <param name='Menu' value='-1' />";
	objectflash += "        <param name='Base' value='' />";
	objectflash += "        <param name='AllowScriptAccess' value='always' />";
	objectflash += "        <param name='Scale' value='ShowAll' />";
	objectflash += "        <param name='DeviceFont' value='0' />";
	objectflash += "        <param name='EmbedMovie' value='0' />";
	objectflash += "        <param name='BGColor' value='' />";
	objectflash += "        <param name='SWRemote' value='' />";
	objectflash += "        <param name='MovieData' value='' />";
	objectflash += "        <param name='SeamlessTabbing' value='1' />";
	objectflash += "        <param value='false' name='menu' />";
	objectflash += "        <param value='opaque' name='wmode' />";
	objectflash += "        <embed wmode='transparent' flashvars='" + strFilename + "' src='" + strFilename + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + intWidth + "' height='" + intHeight + "'></embed>";
    objectflash += "    </object>";
    return objectflash;
}


//Date Format Functions Begin
Date.prototype.formatDate = function(format) {
    var date = this;
    if (!format)
        format = "yyyy/mm/dd";
    var month = date.getMonth() + 1;
    var year = date.getFullYear();
    format = format.replace("mm", month.toString().padL(2, "0"));

    if (format.indexOf("yyyy") > -1)
        format = format.replace("yyyy", year.toString());
    else if (format.indexOf("yy") > -1)
        format = format.replace("yy", year.toString().substr(2, 2));

    format = format.replace("dd", date.getDate().toString().padL(2, "0"));
    var hours = date.getHours();

    return format;
}

String.prototype.padL = function(width, pad) {
    if (!width || width < 1)
        return this;

    if (!pad) pad = " ";

    var length = width - this.length

    if (length < 1)
        return this.substr(0, width);

    return (String.repeat(pad, length) + this).substr(0, width);
}
String.prototype.padR = function(width, pad) {
    if (!width || width < 1)
        return this;

    if (!pad) pad = " ";

    var length = width - this.length

    if (length < 1) this.substr(0, width);
    return (this + String.repeat(pad, length)).substr(0, width);
}
String.repeat = function(chr, count) {
    var str = "";
    for (var x = 0; x < count; x++) {
        str += chr
    };
    return str;
}

function date_format(da, fo) {

    var date = new Date(da);
    var str = date.formatDate(fo);

    return str;

}

function trim(str) { return str.replace(/(^\s*)|(\s*$)/g, ""); } 
//Date Format Functions End