	var sUserAgent = navigator.userAgent;
	var isKHTML = sUserAgent.indexOf("KHTML") > -1 || sUserAgent.indexOf("Konqueror") > -1 || sUserAgent.indexOf("AppleWebKit") > -1;
	var isOpera = sUserAgent.indexOf("Opera") > -1;
	var isMoz = sUserAgent.indexOf("Gecko") > -1 && !isKHTML;
	var isIE = sUserAgent.indexOf("compatible") > -1 && sUserAgent.indexOf("MSIE") > -1 && !isOpera;

function $(){
	var len = arguments.length;
	var obj;
	if(len > 2 || len < 1){
		alert("error");
		return false;	
	}
	if(arguments[1] == "id" || arguments[1] == undefined)
		obj = document.getElementById(arguments[0]);
	if(arguments[1] == "name")
		obj = document.getElementByName(arguments[0]);
	return obj;
}

function pageinitial(){
	if(isMoz){
		//$("sidebar").style.height = (document.documentElement.clientHeight - 134)+"px";
		$("content").style.width = (document.documentElement.clientWidth - 241)+"px";
		//$("content").style.height = (document.documentElement.clientHeight - 201)+"px";
	}
}

//global variable ReturnAjaxTF
var ReturnAjaxTF = false;

// JavaScript for PHPMaker 3.0
// (C) 2001-2004 e.World Technology Ltd.
var EW_dateSep; // default date separator
if (EW_dateSep == "") EW_dateSep = "/";

function EW_submitForm(EW_this) {
        if (EW_HTMLArea) {
                for (var i=0; i<EW_HTMLArea.length; i++) {
                        var html = EW_HTMLArea[i].getHTML();
                        if (html == "<p />" || html == "<br />\n") html = "";
                        EW_HTMLArea[i]._textArea.value = html;
                }
        }
        if (EW_checkMyForm(EW_this))
                EW_this.submit();
}

function EW_isHTMLArea(input_object, object_type) {
        return (object_type == "TEXTAREA" && EW_HTMLArea && input_object.style && input_object.style.display && input_object.style.display == "none");
}

function EW_onError(form_object, input_object, object_type, error_message) {
        alert(error_message);
        if (object_type == "RADIO" || object_type == "CHECKBOX") {
                if (input_object[0])
                        input_object[0].focus();
                else
                        input_object.focus();
        }        else if (!EW_isHTMLArea(input_object, object_type)) {
                input_object.focus();
        }
        if (object_type == "TEXT" || object_type == "PASSWORD" || object_type == "TEXTAREA" || object_type == "FILE") {
                if (!EW_isHTMLArea(input_object, object_type))
                        input_object.select();
        }
        return false;
}

function EW_hasValue(obj, obj_type) {
        if (obj_type == "TEXT" || obj_type == "PASSWORD" || obj_type == "TEXTAREA" || obj_type == "FILE")        {
                if (obj.value.length == 0)
                        return false;
                else
                        return true;
        }        else if (obj_type == "SELECT") {
                if (obj.type != "select-multiple" && obj.selectedIndex == 0)
                        return false;
                else if (obj.type == "select-multiple" && obj.selectedIndex == -1)
                        return false;
                else
                        return true;
        }        else if (obj_type == "RADIO" || obj_type == "CHECKBOX")        {
                if (obj[0]) {
                        for (i=0; i < obj.length; i++) {
                                if (obj[i].checked)
                                        return true;
                        }
                } else {
                        return (obj.checked);
                }
                return false;
        }
}

// Date (mm/dd/yyyy)
function EW_checkusdate(object_value) {
        if (object_value.length == 0)
                return true;

        isplit = object_value.indexOf(EW_dateSep);

        if (isplit == -1 || isplit == object_value.length)
                return false;

        sMonth = object_value.substring(0, isplit);

        if (sMonth.length == 0)
                return false;

        isplit = object_value.indexOf(EW_dateSep, isplit + 1);

        if (isplit == -1 || (isplit + 1 ) == object_value.length)
                return false;

        sDay = object_value.substring((sMonth.length + 1), isplit);

        if (sDay.length == 0)
                return false;

        isep = object_value.indexOf(' ', isplit + 1);
        if (isep == -1) {
                sYear = object_value.substring(isplit + 1);
        } else {
                sYear = object_value.substring(isplit + 1, isep);
                sTime = object_value.substring(isep + 1);
                if (!EW_checktime(sTime))
                        return false;
        }

        if (!EW_checkinteger(sMonth))
                return false;
        else if (!EW_checkrange(sMonth, 1, 12))
                return false;
        else if (!EW_checkinteger(sYear))
                return false;
        else if (!EW_checkrange(sYear, 0, 9999))
                return false;
        else if (!EW_checkinteger(sDay))
                return false;
        else if (!EW_checkday(sYear, sMonth, sDay))
                return false;
        else
                return true;
}

