var J = jQuery.noConflict();
var RootPath = "/scn/";	
function cms_website_select(listname){
var selected = listname.options[listname.selectedIndex].value;
window.location.href='/scn/acms/?do=websites.select.'+selected+'';
}
var _CMS = {
tools :     function(fieldid,action,vars){
	var values = $('#'+fieldid).val();

$.post(""+RootPath+"js/scn.tools", {'do': action, 'var':vars,'vals':values}, function(data){
if(data){
if(data.length >0) {
$('#'+fieldid).val(data);

}
}
});
},
call :     function(fieldid,container,action,vars){

	var values = jQuery('#'+fieldid).val();
	
jQuery.post(""+RootPath+"js/scn.tools", {'do': action, 'vars':vars,'vals':values}, function(data){
if(data){
if(data.length >0) {
jQuery('#'+container).show();
jQuery('#'+container).html(data);

}else{
jQuery('#'+container).html("");
jQuery('#'+container).hide();
}
}else{
jQuery('#'+container).html("");
jQuery('#'+container).hide();
}
});
},
_AJX: function(forrmid,divplace,valor_id,secvar){
	var divplace;
	var loginelegido = document.getElementById(forrmid); 
	if(loginelegido){
	loginelegido = loginelegido.value;
	var forrmid = loginelegido;
	}
	var valor_id;
	var secvar;
	var responsers = "";
try{
$.get(""+RootPath+"js/scn.ajx", {'_u': divplace, '_p':loginelegido,'_id':valor_id,'_s': secvar}, function(data){
if(data){
if(data.length >0) {
$('#'+divplace).html(data);
$('#'+divplace).show();
if(data.indexOf("REDIR:")>=0){
 _CMS._AJXREDIR(data);
}
}else{
$('#'+divplace).hide();
}
}else{
$('#'+divplace).hide();
}
});
}catch(e){
jQuery.get(""+RootPath+"js/scn.ajx", {'_u': divplace, '_p':loginelegido,'_id':valor_id,'_s': secvar}, function(data){
if(data){
if(data.length >0) {
jQuery('#'+divplace).html(data);
jQuery('#'+divplace).show();
if(data.indexOf("REDIR:")>=0){
 _CMS._AJXREDIR(data);
}
}else{
jQuery('#'+divplace).hide();
}
}else{
jQuery('#'+divplace).hide();
}
});
}

},
_AJXREDIR :function(str){
var parenthesedText = /\|.*\|/;
var result = str.match(parenthesedText);
if(result){
s =new String(result);
s = s.replace("|","");
s = s.replace("|","");
setTimeout( "history.go()", s );
}

}


}
function _AJX(forrmid,divplace,valor_id,secvar){
	var divplace;
	var loginelegido = document.getElementById(forrmid); 
	if(loginelegido){
	loginelegido = loginelegido.value;
	var forrmid = loginelegido;
	}
	//}
	var valor_id;
	var secvar;
	var responsers = "";
try{
$.get(""+RootPath+"js/scn.ajx", {'_u': divplace, '_p':loginelegido,'_id':valor_id,'_s': secvar}, function(data){
if(data){
if(data.length >0) {
$('#'+divplace).html(data);
$('#'+divplace).show();
if(data.indexOf("REDIR:")>=0){
 _AJXREDIR(data);
}
}else{
$('#'+divplace).hide();
}
}else{
$('#'+divplace).hide();
}
});
}catch(e){
jQuery.get(""+RootPath+"js/scn.ajx", {'_u': divplace, '_p':loginelegido,'_id':valor_id,'_s': secvar}, function(data){
if(data){
if(data.length >0) {
jQuery('#'+divplace).html(data);
jQuery('#'+divplace).show();
if(data.indexOf("REDIR:")>=0){
 _AJXREDIR(data);
}
}else{
jQuery('#'+divplace).hide();
}
}else{
jQuery('#'+divplace).hide();
}
});
}
}
function _toggle(divplace,values){
try{
$('#'+divplace).toggle(values);
}catch(e){
jQuery('#'+divplace).toggle(values);
}
}
	
