﻿window.opener = null;

function WebAjax() {
    var obj;
    try { obj = new XMLHttpRequest(); }
    catch (e) {
        var AjList = ["MSXML2.XMLHTTP", "MSXML.XMLHTTP", "Microsoft.XMLHTTP"];
        for (var i = 0; i < AjList.length; i++) {
            try {
                obj = new ActiveXObject(AjList[i]);
                break;
            } catch (e) { }
        }
    }
    return obj;
}

function SoID(id) {
    if (document.getElementById) { return document.getElementById(id); }
    else if (document.all) { return document.all[id]; }
    else if (document.layers) { return document.layers[id]; }
    else { return false; }
}

function Ajax() {
    var obj;
    try { obj = new XMLHttpRequest(); }
    catch (e) {
        var objList = ["MSXML2.XMLHTTP", "MSXML.XMLHTTP", "Microsoft.XMLHTTP"];
        obj = false;
        for (var i = 0; i < objList.length; i++) {
            try {
                obj = new ActiveXObject(objList[i]);
                break;
            } catch (e) { }
        }
    }
    return obj;
}

function AddFav(alt, url) {
    if (document.all) { window.external.AddFavorite(url, alt); }
    else if (window.sidebar) { window.sidebar.addPanel(alt, url, ''); }
    else { return false; }
}

function ButClose(id, key) {
    if (key == 1) { SoID(id).style.display = 'block'; }
    else { SoID(id).style.display = 'none'; }
}

function ButDisinp(id, key) {
    if (key == 1) { SoID(id).disabled = true; }
    else { SoID(id).disabled = false; }
}

function ButHtml(id, key) { SoID(id).innerHTML = key; }

function TrimL(key) { return key.replace(/^\s*/, ''); }

function TrimR(key) { return key.replace(/\s*SoID/, ''); }

function TrimAll(key) { return key.replace(/(^\s*)|(\s*SoID)/g, ''); }

function isConfirm(note, url, key) {
    if (confirm(note)) {
        if (!url) { window.location.href = url; }
        else { eval(key); }
    }
    else { return false; }
}

function buCheckAll(n, fmkey, key, keya, keyb) {
    var cka = eval('document.' + fmkey + '.' + keya + '.checked');
    if (n == 0) { return false; }
    var fkey = eval('document.' + fmkey + '.' + key), e = fkey;
    if (!fkey) { return false; }
    eval('document.' + fmkey + '.' + keyb).checked = cka;
    var fkeynum = fkey.length;
    if (fkeynum > 1) {
        for (var i = 0; i < fkeynum; i++) {
            e = fkey[i];
            if (e.checked != cka) { e.checked = cka; }
        }
    }
    else { e.checked = cka; }
}

function buCheckOP(fmkey, key) {
    var fkey = eval('document.' + fmkey + '.' + key);
    if (!fkey) { return false; }
    var fkeynum = fkey.length, e;
    if (fkeynum > 1) {
        for (var i = 0; i < fkeynum; i++) {
            e = fkey[i];
            if (e.checked == true) { e.checked = false; }
            else if (e.checked == false) { e.checked = true; }
        }
    }
    else {
        e = fkey;
        if (e.checked == true) { e.checked = false; }
        else if (e.checked == false) { e.checked = true; }
    }
}

function isCheckAll(fmkey, key, realtid) {
    BuCheckAll(fmkey, key, realtid);
    eval('document.all.' + fmkey).submit();
}

function ChangePic(id, picurl) { SoID(id).src = picurl; }

function OpenMenu(id, num) {
    if (id == '' || id == '0') { return; }
    if (SoID('mu' + id)) { SoID('mu' + id).style.display = 'block'; }
}

function MenuCss(e,num) {
    alert(e.className);
    if (num == 1) { e.className = 'MABDiv1240'; }
    else { e.className = 'MABDiv124'; }
    alert(e.className);
}

function trim(key) { return key.replace(/^\s+|\s+$/g, ""); }
function ltrim(key) { return key.replace(/^\s+/, ""); }
function rtrim(key) { return key.replace(/\s+$/, ""); }
function fulltrim(key) { return rtrim(ltrim(key)); }

function ismail(mail) {
    return (new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail));
}