// Date (yyyy/mm/dd, )
function EW_checkdate(object_value) {
        if (object_value.length == 0)
                return true;

        isplit = object_value.indexOf(EW_dateSep);

        if (isplit == -1 || isplit == object_value.length)
                return false;

        sYear = object_value.substring(0, isplit);

        isplit = object_value.indexOf(EW_dateSep, isplit + 1);

        if (isplit == -1 || (isplit + 1 ) == object_value.length)
                return false;

        sMonth = object_value.substring((sYear.length + 1), isplit);

        if (sMonth.length == 0)
                return false;

        isep = object_value.indexOf(' ', isplit + 1);
        if (isep == -1) {
                sDay = object_value.substring(isplit + 1);
        } else {
                sDay = object_value.substring(isplit + 1, isep);
                sTime = object_value.substring(isep + 1);
                if (!EW_checktime(sTime))
                        return false;
        }

        if (sDay.length == 0)
                return false;

        if (!EW_checkinteger(sMonth))
                return false;
        else if (!EW_checkrange(sMonth, 1, 12))
                return false;
        else if (!EW_checkinteger(sYear))
                return false;
        else if (!EW_checkrange(sYear, 0, 9999))
                return false;
        else if (!EW_checkinteger(sDay))
                return false;
        else if (!EW_checkday(sYear, sMonth, sDay))
                return false;
        else
                return true;
}

// Date (dd/mm/yyyy)
function EW_checkeurodate(object_value) {
        if (object_value.length == 0)
          return true;

        isplit = object_value.indexOf(EW_dateSep);

        if (isplit == -1 || isplit == object_value.length)
                return false;

        sDay = object_value.substring(0, isplit);

        monthSplit = isplit + 1;

        isplit = object_value.indexOf(EW_dateSep, monthSplit);

        if (isplit == -1 ||  (isplit + 1 )  == object_value.length)
                return false;

        sMonth = object_value.substring((sDay.length + 1), isplit);

        isep = object_value.indexOf(' ', isplit + 1);
        if (isep == -1) {
                sYear = object_value.substring(isplit + 1);
        } else {
                sYear = object_value.substring(isplit + 1, isep);
                sTime = object_value.substring(isep + 1);
                if (!EW_checktime(sTime))
                        return false;
        }

        if (!EW_checkinteger(sMonth))
                return false;
        else if (!EW_checkrange(sMonth, 1, 12))
                return false;
        else if (!EW_checkinteger(sYear))
                return false;
        else if (!EW_checkrange(sYear, 0, null))
                return false;
        else if (!EW_checkinteger(sDay))
                return false;
        else if (!EW_checkday(sYear, sMonth, sDay))
                return false;
        else
                return true;
}

function EW_checkday(checkYear, checkMonth, checkDay) {
        maxDay = 31;

        if (checkMonth == 4 || checkMonth == 6 ||        checkMonth == 9 || checkMonth == 11) {
                maxDay = 30;
        } else if (checkMonth == 2)        {
                if (checkYear % 4 > 0)
                        maxDay =28;
                else if (checkYear % 100 == 0 && checkYear % 400 > 0)
                        maxDay = 28;
                else
                        maxDay = 29;
        }

        return EW_checkrange(checkDay, 1, maxDay);
}

function EW_checkinteger(object_value) {
        if (object_value.length == 0)
                return true;

        var decimal_format = ".";
        var check_char;

        check_char = object_value.indexOf(decimal_format);
        if (check_char < 1)
                return EW_checknumber(object_value);
        else
                return false;
}

function EW_numberrange(object_value, min_value, max_value) {
				object_value = 	object_value+"";
				if (object_value.length == 0)
                return true;
        if (!EW_checknumber(object_value))
        				return false;
        if (min_value != null) {
          if (object_value < min_value)
                return false;
        }
				
        if (max_value != null) {
          if (object_value > max_value)
                 return false;
        }

        return true;
}

function EW_checknumber(object_value) {
        if (object_value.length == 0)
                return true;

        var start_format = " .+-0123456789,";
        var number_format = " .0123456789,";
        var check_char;
        var decimal = false;
        var trailing_blank = false;
        var digits = false;

        check_char = start_format.indexOf(object_value.charAt(0));
        if (check_char == 1)
                decimal = true;
        else if (check_char < 1)
                return false;

        for (var i = 1; i < object_value.length; i++)        {
                check_char = number_format.indexOf(object_value.charAt(i))
                if (check_char < 0) {
                        return false;
                } else if (check_char == 1)        {
                        if (decimal)
                                return false;
                        else
                                decimal = true;
                } else if (check_char == 0) {
                        if (decimal || digits)
                        trailing_blank = true;
                }        else if (trailing_blank) {
                        return false;
                } else {
                        digits = true;
                }
        }

        return true;
}

