
function clean_text(value){
    for(;;){
        value2 = value.replace("-","");
        if (value2 == value) {
            break;
        } else {
            value = value2;
        }
    }
    
    return value.replace(" ","");
}


function do_selected(id){
    document.getElementById(id).selected = true;
    value = document.getElementById(id).text;
}

function add_text(obj){
    value = obj.options[obj.selectedIndex].text;
    document.form1.name.value = clean_text(value);
}

function addFile(btn)
{
  
  if (img_count >= img_limit){
      return;
  }  
  if(document.getElementById)
  {
    while (btn.tagName != 'TR') btn = btn.parentNode;
    var newTr = btn.parentNode.insertBefore(btn.cloneNode(true),btn.nextSibling);
    thisChilds = newTr.getElementsByTagName('td');
  }
  img_count++;
}

function makeVisible(id,attr){
    document.getElementById(id).style.display = attr;
    document.cookie =

		escape("menu"+id) + '=' + escape(attr)+"; path=/admin";
		//alert(document.cookie);
    return true;
}

function makeVisible2(id){
    
    cookieVal = getCookie(id);
    if(cookieVal == 'inline'){
        makeVisible(id,'none')
    } else {
        makeVisible(id,'inline')
    }
    return true;
}


function bulkVisible(arr,attr){
    for(i=0;i<arr.length;i++){
        document.getElementById(arr[i]).style.display = attr;
        document.cookie =

		escape("menu"+arr[i]) + '=' + escape(attr)+"; path=/admin";
    }
    
}

function getCookie(cookieName) {

	var cookieValue = '';

	var posName = document.cookie.indexOf(escape(cookieName) + '=');

	if (posName != -1) {

		var posValue = posName + (escape(cookieName) + '=').length;

		var endPos = document.cookie.indexOf(';', posValue);

		if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));

		else cookieValue = unescape(document.cookie.substring(posValue));

	}

	return (cookieValue);

}

function selectAll(){
    obj = document.forms['form1'];
    for(j=0; j<obj.elements.length; j++){
        if(obj.elements[j].type == 'checkbox' && obj.elements[j].id != "do_not_touch" ){
        obj.elements[j].checked = document.getElementById('do_not_touch').checked;
        }
    }
}

function E(d) {return document.getElementById(d);}
function showTooltip(div, e, w) {
 	//alert('test');
 	var odlX = screen.width - e.clientX;
 	
 	if( w==2 ) {
 		width=125;
 	}
 	else if( w==3 ) {
 		width = 260;
 	}
 	else {
 		width=0;
 	}
 	
 	var toolW = 280;
 	var tmp = 0;
 	
 	if( odlX>=toolW  ) {
 		E(div).style.left = (e.clientX+document.body.scrollLeft+120)-width+'px';
		E(div).style.top = e.clientY+document.body.scrollTop+10+'px';
		E(div).style.visibility = 'visible';
		
		//alert(E(div).style.visibility);
 	}
}

function hideTooltip(div) {
	E(div).style.visibility = 'hidden';
}	

function deee(e){
    mes = e.clientY + " " + e.clientX + " " + screen.width+'<br>';
    E('delete').innerHTML=mes+e.clientX+'px' + " " + e.clientY+'px' + " xxx" + screen.width+'\n';
    
}

function reload_captcha(){
	alert(document.getElementById('captcha').src);
	document.getElementById('captcha').src = 'http://redfrog.com/captcha/img.html?r='+Math.random();alert(document.getElementById('captcha').src);
}

   
    xajax.realCall = xajax.call;
    //override the call function to bend to our wicked ways
    xajax.call = function(sFunction, aArgs, sRequestType,sWrapperPrefix)
    {
	
	    if (sFunction == 'set_region') {
	        document.getElementById('region_id2').innerHTML = loadingMes + " ... ";
		}
		
	    if (sFunction == 'set_city' && document.getElementById('city_id2') ) {
	        document.getElementById('city_id2').innerHTML = loadingMes + " ... ";
		}		
        //show the spinner
         //call the old call function
        return xajax.realCall(sFunction, aArgs, sRequestType,sWrapperPrefix);
    }
    xajax.realProcessResponse = xajax.processResponse;
    //override the call function to bend to our wicked ways
   xajax.processResponse = function(xml)
    {
        //hide the spinner
               
        //call the real processResponse function
        return xajax.realProcessResponse(xml);
    }