function Checkjoinemail() {
  SoID('idp1').innerHTML = '*';
  SoID('idp2').innerHTML = '*';
  SoID('idp3').innerHTML = '*';
  if (fulltrim(document.bu.usernamea.value) == "") {
    SoID('idp1').innerHTML = '* This field is required. Please enter a value.';
    document.bu.usernamea.focus();
    return;
  }
  if (fulltrim(document.bu.usernameb.value) == "") {
    SoID('idp2').innerHTML = '* This field is required. Please enter a value.';
    document.bu.usernameb.focus();
    return;
   }
   var usermail = fulltrim(document.bu.useremail.value);
  if (usermail == "") {
    SoID('idp3').innerHTML = '* This field is required. Please enter a value.';
    document.bu.useremail.focus();
    return;
  }
  if (ismail(usermail) == false) {
    SoID('idp3').innerHTML = '* This email is error.';
    document.bu.useremail.focus();
    return;
  }
  document.bu.submit();
}

function Checkcontactus() {
    SoID('idp1').innerHTML = '*';
    //SoID('idp2').innerHTML = '*';
    SoID('idp3').innerHTML = '*';
    if (fulltrim(document.bu.usernamea.value) == "") {
        SoID('idp1').innerHTML = '* This field is required. Please enter a value.';
        document.bu.usernamea.focus();
        return;
    }
    /**if (fulltrim(document.bu.usernameb.value) == "") {
        SoID('idp2').innerHTML = '* This field is required. Please enter a value.';
        document.bu.usernameb.focus();
        return;
    }**/
    var usermail = fulltrim(document.bu.useremail.value);
    if (usermail == "") {
        SoID('idp3').innerHTML = '* This field is required. Please enter a value.';
        document.bu.useremail.focus();
        return;
    }
    if (ismail(usermail) == false) {
        SoID('idp3').innerHTML = '* This email is error.';
        document.bu.useremail.focus();
        return;
    }
    if (fulltrim(document.bu.usernote.value) == "") {
        SoID('idp4').innerHTML = '* This field is required. Please enter a value.';
        document.bu.usernote.focus();
        return;
    }
    document.bu.submit();
}

function Checkgetlisteddo() {
    SoID('idp1').innerHTML = '*';
    SoID('idp2').innerHTML = '*';
	SoID('idp3').innerHTML = '*';
    SoID('idp4').innerHTML = '*';
    SoID('idp5').innerHTML = '*';
	SoID('idp6').innerHTML = '*';
	SoID('idp7').innerHTML = '*';
    if (fulltrim(document.bu.usernamea.value) == "") {
        SoID('idp1').innerHTML = '* This field is required. Please enter a value.';
        document.bu.usernamea.focus();
        return;
    }
    if (fulltrim(document.bu.usernameb.value) == "") {
        SoID('idp2').innerHTML = '* This field is required. Please enter a value.';
        document.bu.usernameb.focus();
        return;
    }
	if (fulltrim(document.bu.usercompany.value) == "") {
        SoID('idp6').innerHTML = '* This field is required. Please enter a value.';
        document.bu.usercompany.focus();
        return;
    }

	if (fulltrim(document.bu.userphone.value) == "") {
        SoID('idp3').innerHTML = '* This field is required. Please enter a value.';
        document.bu.userphone.focus();
        return;
    }

    var usermail = fulltrim(document.bu.useremail.value);
    if (usermail == "") {
        SoID('idp4').innerHTML = '* This field is required. Please enter a value.';
        document.bu.useremail.focus();
        return;
    }
    if (ismail(usermail) == false) {
        SoID('idp4').innerHTML = '* This email is error.';
        document.bu.useremail.focus();
        return;
    }
	if (fulltrim(document.bu.website.value) == "") {
        SoID('idp7').innerHTML = '* This field is required. Please enter a value.';
        document.bu.website.focus();
        return;
    }
    if (fulltrim(document.bu.usernote.value) == "") {
        SoID('idp5').innerHTML = '* This field is required. Please enter a value.';
        document.bu.usernote.focus();
        return;
    }
	
    document.bu.submit();
}

function RaveFunc(id,num) {
    var xmlhttp = WebAjax();
    var AjaxURL = 'ajax.php?id=' + id + '&num=' + num;
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            var getText = xmlhttp.responseText;
            xmlhttp = '';
            getText = fulltrim(getText);
            if (getText == 'ok') { alert('success! thanks'); }
            else if (getText == 'have') { alert('thanks,you are have rave this on today.'); }
            else { alert('sorry,rave this is error'); }
        }
    }
    xmlhttp.open("GET", AjaxURL, true);
    xmlhttp.setRequestHeader("Content-type", "text/html;charset=utf-8");
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send(null);
}