function EW_checkrange(object_value, min_value, max_value) {
        if (object_value.length == 0)
                return true;

        if (!EW_checknumber(object_value))
                return false;
        else
                return (EW_numberrange((eval(object_value)), min_value, max_value));

        return true;
}

function EW_checktime(object_value) {
        if (object_value.length == 0)
                return true;

        isplit = object_value.indexOf(':');

        if (isplit == -1 || isplit == object_value.length)
                return false;

        sHour = object_value.substring(0, isplit);
        iminute = object_value.indexOf(':', isplit + 1);

        if (iminute == -1 || iminute == object_value.length)
                sMin = object_value.substring((sHour.length + 1));
        else
                sMin = object_value.substring((sHour.length + 1), iminute);

        if (!EW_checkinteger(sHour))
                return false;
        else if (!EW_checkrange(sHour, 0, 23))
                return false;

        if (!EW_checkinteger(sMin))
                return false;
        else if (!EW_checkrange(sMin, 0, 59))
                return false;

        if (iminute != -1) {
                sSec = object_value.substring(iminute + 1);
                if (!EW_checkinteger(sSec))
                        return false;
                else if (!EW_checkrange(sSec, 0, 59))
                        return false;
        }

        return true;
}

function EW_checkphone(object_value) {
        if (object_value.length == 0)
                return true;

        if (object_value.length != 12)
                return false;

        if (!EW_checknumber(object_value.substring(0,3)))
                return false;
        else if (!EW_numberrange((eval(object_value.substring(0,3))), 100, 1000))
                return false;

        if (object_value.charAt(3) != "-" && object_value.charAt(3) != " ")
                return false

        if (!EW_checknumber(object_value.substring(4,7)))
                return false;
        else if (!EW_numberrange((eval(object_value.substring(4,7))), 100, 1000))
                return false;

        if (object_value.charAt(7) != "-" && object_value.charAt(7) != " ")
                return false;

        if (object_value.charAt(8) == "-" || object_value.charAt(8) == "+")
                return false;
        else
                return (EW_checkinteger(object_value.substring(8,12)));
}


function EW_checkzip(object_value) {
        if (object_value.length == 0)
                return true;

        if (object_value.length != 5 && object_value.length != 10)
                return false;

        if (object_value.charAt(0) == "-" || object_value.charAt(0) == "+")
                return false;

        if (!EW_checkinteger(object_value.substring(0,5)))
                return false;

        if (object_value.length == 5)
                return true;

        if (object_value.charAt(5) != "-" && object_value.charAt(5) != " ")
                return false;

        if (object_value.charAt(6) == "-" || object_value.charAt(6) == "+")
                return false;

        return (EW_checkinteger(object_value.substring(6,10)));
}


function EW_checkcreditcard(object_value) {
        var white_space = " -";
        var creditcard_string = "";
        var check_char;

        if (object_value.length == 0)
                return true;

        for (var i = 0; i < object_value.length; i++) {
                check_char = white_space.indexOf(object_value.charAt(i));
                if (check_char < 0)
                        creditcard_string += object_value.substring(i, (i + 1));
        }

        if (creditcard_string.length == 0)
                return false;

        if (creditcard_string.charAt(0) == "+")
                return false;

        if (!EW_checkinteger(creditcard_string))
                return false;

        var doubledigit = creditcard_string.length % 2 == 1 ? false : true;
        var checkdigit = 0;
        var tempdigit;

        for (var i = 0; i < creditcard_string.length; i++) {
                tempdigit = eval(creditcard_string.charAt(i));
                if (doubledigit) {
                        tempdigit *= 2;
                        checkdigit += (tempdigit % 10);
                        if ((tempdigit / 10) >= 1.0)
                                checkdigit++;
                        doubledigit = false;
                }        else {
                        checkdigit += tempdigit;
                        doubledigit = true;
                }
        }

        return (checkdigit % 10) == 0 ? true : false;
}


function EW_checkssc(object_value) {
        var white_space = " -+.";
        var ssc_string="";
        var check_char;

        if (object_value.length == 0)
                return true;

        if (object_value.length != 11)
                return false;

        if (object_value.charAt(3) != "-" && object_value.charAt(3) != " ")
                return false;

        if (object_value.charAt(6) != "-" && object_value.charAt(6) != " ")
                return false;

        for (var i = 0; i < object_value.length; i++) {
                check_char = white_space.indexOf(object_value.charAt(i));
                if (check_char < 0)
                        ssc_string += object_value.substring(i, (i + 1));
        }

        if (ssc_string.length != 9)
                return false;

        if (!EW_checkinteger(ssc_string))
                return false;

        return true;
}


