jslous.noConflict();
var js = jslous;
js(function(){
 
 
 var root = 'http://'+location.host+'/';
 js('p',document.getElementById('cam_dis_output')).each(function(){
  var chk = this;
  if(chk && chk.tagName && chk.tagName.toLowerCase() == 'p' && chk.getAttribute('align')){
   chk.style['textAlign'] = chk.getAttribute('align');
  }
 }).query('div#flashcontent').each(function(){
  var elm = this;
  if(elm && elm.tagName && elm.tagName.toLowerCase() == 'div'){
   var so = new SWFObject("top.swf", "美光写苑", "100%", "480", "7", "#000");
   so.addVariable("flashVarText", "this is passed in via FlashVars for example only");
   so.addParam("scale", "noscale");
   so.write("flashcontent");
  }
 }).query('input.interface').each(function(){
  var chk = this;
  if(chk && chk.tagName && chk.tagName.toLowerCase() == 'input'){
   photo = document.getElementById('img'+chk.getAttribute('id'));
   photo['className'] = chk.checked == true ? 'select':'nonselect';
  }
 }).query('input.interface').push('label.interface').click(function(evt){
  var elm = jslous.Event.target(evt);
  if(elm && elm.tagName){
   if(elm.tagName.toLowerCase() == 'label' || elm.tagName.toLowerCase() == 'input'){
    var photo = null;
    var photo_selected = 0;
    js('input.interface').each(function(){
     var chk = this;
     if(chk && chk.tagName && chk.tagName.toLowerCase() == 'input' && chk.checked == true){
      photo_selected++;
     }
    });
    if(elm.tagName.toLowerCase() == 'label'){
     var unique = elm.getAttribute('for');
     elm = document.getElementById(unique);
     photo = document.getElementById('img'+unique);
    }else{
     photo = document.getElementById('img'+elm.getAttribute('id'));
    }
    if(photo_selected > 2 || elm.checked == false){
     photo_selected--;
     elm.checked = false;
     photo['className'] = 'nonselect';
    }else{
     photo['className'] = 'select';
     photo_selected++;
    }
    var btn = document.getElementById('photocomfirm');
    if(btn && btn.tagName && btn.tagName.toLowerCase() == 'input'){
     btn.disabled = photo_selected > 2 ? false:true;
    }
   }
  }
 }).query('input.selectoins').click(function(evt){
  var elm = jslous.Event.target(evt);
  var limit = parseInt(document.getElementById('select_limit').value);
  var select = parseInt(document.getElementById('choice').innerHTML);
  if(elm && elm.tagName && elm.tagName.toLowerCase() == 'input'){
   var f = elm.checked == true ? 1:0;
   if(limit <= select && f == 1){
    window.event.returnValue = false;
    elm.checked = false;
    return false;
   }
   var v = elm.value;
   jslous.ajax(root+'member/index.php?pid='+v+'&flag='+f+'&get='+Math.floor(Math.random()*100),'GET','',function(res){
    document.getElementById('choice').innerHTML = select+(elm.checked == true ? 1:-1);
   },'txt');
  }
 }).query('img.selection_clear').click(function(){
  jslous.ajax(root+'member/index.php?clear=1&get='+Math.floor(Math.random()*100),'GET','',function(res){
   location.reload();
  },'txt');
 }).query('input.public').click(function(evt){
  var elm = jslous.Event.target(evt);
  var limit = parseInt(document.getElementById('select_limit').value);
  var select = parseInt(document.getElementById('choice').innerHTML);
  if(elm && elm.tagName && elm.tagName.toLowerCase() == 'input'){
   var f = elm.checked == true ? 1:0;
   if(limit <= select && f == 1){
    window.event.returnValue = false;
    elm.checked = false;
    return false;
   }
   var v = elm.value;
   jslous.ajax(root+'member/public.php?pid='+v+'&flag='+f+'&get='+Math.floor(Math.random()*100),'GET','',function(res){
    document.getElementById('choice').innerHTML = select+(elm.checked == true ? 1:-1);
   },'txt');
  }
 }).query('img.public_clear').click(function(){
  jslous.ajax(root+'member/public.php?clear=1&get='+Math.floor(Math.random()*100),'GET','',function(res){
   location.reload();
  },'txt');
 }).query('input.numlock').enter(function(evt){
  var check = String.fromCharCode(evt.keyCode);
  var reg = /[0-9]+/;
  if(reg.test(check) !== true && evt.keyCode != 8 && evt.keyCode != 9 && evt.keyCode != 13 && !(evt.keyCode >= 96 && evt.keyCode <= 105) && evt.keyCode != 110){
   window.event.returnValue = false;
  }
 }).query('input.photoorder').change(function(evt){
  var elm = jslous.Event.target(evt);
  if(elm && elm.tagName && elm.tagName.toLowerCase() == 'input'){
   var pid = elm.getAttribute('pid');
   var type = elm.getAttribute('type');
   var v = elm.value;
   jslous.ajax(root+'visitor/ordering.php?pid='+pid+'&type='+type+'&v='+v+'&get='+Math.floor(Math.random()*100),'GET','',function(res){
    
   },'txt');
  }
 }).query('img.ordering_clear').click(function(){
  jslous.ajax(root+'visitor/ordering.php?clear=1&get='+Math.floor(Math.random()*100),'GET','',function(res){
   location.reload();
  },'txt');
 }).query('div#requestclublist').each(function(){
  var elm = this;
  if(elm && elm.tagName && elm.tagName.toLowerCase() == 'div'){
   elm.style.display = 'none';
   jslous.ajax(root+'system/outputs/reqfooters.php?get='+Math.floor(Math.random()*100),'GET','',function(res){
    elm.innerHTML = res;
    elm.style.display = '';
   },'txt');
  }
 }).query('select#studiolocale').change(function(evt){
  if(!document.getElementById('studiolocale') ||!document.getElementById('studio')){ return false; }
  var trg = jslous.Event.target(evt);
  while(trg.tagName.toLowerCase() != 'select'){ trg = trg.parentNode; }
  if(trg && trg.tagName && trg.tagName.toLowerCase() == 'select'){
   var locale = jslous.node.getSelect(document.getElementById('studiolocale')).value;
   var replace = document.getElementById('studio');
   var select = [];
   jslous.ajax('../../system/req/getstudio.php?locale='+locale+'&get='+Math.floor(Math.random()*100),'GET','',function(res){
    $('studio',res).each(function(){
     var self = this,value = self.getAttribute('data'),text = self.getAttribute('string');
     select.push({val:value,txt:text});
    });
    select = jslous.node.createSelect(select);
    select['name'] = replace['name'];
    replace.parentNode.replaceChild(select,replace);
    select['id'] = 'studio';
   },'xml');
  }
 });

});