function ShowBBSList(methodid,sortid) {
    var xmlhttp = WebAjax();
    var AjaxURL = 'ajaxbbs.php?methodid=' + methodid + '&sortid=' + sortid + '&ntime=' + Math.floor(Math.random() * 10000 + 1); ;
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            var getText = xmlhttp.responseText;
            xmlhttp = '';
            SoID('bbslist').innerHTML = fulltrim(getText);
        }
    }
    xmlhttp.open("GET", AjaxURL, true);
    xmlhttp.setRequestHeader("Content-type", "text/html;charset=utf-8");
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send(null);
}

function Checkreply() {
    SoID('idp1').innerHTML = '*';
    //SoID('idp2').innerHTML = '*';
    SoID('idp3').innerHTML = '*';
    //SoID('idp4').innerHTML = '*';
    if (fulltrim(document.bu.usernamea.value) == "") {
        SoID('idp1').innerHTML = '* This field is required. Please enter a value.';
        document.bu.usernamea.focus();
        return;
    }
    /**if (fulltrim(document.bu.usernameb.value) == "") {
        SoID('idp2').innerHTML = '* This field is required. Please enter a value.';
        document.bu.usernameb.focus();
        return;
    }**/
    var usermail = fulltrim(document.bu.useremail.value);
    if (usermail == "") {
        SoID('idp3').innerHTML = '* This field is required. Please enter a value.';
        document.bu.useremail.focus();
        return;
    }
    if (ismail(usermail) == false) {
        SoID('idp3').innerHTML = '* This email is error.';
        document.bu.useremail.focus();
        return;
    }
    /**if (fulltrim(document.bu.usernote.value) == "") {
        SoID('idp4').innerHTML = '* This field is required. Please enter a value.';
        document.bu.usernote.focus();
        return;
    }**/
    document.bu.submit();
}





/*
   Class that defines a standard ratings component.
*/
// Messages for display above the individual ratings units. The length of the
// array also defines how many units to include in the component.
yg_Ratings.Msgs = new Array
(
   "1 Star",
   "2 Stars",
   "3 Stars",
   "4 Stars",
   "5 Stars"
);
yg_Ratings.Labels = new Array
(
   "1 Star",
   "2 Stars",
   "3 Stars",
   "4 Stars",
   "5 Stars"
);
// Path for all images.