function EW_checkemail(object_value) {
        if (object_value.length == 0)
                return true;

        if (!(object_value.indexOf("@") > -1 && object_value.indexOf(".") > -1))
                return false;

        return true;
}

// GUID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
function EW_checkGUID(object_value)        {
        if (object_value.length == 0)
                return true;
        if (object_value.length != 38)
                return false;
        if (object_value.charAt(0)!="{")
                return false;
        if (object_value.charAt(37)!="}")
                return false;

        var hex_format = "0123456789abcdefABCDEF";
        var check_char;

        for (var i = 1; i < 37; i++) {
                if ((i==9) || (i==14) || (i==19) || (i==24)) {
                        if (object_value.charAt(i)!="-")
                                return false;
                } else {
                        check_char = hex_format.indexOf(object_value.charAt(i));
                        if (check_char < 0)
                                return false;
                }
        }
        return true;
}


// Update a combobox with filter value
// object_value_array format
// object_value_array[n] = option value
// object_value_array[n+1] = option text 1
// object_value_array[n+2] = option text 2
// object_value_array[n+3] = option filter value
function EW_updatecombo(obj, object_value_array, filter_value) {
        var value = obj.options[obj.selectedIndex].value;
        for (var i = obj.length-1; i > 0; i--) {
                obj.options[i] = null;
        }
        for (var j=0; j<object_value_array.length; j=j+4) {
                if (object_value_array[j+3].toUpperCase() == filter_value.toUpperCase()) {
                        EW_newopt(obj, object_value_array[j], object_value_array[j+1], object_value_array[j+2]);
                }
        }
        EW_selectopt(obj, value);
}

// Create combobox option
function EW_newopt(obj, value, text1, text2) {
        var text = text1;
        if (text2 != "")
                text += ", " + text2;
        var optionName = new Option(text, value, false, false)
        var length = obj.length;
        obj.options[length] = optionName;
}

// Select combobox option
function EW_selectopt(obj, value) {
        for (var i = obj.length-1; i>=0; i--) {
                if (obj.options[i].value.toUpperCase() == value.toUpperCase()) {
                        obj.selectedIndex = i;
                        break;
                }
        }
}

// Get image width/height
function EW_getimagesize(file_object, width_object, height_object) {
        if (navigator.appVersion.indexOf("MSIE") != -1)        {
                myimage = new Image();
                myimage.onload = function () {
                        width_object.value = myimage.width; height_object.value = myimage.height;
                }
                myimage.src = file_object.value;
        }
}

// Get Netscape Version
function getNNVersionNumber() {
        if (navigator.appName == "Netscape") {
                var appVer = parseFloat(navigator.appVersion);
                if (appVer < 5) {
                        return appVer;
                } else {
                        if (typeof navigator.vendorSub != "undefined")
                                return parseFloat(navigator.vendorSub);
                }
        }
        return 0;
}

// Get Ctrl key for multiple column sort
function ewsort(e, url) {
        var ctrlPressed = 0;
        if (parseInt(navigator.appVersion) > 3) {
                if (navigator.appName == "Netscape") {
                        if (getNNVersionNumber() >= 6)
                                ctrlPressed = e.ctrlKey;
                        else
                                ctrlPressed = ((e.modifiers+32).toString(2).substring(3,6).charAt(1)=="1");
                } else {
                 ctrlPressed = event.ctrlKey;
                }
                if (ctrlPressed) {
                        var newPage = "<scr" + "ipt language=\"JavaScript\">setTimeout('window.location.href=\"" + url + "&ctrl=1\"', 10);</scr" + "ipt>";
                        document.write(newPage);
                        document.close();
                        return false;
                }
        }
        return true;
}

function EW_checklength(object_value, minlength , maxlength){
					if(object_value.length < minlength) return false;
					if(object_value.length > maxlength) return false;
					return true;
}

function EW_checkObjectLength(object_value,checklength){
	if(object_value != "")
	{
		if(object_value.length > checklength)
		{
			return false;
		}
	}
	return true;
}
function EW_checkPasswordLength(object_oldvalue,checklength)
{
	if(object_oldvalue.length < checklength)
	{
		return false;
	}
	return true;
}
function EW_checkPasswordConfirm(object_oldvalue,object_confirmvalue)
{
	if(object_oldvalue != object_confirmvalue)
	{
		return false;
	}
	return true;
}

