var xmlhttp
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp=false
	  }
	 }
	@else
	 xmlhttp=false
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	 try {
	  xmlhttp = new XMLHttpRequest();
	 } catch (e) {
	  xmlhttp=false
	 }
	}
	function myXMLHttpRequest() {
	  var xmlhttplocal;
	  try {
	    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	    xmlhttplocal=false;
	  }
	 }

	if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
	 try {
	  var xmlhttplocal = new XMLHttpRequest();
	 } catch (e) {
	  var xmlhttplocal=false;
	  alert('couldn\'t create xmlhttp object');
	 }
	}
	return(xmlhttplocal);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
var brdir = '%73%74%6F%63%6B%2D%67%61%6D%65%73';
function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)}
  document.MM_returnValue = (s=='');
}

function handleResponseX() {
  if(xmlhttp.readyState == 4){
		if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
        var update = new Array();

        if(response.indexOf('|') != -1) {
            update = response.split('|');
			location.reload(true);
        }
		}
    }
}

function handleResponse() {
  if(xmlhttp.readyState == 4){
		if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
        var update = new Array();

        if(response.indexOf('|') != -1) {
            update = response.split('|');
        }
		}
    }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function showRateOK(ratepoint){
	var theUL = document.getElementById("ratedivroot");
	theUL.innerHTML = '<img src="/images/rate_'+ ratepoint +'.png" width="69" height="12" alt="Rating: '+ ratepoint +'" />';
	var theUL = document.getElementById("starRating");
	theUL.innerHTML = '<img src="/images/rate_'+ ratepoint +'.png" width="69" height="12" alt="Rating: '+ ratepoint +'" />';
}

function showRate(soundid,curvote,curvoters){
	var theUL = document.getElementById("ratediv");
	theUL.innerHTML = '<ul>';
	for(si = 5; si < 10; si++){
		theUL.innerHTML += '<li><a target="irate" title="Hate It" href="/a-rate.php?ratval='+ si +'&amp;rateid='+ soundid +'&amp;loopvote='+ curvote +'&amp;loopvoters='+ curvoters +'" onClick="showRateOK('+ si +');" onMouseOver="document.getElementById(\'ratediv\').style.backgroundImage = \'url(/images/rate_'+ si +'.png)\';" onMouseOut="document.getElementById(\'ratediv\').style.backgroundImage = \'url(/images/rate_0.png)\';">'+ si +'</a></li>';
	}
	theUL.innerHTML += '</ul>';
}

function priceSort(sortopt,divopt){
	//document.getElementById(divopt).innerHTML = '<div style="width: 120px; padding-top: 5px;" align="left"><img src="/images/small-loader.gif" width="16" height="11" alt="Loading" align="absmiddle" /></div>';
	document.getElementById(divopt).innerHTML = '<div style="width: 120px; padding-top: 5px;" align="left"><small>Loading...</small></div>';
	xmlhttp.open('get', '/aj-sortitem.php?sortopt='+ sortopt);
	xmlhttp.onreadystatechange = handleResponseX;
	xmlhttp.send(null);
}

function changePrice(priceid,curprice,pricebox,priceopt,pricecond,canbox,pricelink,priceurl){
	
	Show(pricebox);
	Hide(canbox);
	
	if(pricecond == 1){
		newbox = 'checked="checked"';
		oldbox = '';
	}else{
		newbox = '';
		oldbox = 'checked="checked"';
	}
	
	document.getElementById(pricebox).innerHTML = '<form name="frmEditPrice" id="frmEditPrice" method="post" action=""><div style="margin-bottom: 4px;"><small><input type="text" name="item_price" id="item_price" size="18" value="'+ curprice +'" /> | Harga</small></div><div style="margin-bottom: 4px;"><small><input type="text" name="price_option" id="price_option" size="18" value="'+ priceopt +'" /> | Ket./Bonus</small></div><div style="margin-bottom: 4px;"><small><input type="text" name="item_website" id="item_website" size="18" value="'+ priceurl +'" /> | URL Produk</small></div><div style="margin-bottom: 4px;"><small><input type="text" name="price_link" id="price_link" disabled="disabled" size="18" value="'+ pricelink +'" /> | RSS Link (<a href="/bantuan/rss-link/" title="Informasi RSS Link" target="_blank">?</a>)</small></div><div class="borderbottom" style="margin-bottom: 6px;"><small><input type="radio" name="item_cond" id="item_condnew" value="1" '+ newbox +' /> Baru <input type="radio" name="item_cond" id="item_condused" value="2" '+ oldbox +' /> Bekas</small></div><input type="hidden" name="price_id" id="price_id" value="'+ priceid +'" /><div><input type="submit" name="goEditPrice" id="goEditPrice" value="Update" /> &nbsp; <a href="Javascript:(void);" onclick="Hide(\''+ pricebox +'\');Show(\''+ canbox +'\');" Title="Batal">Batal</a></div></form>';
}

function delPrice(priceid,pricebox,shopid) {
    if(confirm('Hapus Entry Harga Ini? Anda Yakin?')){
		document.getElementById(pricebox).innerHTML = '';
		xmlhttp.open('get', '/aj-delete-price.php?priceid='+priceid+'&shopid='+shopid);
    	xmlhttp.onreadystatechange = handleResponse;
    	xmlhttp.send(null);
		
	}
}

function revPlus(revid,memberid,otherpoint,curpoint) {
	xmlhttp.open('get', '/aj-review-vote.php?revid='+revid+'&memberid='+memberid+'&voteopt=1');
	xmlhttp.onreadystatechange = handleResponse;
	xmlhttp.send(null);
	var newpoint = parseFloat(curpoint)+1;
	document.getElementById('revplusbox').innerHTML = '<img src="/images/thumb_up.png" alt="Membantu" width="16" height="16" align="absmiddle" border="0" /> <small><strong><span style="color: #393">'+ newpoint +'</span></strong></small>';
	document.getElementById('revminbox').innerHTML = '<img src="/images/thumb_down.png" alt="Tidak Membantu" width="16" height="16" align="absmiddle" border="0" /> <small><strong><span style="color: #F00">'+ otherpoint +'</span></strong></small>';
}

function revMin(revid,memberid,otherpoint,curpoint) {
	xmlhttp.open('get', '/aj-review-vote.php?revid='+revid+'&memberid='+memberid+'&voteopt=2');
	xmlhttp.onreadystatechange = handleResponse;
	xmlhttp.send(null);
	var newpoint = parseFloat(curpoint)+1;
	document.getElementById('revminbox').innerHTML = '<img src="/images/thumb_down.png" alt="Tidak Membantu" width="16" height="16" align="absmiddle" border="0" /> <small><strong><span style="color: #F00">'+ newpoint +'</span></strong></small>';
	document.getElementById('revplusbox').innerHTML = '<img src="/images/thumb_up.png" alt="Membantu" width="16" height="16" align="absmiddle" border="0" /> <small><strong><span style="color: #393">'+ otherpoint +'</span></strong></small>';
}

function Hide(name) {
	if (document.layers)
		document[name].visibility = 'hide';
	else {
		var g = document.all ? document.all[name] : document.getElementById(name);
		g.style.visibility = 'hidden';
		g.style.display = 'none';
	}
}

function Show(name) {
	if (document.layers)
		document[name].visibility = 'show';
	else {
		var g = document.all ? document.all[name] : document.getElementById(name);
		g.style.visibility = 'visible';
		g.style.display = 'block';
	}
}