var path = "images/star/yri_";
yg_Ratings.starbar = "star_";
// Image for set units.
yg_Ratings.UnitY = "yellow.gif";
// Image for set units <= the mouse over point.
yg_Ratings.UnitYMouseOver = "yellow.gif";
// Image for set units > the mouse over point.
yg_Ratings.UnitYMouseLess = "grey.gif";
// Image for unset units.
yg_Ratings.UnitN = "white.gif";
// Image for unset units <= the mouse over point.
yg_Ratings.UnitNMouseOver = "hover.gif";
yg_Ratings.DefaultMsg = " ";
function yg_Ratings(id, button, isURL,URL, inputname, defaultval,type)
{
   // The id parameter is the name (a string) of the variable to which the
   // instance is assigned. (The variable is sent along to event handlers,
   // so it must be in the global scope.)
   var i, t;
   var attributes;
   var h1, h2;
   var d = document;
   var style;   
   this.starbar = type + "_";
   this.rating = 0;
   this.showbutton = button;
   if (defaultval < 1 || defaultval > 5) {
 defaultval = 0;
   }
   this.rating = defaultval;
  
   attributes = 'class="ygrtngs" id="' + id + '" style="' + style + '"';
   h1 = 'onMouseOut="return yg_Ratings_mouseOut(' + id + ');"';
	if(isURL){
	d.write('<a href="' + URL + '"><span ' + attributes + ' ' + h1 + '>');
	}
	else{
	d.write('<span ' + attributes + ' ' + h1 + '>');
	}

   if (defaultval > 0 && type == "star") {
       d.write('<div class="msg" id="'+id+'_msg" style=\"display:none\">'+yg_Ratings.Msgs[defaultval-1]+'</div>');
   } else {
       d.write('<div class="msg" id="'+id+'_msg" style=\"display:none\">'+yg_Ratings.DefaultMsg+'</div>');
   }
   if (this.showbutton) { 
      d.write('<span><strong>Rate it:</strong></span>');
   }
   for (i = 1; i <= yg_Ratings.Msgs.length; i++)
   {
      h1 = 'onMouseOver="return yg_Ratings_mouseOver(' + id + ', ' + i + ');"';
      h2 = 'onClick="return yg_Ratings_click(' + id + ', ' + i + ');"';
      d.write('<span class="unit "' + h1 + ' ' + h2 + '>');
      if (i <= defaultval) {
         d.write('<img src="' + path + this.starbar + yg_Ratings.UnitY + '" border="0" />');
      } else {
         d.write('<img src="' + path + this.starbar + yg_Ratings.UnitN + '" border="0" />');
      }
      d.write('</span>');
   }
   if(defaultval){
 d.write('<input type="hidden" name="'+inputname+'" id="input_'+id+'" value="' + defaultval + '" />');
   } else {
 d.write('<input type="hidden" name="'+inputname+'" id="input_'+id+'" />');    
   }
   this.input = document.getElementById('input_'+id);

	if(isURL){
		d.write('</span></a>');
	}
	else
	{
		d.write('</span>');
	}
 
   this.parent = document.getElementById(id);
   this.images = this.parent.getElementsByTagName("img");
   this.msg = document.getElementById(id + '_msg');
   this.id = id;
   var children = this.msg.childNodes;
   var node;
   for (var i = 0; i <  children.length; i++)
   {
      node = children[i];
      if (node.nodeType == 3)
      {
            this.DefaultMsg = node.nodeValue;
      }
   } 
}
function yg_Ratings_set(n, oflag)
{
   if (arguments.length < 2)
      oflag = true;
   
   this.rating = n;
   this.DefaultMsg = yg_Ratings.Msgs[n-1];
//   if (this.showbutton) {
    this.showBtn("btnSave");
//   }
   this.update(n, oflag);
}
function yls_Ratings_showSubmit(sBtn) {
    var saveButton = document.getElementById(sBtn);
    if(saveButton != null) {
        saveButton.style.display="block";
    }
}
function yg_Ratings_setMsg(m)
{
   var children = this.msg.childNodes;
   var node;
   for (var i = 0; i < children.length; i++)
   {
      node = children[i];
      if (node.nodeType == 3)
      {
         // Using 0xA0 prevents the browser from collapsing empty messages.
            node.nodeValue = m;
      }
   }
}
function yg_Ratings_get()
{
   return this.rating;
}
function yg_Ratings_update(n, oflag)
{
   // The oflag parameter is true when the mouse is outside of the ratings
   // component. The n parameter is the 
   if (this.starbar == 'star_') {
    if (oflag) {
    this.setMsg(this.DefaultMsg);
    } else {
    this.setMsg(yg_Ratings.Msgs[n - 1]);
    }
   }
   if (n == this.rating) {
      this.input.setAttribute("value", n);
   }
   for (i = 1; i <= yg_Ratings.Msgs.length; i++)
   {
      if (oflag)
      {
         if (i <= this.rating)
            this.images[i - 1].src = path + this.starbar + yg_Ratings.UnitY;
         else
            this.images[i - 1].src = path + this.starbar + yg_Ratings.UnitN;
      }
      else
      {
         if (i <= n)
         {
            if (i <= this.rating)
               this.images[i - 1].src = path + this.starbar + yg_Ratings.UnitYMouseOver;
            else
               this.images[i - 1].src = path + this.starbar + yg_Ratings.UnitNMouseOver;
         }
         else
         {
            if (i <= this.rating)
               this.images[i - 1].src = path + this.starbar + yg_Ratings.UnitYMouseLess;
            else
               this.images[i - 1].src = path + this.starbar + yg_Ratings.UnitN;
         }
      }
   }
   return true;
}
function yg_Ratings_click(obj, n)
{
   obj.set(n, false);
   return true;
}
function yg_Ratings_mouseOver(obj, n)
{
   obj.update(n, false);
   return true;
}
function yg_Ratings_mouseOut(obj)
{
   obj.update(0, true);
   return true;
}
yg_Ratings.prototype.set = yg_Ratings_set;
yg_Ratings.prototype.setMsg = yg_Ratings_setMsg;
yg_Ratings.prototype.get = yg_Ratings_get;
yg_Ratings.prototype.update = yg_Ratings_update;
yg_Ratings.prototype.showBtn = yls_Ratings_showSubmit;