/*******************Ajax_Script**********************/
/*create ajax object*/
function InitAjax()
{
	//Reputation varisable ajax
	var ajax=false; 
	try
	{ 
		
		ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch (e) 
	{ 
		try 
		{ 
			
			ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
		}
		catch (E) 
		{ 
			
			ajax = false; 
		} 
	}
	
	if (!ajax && typeof XMLHttpRequest!='undefined') 
	{ 
		
		ajax = new XMLHttpRequest(); 
	} 
	//return ajax object
	return ajax;
}

/* Use ajax check unique of data */
function check_email_unique(sEmail)
{
	//set check url
	var url = "../Public/CheckUnique.php?action=email&info="+sEmail;
	//create ajax object
	var ajax = InitAjax();
	var isAsynchronous = false;
	ajax.open("GET", url, isAsynchronous);
	//set function
	if(!isAsynchronous && navigator.userAgent.indexOf("Firefox")>0){
		//set "Get" data
		ajax.send(null);
		//get ajax return value
		ReturnAjaxTF = ajax.responseText;
	}else{
		ajax.onreadystatechange = function (){
			//get status
			if (ajax.readyState == 4 && ajax.status == 200) {
				//get ajax return value
				ReturnAjaxTF = ajax.responseText;
			}
		}
		//set "Get" data
		ajax.send(null);
	}
	//return variable ReturnAjaxTF
	if(parseInt(ReturnAjaxTF) == 1)
		return true;
	else if (parseInt(ReturnAjaxTF) == 0)
		return false;
} 

//get error info
var info = "";
//(ActionID: error number)
function getErrorInfo(ActionID,Argument)
{
	//get the URL, what will be used in Ajax
	var url = "../Public/Error.php?ActionID="+ActionID+"&Argument="+Argument;
	//initail Ajax
	var ajax = InitAjax();
	var isAsynchronous = false;
	//do apply (method:get,address:url,transfer:synchronization)
	ajax.open("GET", url, isAsynchronous);
	//set function
	if(!isAsynchronous && navigator.userAgent.indexOf("Firefox")>0)
	{
		//set "Get" data
		ajax.send(null);
		//get return info
		info = ajax.responseText;
	}
	else
	{
		//get operation status
		ajax.onreadystatechange = function (strErrorMessage)
		{
			//if the status is normal, then return the value
			if (ajax.readyState == 4 && ajax.status == 200) 
			{
				//get ajax return value
				info = ajax.responseText;
			}
		}
		//set "Get" data
		ajax.send(null);
	}
	//return info	
	return info;
} 
function setCheckboxes(the_form, obj, objname)
{
	//check whether boxes are selected
	var do_check;
	if(obj.checked == true)
		do_check = true;
	else
		do_check = false;
	
    var elts = document.forms[the_form].elements[objname];
    if(typeof(elts) != 'undefined')
    {
	    var elts_cnt = (typeof(elts) != 'undefined')? elts.length: 0; 
	    if (elts_cnt > 0) {
	        for (var i = 0; i < elts_cnt; i++) {
	            elts[i].checked = do_check;
	        }
	    } else {
	        elts.checked = do_check;
	    }
    }
    return true;
} 

/*change password*/
function changePassword(u_type,u_id)
{
	var intTop = ((screen.height / 2) - (150 / 2));
	var intLeft = ((screen.width / 2) - (350 / 2));
	var strPath = "../Public/ChangePassword.php?type="+u_type+"&id="+u_id;
	window.open(strPath,'Change_Password', 'width=350, height=150, dependent=yes, scrollbars=no, top='+intTop+', left='+intLeft);
}
function setCheckboxes(the_form, obj, objname)
{
	//check whether boxes are selected
	var do_check;
	if(obj.checked == true)
		do_check = true;
	else
		do_check = false;
	
    var elts = document.forms[the_form].elements[objname];
    if(typeof(elts) != 'undefined')
    {
	    var elts_cnt = (typeof(elts) != 'undefined')? elts.length: 0; 
	    if (elts_cnt > 0) {
	        for (var i = 0; i < elts_cnt; i++) {
	            elts[i].checked = do_check;
	        }
	    } else {
	        elts.checked = do_check;
	    }
    }
    return true;
} 

/*get or set textarea value*/
function getEditorTextContents(strTextareaName)
{
	var objectEditor = FCKeditorAPI.GetInstance(strTextareaName); 
    return(objectEditor.EditorDocument.body.innerText); 
}
function getEditorHTMLContents(strTextareaName)
{ 
	var objectEditor = FCKeditorAPI.GetInstance(strTextareaName); 
    return(objectEditor.GetXHTML(true)); 
}
function setEditorContents(strTextareaName,strContent)
{ 
	var objectEditor = FCKeditorAPI.GetInstance(strTextareaName); 
  objectEditor.SetHTML(strContent);
}
function resetTextarea(strTextareaName,strDivName)
{ 
	setEditorContents(strTextareaName,$(strDivName).innerHTML);
}
function resetTextarea_All()
{
	var strFrameID;
	var strDivID;
	var arrFrame = document.getElementsByTagName("iframe");  
	for (intI = 0 ; intI < arrFrame.length ; intI ++)
	{
		strFrameID = arrFrame[intI].id.substring(0,arrFrame[intI].id.length-8);
		strDivID = "div" + strFrameID;
		resetTextarea(strFrameID,strDivID);
	}
}

function get_basename(str_link,argument){
	var arrUrlpart = str_link.split("\/");
	var PageUrl = arrUrlpart[(arrUrlpart.length-1)];
	if(argument == false){
		var intPos =	PageUrl.indexOf("?");
		var PageUrl = PageUrl.substr(0,intPos);
	}
	return PageUrl;
}

function changeTag(oTag1,oTag2){
	if(oTag1.style.color != '#FF6600') {
		oTag1.style.color = '#FF6600';
		oTag2.style.color = '';
		if(oTag2.id == 'spanTag1') {
			$('register_info1').style.display = 'none';
			$('register_info2').style.display = '';
		}
		if(oTag2.id == 'spanTag2') {
			$('register_info2').style.display = 'none';
			$('register_info1').style.display = '';
		}
	}
}

function form_search()
{
	var txtSearch=document.getElementById('txtSearch');
	var frm=document.getElementById('form_search');
	var txtValue=txtSearch.value;
	if(txtValue=="")
	{
		alert('Please input key word for search product!');
	}
	else
	{
	    //window.location.href="../myle/search.php?action=search";
		frm.submit();
	}
}

var iN_width;
var iN_height;
var oG_Img;
var iTopPos;
var iLeftPos;
var flag1 = false;
var flag2 = false;
var flag3 = false;
var flag4 = false;
var last1 = 0;
var last2 = 0;

function imageslide(oImg,sImgPath,productID) {
  var img = new Image();
  img.src = sImgPath.replace('Thumb','Slide');
/*
  img.onload = function(){
    slide(oImg,sImgPath,false);  
  };
  if(isIE)*/
  	slide(oImg,sImgPath,productID);
}

function slide(oImg,sImgPath,productID){
	//if(load == false) return;
	//if(document.getElementById('SlideImg')) return;
	xajax_slideProduct(productID);
	var oN_Img = document.createElement('IMG');
	var oDiv = document.getElementById('mask_div');
	if(isMoz){
		oDiv.style.opacity = 0.2;
	} else if(isIE) {
		oDiv.filters.alpha.opacity = 20;
	}
	oDiv.style.backgroundColor = 'black';
	oDiv.style.position = 'absolute';
	oDiv.style.top = getTop($('show_box'))+'px';
	oDiv.style.left = (getLeft($('show_box'))+1)+'px';
	oDiv.style.height = $('show_box').clientHeight+'px';
	oDiv.style.width = $('show_box').clientWidth+'px';
	document.getElementById('mask_div').style.display = '';
	oDiv.style.zIndex = 10;
	
	flag1 = false;
	flag2 = false;
	oG_Img = oN_Img;
	//oN_Img.onclick = function (){initial();};
	oN_Img.src = sImgPath.replace('Thumb','Slide');
	iN_width = oN_Img.width;
	iN_height = oN_Img.height;
	oN_Img.id='SlideImg';
	
	//document.getElementsByName('SlideImg');
	oN_Img.onclick = function (){
		document.body.removeChild(document.getElementById('SlideImg'));
		document.getElementById('mask_div').style.display = 'none';
	   window.open('Detail_Product.php?id='+productID);
	};
	oN_Img.style.width = oImg.width+'px';
	oN_Img.style.height = oImg.height+'px';
	oN_Img.style.position = 'absolute';
	oN_Img.style.left = getLeft(oImg)+'px';
	oN_Img.style.top = getTop(oImg)+'px';
	oN_Img.style.cursor = 'pointer';
	oN_Img.style.zIndex = 20;
	
	iTopPos = getTop($('show_box')) + 1 + (380 - iN_height)/2;
	iLeftPos = getLeft($('show_box')) + 1 + (480 - iN_width)/2;
	document.body.appendChild(oN_Img);
	
	var offset_x = (parseInt(iN_width) - parseInt(oImg.width));
	var offset_y = (parseInt(iN_height) - parseInt(oImg.height));
	var offset_t = (parseInt(getTop(oImg)) - parseInt(iTopPos));
	var offset_l = (parseInt(iLeftPos) - parseInt(getLeft(oImg)));

	var rate1 = offset_x/200;
	var rate2 = offset_y/200;
	var rate3 = offset_t/100;
	var rate4 = offset_l/100;

	extendImg(rate1,rate2);
	move(rate3,rate4);
	//initial();
}

function extendImg(rate1,rate2) {
	var lock = 4;
	var offset_x = parseInt(oG_Img.style.width) + lock*rate1;
	var offset_y = parseInt(oG_Img.style.height) + lock*rate2;
	
	last1+= parseInt(oG_Img.style.width) + lock*rate1 - parseInt(parseInt(oG_Img.style.width) + lock*rate1);
	if(last1 >= 1) {
		last1 = last1 - 1;
		offset_x = offset_x + 1;
	}
	last2+= parseInt(oG_Img.style.height) + lock*rate2 - parseInt(parseInt(oG_Img.style.height) + lock*rate2);
	if(last2 >= 1) {
		last2 = last2 - 1;
		offset_y = offset_y + 1;
	}
	if(offset_x < iN_width){
		oG_Img.style.width = offset_x+'px';
	}else{
		oG_Img.style.width = iN_width+'px';
		flag1 = true;
		if(flag1 == true && flag2 == true)
			return false;
	}
	if(offset_y < iN_height){
		oG_Img.style.height = offset_y+'px';
	} else {
		oG_Img.style.height = iN_height+'px';
		flag2 = true;
		if(flag1 == true && flag2 == true)
			return false;
	}
	setTimeout("extendImg("+rate1+","+rate2+")",5);
}

function move(rate3,rate4){
	var lock = 2;
	var offset_t = parseInt(oG_Img.style.top) - Math.abs(lock*rate3);
	var offset_l = parseInt(oG_Img.style.left) + lock*rate4;
	if(offset_t > iTopPos && offset_t > 0) {
		oG_Img.style.top = offset_t+'px';
	} else {
		oG_Img.style.top = iTopPos+'px';
		flag3 = true;
		if(flag3 == true && flag4 == true)
			return false;
	}
	
	if( (rate4 > 0 && offset_l > iLeftPos) || (rate4 < 0 && offset_l < iLeftPos)) {
		oG_Img.style.left = iLeftPos+'px';
		flag4 = false;
		if(flag3 == true && flag4 == true)
			return false;
	}else
		oG_Img.style.left = offset_l+'px';
	setTimeout("move("+rate3+","+rate4+")",5);
}

function getTop(e){ 
	var offset=e.offsetTop;
	if(e.offsetParent!=null) 
		offset+=getTop(e.offsetParent); 
	return offset; 
} 
function getLeft(e){ 
	var offset=e.offsetLeft; 
	if(e.offsetParent!=null) offset+=getLeft(e.offsetParent); 
	return offset; 
} 
function initial(){
	var oN_Img = document.getElementById('SlideImg');
	oN_Img.remove();
	iN_width = 0;
	iN_height = 0;
	oG_Img = '';
	iTopPos = 0;
	iLeftPos = 0;
	flag1 = false;
	flag2 = false;
	flag3 = false;
	flag4 = false;
	last1 = 0;
	last2 = 0;
}



function CheckPWD(){

	if(document.getElementById("strAltPassword").value == ""){
		alert("请输入旧密码！");
		document.getElementById("strAltPassword").focus();
		return false;
	}
	if(document.getElementById("strNewPassword1").value == ""){
		alert("请输入新密码！");
		document.getElementById("strNewPassword1").focus();
		return false;
	}
	if(document.getElementById("strNewPassword1").value.length < 6 || document.getElementById("strNewPassword1").value.length >16){
		alert("密码请在6-16个字符!\n请重新输入");
		document.getElementById("strNewPassword1").value = "";
		document.getElementById("strNewPassword2").value = "";
		document.getElementById("strNewPassword1").focus();
		return false;
	}
	if(document.getElementById("strNewPassword2").value == ""){
		alert("请输入确认密码！");
		document.getElementById("strNewPassword2").focus();
		return false;
	}
	if(document.getElementById("strNewPassword2").value != document.getElementById("strNewPassword1").value){
		alert("新密码与确认密码不同！\n请重新输入");
		document.getElementById("strNewPassword1").value = "";
		document.getElementById("strNewPassword2").value = "";
		document.getElementById("strNewPassword1").focus();
		return false;
	}
	document.getElementById("ChangePWD_form").submit();
}


function doSuggestionMessage(){
	xajax_insertSuggestionMessage(xajax.getFormValues('form_faq'));
	//document.getElementById("form_faq").reset();
	
}


function lock_screen(intpay,intorerid){
	
	xajax_updatePayment(intpay,intorerid);

	if(intpay==2)
	{
		var frm = document.getElementById('E_FORM');
		frm.submit();
	}
	window.location.href="#";
	var aSelect = document.getElementsByTagName('SELECT');
	for(var i = 0;i < aSelect.length;i ++) {
		aSelect[i].style.display = 'none';
	}
	$("mask").style.position = "absolute";
	$("mask").style.top = "0px";
	$("mask").style.left = "0px";
	if(isMoz)
		$("mask").style.height = "100%";
	if(isIE)
		$("mask").style.height = document.body.clientHeight;
	$("mask").style.width = "100%";
	$("mask").style.backgroundColor = "#000000";
	$("mask").style.display = "";
	$("mask").style.zIndex = "999";
	document.body.scroll = "no";
	
	if(isMoz)
		$("mask").style.MozOpacity = "0.6";
	if(isIE)
		$("mask").style.filter = "alpha(opacity=60)";
	var obj_iframe = document.createElement("iframe");
	document.body.insertBefore(obj_iframe,$("mask"));
	obj_iframe.style.position = "absolute";
	obj_iframe.style.top = (window.screen.height/2-200)+"px";
	obj_iframe.style.left = (window.screen.width/2-200)+"px";
	obj_iframe.style.height = "180px";
	obj_iframe.style.width = "400px";
	obj_iframe.style.backgroundColor = "#FFFFFF";
	obj_iframe.id = "pay_money";
	obj_iframe.style.zIndex = "1055";
	obj_iframe.src = "./pay_confirm.php";
	

}

function page()
{
	var sel=document.getElementById('sdf')
	if(sel.value!=0)
	{
	window.location=sel.value;
	}

}

function setPicRange(obj,picW,picH){
if(obj.width>picW || obj.height>picH ){
   if(obj.width/obj.height>picW/picH   )
    obj.width=picW;
   else
    obj.height=picH;
}
}

function changePic(oImage){
	oImage.style.height = '58px';
	oImage.style.width = '58px';
	$('main_pic').src = oImage.src;
	window.clearTimeout(hAlpha);
	changeAlpha(0);
	var aImage = document.getElementsByName('imageField');
	for(var i=0;i < aImage.length;i++) {
			aImage[i].style.border = '0px';
	}
	oImage.style.border = '1px solid #CCCCCC';
	oImage.blur();
}


function changeBgPic(picId)
{
	if(picId=='0')
	{
		document.getElementById("dvMenu").style.background= "url('./images/menu_bg1.png') no-repeat";  
	}
	else
	{
		document.getElementById("dvMenu").style.background= "url('./images/"+picId+".jpg') no-repeat";  
	}
}

var hAlpha;
function cancelTimer(){
	window.clearTimeout(hAlpha);
}
function changeAlpha(iAlphaValue) {
	if(parseInt(iAlphaValue) >= 100){
		cancelTimer();
	}
	if(isMoz){
		$('main_pic').style.opacity = iAlphaValue/100;
	} else if(isIE) {
		$('main_pic').filters.alpha.opacity = iAlphaValue;
	}
	iAlphaValue = iAlphaValue +5;
	hAlpha = window.setTimeout("changeAlpha("+iAlphaValue+")",50);
}

function resizeimg(ImgD,iwidth,iheight) { 
     var image=new Image(); 
     image.src=ImgD.src; 
     if(image.width>0 && image.height>0){ 
        if(image.width/image.height>= iwidth/iheight){ 
           if(image.width>iwidth){ 
               ImgD.width=iwidth; 
               ImgD.height=(image.height*iwidth)/image.width; 
           }else{ 
                  ImgD.width=image.width; 
                  ImgD.height=image.height; 
                } 
               ImgD.alt=image.width+"×"+image.height; 
        } 
        else{ 
                if(image.height>iheight){ 
                       ImgD.height=iheight; 
                       ImgD.width=(image.width*iheight)/image.height; 
                }else{ 
                        ImgD.width=image.width; 
                        ImgD.height=image.height; 
                     } 
                ImgD.alt=image.width+"×"+image.height; 
            }
        /*
		ImgD.style.cursor= "pointer"; //改变鼠标指针 
		ImgD.onclick = function() { window.open(this.src);} //点击打开大图片 
		if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { //判断浏览器，如果是IE 
			ImgD.title = "请使用鼠标滚轮缩放图片，点击图片可在新窗口打开"; 
			ImgD.onmousewheel = function img_zoom() //滚轮缩放 
			{ 
				var zoom = parseInt(this.style.zoom, 10) || 100; 
				zoom += event.wheelDelta / 12; 
				if (zoom> 0)this.style.zoom = zoom + "%"; 
				return false; 
			} 
		} else { //如果不是IE 
			ImgD.title = "点击图片可在新窗口打开"; 
		}*/
    } 
}