function _AJXREDIR(str){
var parenthesedText = /\|.*\|/;
var result = str.match(parenthesedText);
if(result){
//alert(result);
s =new String(result);
s = s.replace("|","");
s = s.replace("|","");
//alert(s);
//result.replace(result,"}}");
setTimeout( "history.go()", s );

}
}
function _clearText(field)
{
  if (field.defaultValue == field.value) field.value = '';
  else if (field.value == '') field.value = field.defaultValue;
}
 function _popup(page,width,height) 
 {
 
OpenWin = window.open(page, "pop_window", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,dependent=no,directories=no,width=" + width + ",height=" + height + ",x=50,y=50");
}
function VALME(valfield,cantlenth,mymode) 
{
try{
var realvalue = J('#'+valfield+'').val();
 if(realvalue.length<cantlenth){
	return deactivate(valfield);

 }else{
  switch(mymode){
 case 'email':
 if (!VAL_EMAIL(realvalue)){
	return deactivate(valfield);
 }else{
 return activate(valfield);
 }
 break;
 case 'password':
 if (!VAL_PASSWORD(realvalue,5)){
	return deactivate(valfield);
 }else{
 return activate(valfield);
 }
 break;
case '':
 return activate(valfield);
 break;
}
}}
catch(e){
//alert(e);
}
}
function is_Email(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
		return false;
}
function activate(valfield){
 document.getElementById(valfield).style.border = '1px solid #cccccc';
 document.getElementById(valfield).style.background = '#ffffff';
return true;
}

function deactivate(valfield){
document.getElementById(valfield).style.border = '1px solid #cc0000';
	document.getElementById(valfield).style.background = '#FFFFeC';
return false;
}
function myerrordiv(vardiv,mode,mytext){
try{
if(mode){
 document.getElementById(vardiv).style.display = 'block';
 document.getElementById(vardiv).innerHTML = mytext;
}else{
 document.getElementById(vardiv).style.display = 'none';
}
}catch (e)
{
//alert(mytext);
return false;
}
}

function removeArrayItems(array, item) {
var i = 0;
while (i < array.length) {
if (array[i] == ""+item+"") {
array.splice(i, 1);
} else {
i++;
}
}
return array;
}

function _toggle(sender, container){
J('#'+container).toggle(400);
}
function _toggle_img(sender, container,myclassname){
J('#'+container).toggle(400);
if(J('#'+sender).attr('class') == myclassname){
J('#'+sender).removeClass(myclassname);
J('#'+sender).addClass(myclassname+'_');
}else{
J('#'+sender).removeClass(myclassname+'_');
J('#'+sender).addClass(myclassname);
}
}
function __autorep(from,towhere){
J('#'+towhere+'').html($('#'+from+'').val());
}
function _card_select(sender,hidden,value,selectedcard){
var senderid = sender.id;
J('#'+selectedcard+'').html(J('#'+senderid+'').html());
J('#icarditems').toggle(400);
J('#'+hidden+'').val(value);
}
function cms_show_hide(show,hide){
J('#'+show).show();
J('#'+hide).hide();
}
function cms_chk_boxes(main,name){
if(main.checked == true){
J('input[name^="'+name+'"]').attr('checked', 'checked');
}else{
J('input[name^="'+name+'"]').removeAttr('checked');
}
}
function contstoggle(sender, container){
J('#'+container).toggle(400);
}
function cms_chkbox_display(checkerbox,div){
if(checkerbox.checked){
J('#'+div).show();
}
else{
J('#'+div).hide();
}
}
function cms_confirm(text,url){

var answer = confirm(text)

	if (answer){
		window.location.href = ''+url+'';

	}else{
	return false
	}
}
function cms_content_autorep(from,towhere){
J('#'+towhere+'').html(J('#'+from+'').val());
}
function cms_components_drop(menudiv,mode){
if(mode==1){
J('#'+menudiv).show();
}else{
J('#'+menudiv).hide();
}
}
function cms_droplist_menu(ateventsmenu){var getEls=document.getElementById(ateventsmenu).getElementsByTagName("LI");var getAgn=getEls;for(var i=0;i<getEls.length;i++){getEls[i].onclick=function(){for(var x=0;x<getAgn.length;x++){getAgn[x].className=getAgn[x].className.replace("chtunclick","");getAgn[x].className=getAgn[x].className.replace("chtclick","chtunclick")}if((this.className.indexOf('unclick'))!=-1){this.className=this.className.replace("chtunclick","")}else{this.className+=" chtclick"}}}}

function cms_level_change(listname,text,uid,moder){
var selected = listname.options[listname.selectedIndex].value;
url='/scn/acms/?do='+moder+'.update_level.'+selected+'.'+uid+'';
cms_confirm(text,url);
}
function cms_drop_change(listname,text,_do){
var selected = listname.options[listname.selectedIndex].value;
url='/scn/acms/?do='+_do+'.'+selected;
cms_confirm(text,url);
}
function cms_AJX(action,divplace,fvalue,arrvars){
var variables = arrvars;
var fvals = '';
if(fvalue!=''){
fvals = J('#'+fvalue+'').val();
}
cms_AJX_animate(divplace,true);
J.get("/scn/js/acms.ajx", {'do': ''+action+'','fvars':''+fvals+'','arr': ''+arrvars+''}, function(data){
if(data){
			if(data.length >0) {
			cms_AJX_animate(divplace,false);
				J('#'+divplace+'').html(data);
			}
			}
		});

}
function cms_EMAILCHK(action,divplace,fvalue,pvalue,mode){
var variables = arrvars;
var fvals = '';
var arrvars = [J('#'+fvalue+'').val(), J('#'+pvalue+'').val() ,mode];
cms_AJX(action,divplace,fvalue,arrvars);
}
function cms_AJX_animate(divplace,mode){
if(mode==true){
J('#cms_loading').css("padding:","30px");
J('#cms_loading').css("background","url(/scn/images/loading_small.gif) no-repeat top right");
}else{
J('#cms_loading').css("padding:","0px");
J('#cms_loading').css("background","none");
}
/*if(mode==true){
J('#'+divplace+'').css("padding:","30px");
J('#'+divplace+'').css("background","url(/scn/images/loading_small.gif) no-repeat top left");
}else{
J('#'+divplace+'').css("padding:","0px");
J('#'+divplace+'').css("background","none");
}*/
}
 function stoperror(){
	return true
}

//window.onerror=stoperror

