
if(typeof HostcmsEscape=='undefined')
{
function HostcmsEscape(str)
{
var trans=[];
for(var i=0x410;i<=0x44F;i++)
{
trans[i]=i-0x350;
}
trans[0x401]=0xA8;
trans[0x451]=0xB8;
var ret=[];
for(var i=0;i<str.length;i++)
{
var n=str.charCodeAt(i);
if(typeof trans[n]!='undefined')
{
n=trans[n];
}
if(n<=0xFF)
{
ret.push(n);
}
}
var res=escape(String.fromCharCode.apply(null,ret)).replace('+','%2B').replace(':','%3A').replace('/','%2F').replace('?','%3F').replace('=','%3D').replace('&','%26').replace('@','%40').replace('#','%23').replace('$','%24').replace(';','%3B');
return res;
}
}
document.onkeydown=DoKeyDown;
function DoKeyDown(event)
{
if(!document.getElementById)
{
return;
}
if(window.event)
{
event=window.event;
}
if(event.ctrlKey)
{
var Element=null;
switch(event.keyCode?event.keyCode:event.which?event.which:null)
{
case 0x25:
Element=document.getElementById('id_prev');
break;
case 0x27:
Element=document.getElementById('id_next');
break;
}
if(Element&&Element.href)
{
document.location=Element.href;
}
}
}
function DisableTinyMCE()
{
if(typeof tinyMCE!='undefined')
{
textarea_array=document.getElementsByTagName("textarea");
for(var i=0;i<textarea_array.length;i++)
{
var elementId=textarea_array[i].id;
if(tinyMCE.getInstanceById(elementId)!=null)
{
textarea_array[i].disabled=true;
tinyMCE.execCommand('mceRemoveControl',false,elementId);
}
}
}
}
function runScripts(scripts)
{
if(!scripts)
{
return false;
}
for(var i=0;i<scripts.length;i++)
{
var thisScript=scripts[i];
var text;
if(thisScript.src)
{
var newScript=document.createElement("script");
newScript.type=thisScript.type;
newScript.language=thisScript.language;
newScript.src=thisScript.src;
document.getElementsByTagName('head')[0].appendChild(newScript);
}
else if(text=(thisScript.text||thisScript.innerHTML))
{
var text=(""+text).replace(/^\s*<!\-\-/,'').replace(/\-\->\s*$/,'');
var newScript=document.createElement("script");
newScript.setAttribute("type","text/javascript");
newScript.text=text;
var script_node=document.getElementsByTagName('head')[0].appendChild(newScript);
}
}
}
function sendRequest(action,method,callback_function)
{
var req=new JsHttpRequest();
ShowLoadingScreen();
req.onreadystatechange=function()
{
if(req.readyState==4)
{
document.body.style.cursor='';
HideLoadingScreen();
if(typeof callback_function!='undefined')
{
callback_function(req.responseJS);
}
return true;
}
}
req.open(method,action,true);
req.send(null);
document.body.style.cursor="wait";
}
function DoLoadAjax(AAction,AAdditionalParams,AAdminFromsId,AOperation,ALimit,AOnPage,AOrderFieldId,AOrderDirection)
{
DisableTinyMCE();
if(AOperation=='')
{
return false;
}
if(AOrderFieldId!=0)
{
sOrder='&order_field_id='+AOrderFieldId+
'&order_field_direction='+AOrderDirection;
}
else
{
sOrder='';
}
cbOnPage=document.getElementById('id_on_page');
if(AOnPage)
{
sOnPage='&admin_forms_on_page='+AOnPage;
}
else
{
if(cbOnPage)
{
sOnPage='&admin_forms_on_page='+cbOnPage.options[cbOnPage.selectedIndex].value;
}
else
{
sOnPage='';
}
}
sElements='';
sFilter='';
reg_filter=/admin_form_filter_.+/;
element_array=document.getElementsByTagName("input");
if(element_array.length>0)
{
for(var i=0;i<element_array.length;i++)
{
element_name=element_array[i].getAttribute('name');
if(element_name==undefined)
{
continue;
}
if(element_name.search("check_")!=-1&&
element_name.search("_fv_")==-1)
{
if(element_array[i].checked)
{
sElements=sElements+'&'+element_name+'=1';
value_element_array=document.getElementsByTagName("input");
if(value_element_array.length>0)
{
for(var j=0;j<value_element_array.length;j++)
{
value_element_name=value_element_array[j].name;
if(typeof value_element_name=='undefined')
{
continue;
}
if(value_element_name.search("_fv_")!=-1&&
value_element_name.search(element_name)!=-1)
{
if(value_element_array[j].getAttribute('type')=='text')
{
sElements=sElements+'&'+value_element_name+
'='+value_element_array[j].value;
}
else if(value_element_array[j].getAttribute('type')=='checkbox')
{
if(value_element_array[j].checked)
{
sElements=sElements+'&'+value_element_name+'=1';
}
else
{
sElements=sElements+'&'+value_element_name+'=0';
}
}
}
}
}
value_element_array=document.getElementsByTagName("select");
if(value_element_array.length>0)
{
for(var j=0;j<value_element_array.length;j++)
{
value_element_name=value_element_array[j].name;
if(typeof value_element_name=='undefined')
{
continue;
}
if(value_element_name.search("_fv_")!=-1&&
value_element_name.search(element_name)!=-1)
{
sElements=sElements+'&'+value_element_name+
'='+HostcmsEscape(value_element_array[j].options[value_element_array[j].selectedIndex].value);
}
}
}
}
}
if(reg_filter.test(element_name))
{
if(element_array[i].value.length<256)
{
sFilter=sFilter+'&'+element_name+'='+HostcmsEscape(element_array[i].value);
}
}
}
}
element_array=document.getElementsByTagName("select");
if(element_array.length>0)
{
for(var i=0;i<element_array.length;i++)
{
element_name=element_array[i].getAttribute('name');
if(reg_filter.test(element_name))
{
sFilter=sFilter+'&'+element_name+'='+HostcmsEscape(element_array[i].value);
}
}
}
sParams=AAdditionalParams;
if(ALimit===false)
{
ALimit='';
}
else
{
ALimit='&limit='+ALimit;
}
cmsrequest=AAction+'?admin_forms_id='+AAdminFromsId+
'&hostcmsAAction='+HostcmsEscape(AAction)+
'&hostcmsAAdditionalParams='+HostcmsEscape(AAdditionalParams)+
'&operation='+AOperation+ALimit+sOnPage+sFilter+
sElements+sOrder+sParams;
if(cmsrequest.length<2000)
{
method='get';
}
else
{
method='post';
}
sendRequest(cmsrequest,method,callbackfunction_DoLoadAjax);
}
function callbackfunction_DoLoadAjax(responseJS)
{
sended_request=false;
if(responseJS!=null)
{
if(typeof responseJS.error!='undefined')
{
var div_id_message=document.getElementById('id_message');
if(div_id_message)
{
div_id_message.innerHTML=responseJS.error;
}
}
if(typeof responseJS.form_html!='undefined')
{
if(cmsrequest!=''
&&function_exists('getCmsUrl')
&&getCmsUrl()!=cmsrequest)
{
setLocation(cmsrequest);
}
if(function_exists('saveLocation'))
{
saveLocation(getCmsUrl());
}
DisableTinyMCE();
html=responseJS.form_html;
document.getElementById('id_content').innerHTML=html;
runScripts(document.getElementById('id_content').getElementsByTagName('SCRIPT'));
cmsrequest='';
}
if(typeof responseJS.title!='undefined'&&responseJS.title!='')
{
document.title=responseJS.title;
}
if(typeof responseJS.redirect!='undefined')
{
if(responseJS.redirect!='')
{
ShowLoadingScreen();
location=responseJS.redirect;
}
}
}
}
function doSendForm(AAction,AAdditionalParams,ButtonObject,AAdminFromsId,AOperation,ALimit,AOnPage)
{
var FormNode=ButtonObject.parentNode;
while(FormNode.nodeName.toLowerCase()!='form')
{
var FormNode=FormNode.parentNode;
}
FormID=FormNode.id;
var HiddenInput=document.getElementById(ButtonObject.name);
if(null==HiddenInput&&undefined==HiddenInput||HiddenInput.type!='hidden')
{
var ElementInput=document.createElement("input");
ElementInput.setAttribute("type","hidden");
ElementInput.setAttribute("id",ButtonObject.name);
ElementInput.setAttribute("name",ButtonObject.name);
var InputNode=FormNode.appendChild(ElementInput);
}
if(typeof tinyMCE!='undefined')
{
tinyMCE.triggerSave();
}
var JsHttpRequestSendForm=new JsHttpRequest();
JsHttpRequestSendForm.onreadystatechange=function()
{
if(JsHttpRequestSendForm.readyState==4)
{
document.body.style.cursor='';
HideLoadingScreen();
if(typeof JsHttpRequestSendForm.responseJS!='undefined')
{
if(typeof JsHttpRequestSendForm.responseJS.error!='undefined')
{
var div_id_message=document.getElementById('id_message');
if(div_id_message)
{
var span=document.createElement("span");
span.style.display='none';
span.innerHTML="Stupid IE. "+JsHttpRequestSendForm.responseJS.error;
runScripts(span.getElementsByTagName('SCRIPT'));
div_id_message.innerHTML=JsHttpRequestSendForm.responseJS.error;
}
}
if(typeof JsHttpRequestSendForm.responseJS.form_html!='undefined'&&JsHttpRequestSendForm.responseJS.form_html!='')
{
DisableTinyMCE();
HideWindow(prev_window);
}
}
return true;
}
}
var FormAction=FormNode.attributes['action'].value;
var FormMethod=FormNode.getAttribute('method');
if(AOnPage)
{
sOnPage='&admin_forms_on_page='+AOnPage;
}
else
{
sOnPage='';
}
if(ALimit==0)
{
ALimit='';
}
else
{
ALimit='&limit='+ALimit;
}
FormAction+=(FormAction.indexOf('?')>=0?'&':'?')+'hostcmsAAction='+HostcmsEscape(AAction)+
'&hostcmsAAdditionalParams='+HostcmsEscape(AAdditionalParams)+AAdditionalParams+
'&operation='+AOperation+ALimit+sOnPage;
JsHttpRequestSendForm.open(FormMethod,FormAction,true);
JsHttpRequestSendForm.send({query:FormNode});
var div_id_message=document.getElementById('id_message');
if(div_id_message)
{
div_id_message.innerHTML='';
}
document.body.style.cursor="wait";
ShowLoadingScreen();
return false;
}
function TrigerSingleAction(AAction,AAdditionalParams,AOperation,AItemName,AAdminFromsId,ALimit,AOnPage,AOrderFieldId,AOrderDirection)
{
var ElementID='id_'+AItemName;
cbItem=document.getElementById(ElementID);
if(cbItem)
{
element_array=document.getElementsByTagName("input");
if(element_array.length>0)
{
for(var i=0;i<element_array.length;i++)
{
if(element_array[i].getAttribute('name')==null)
{
continue;
}
if(element_array[i].getAttribute('name').search("check_")!=-1
&&element_array[i].getAttribute('name').search("_fv_")==-1)
{
element_array[i].checked=false;
}
}
}
cbItem.checked=true;
}
else
{
var reg=/id_check_(\d+)_(\S+)/;
var arr=reg.exec(ElementID);
var ElementDiv=document.createElement("div");
ElementDiv.setAttribute("style","display: none");
var DivNode=document.getElementById('id_content').appendChild(ElementDiv);
var ElementCheckbox=null;
try{
ElementCheckbox=document.createElement('<input name="'+AItemName+'" type="checkbox" checked="">');
}catch(e){
}
if(!ElementCheckbox)
{
ElementCheckbox=document.createElement("input");
ElementCheckbox.setAttribute("type","checkbox");
ElementCheckbox.setAttribute("name",AItemName);
ElementCheckbox.setAttribute("checked",true);
ElementCheckbox.setAttribute("value","1");
}
var ElementNode=DivNode.appendChild(ElementCheckbox);
}
var admin_forms_all_check=document.getElementById('id_admin_forms_all_check');
if(admin_forms_all_check!=undefined)
{
admin_forms_all_check.checked=false;
}
if(ALimit==0)
{
ALimit=false;
}
DoLoadAjax(AAction,AAdditionalParams,AAdminFromsId,AOperation,ALimit,AOnPage,AOrderFieldId,AOrderDirection);
}
function AjaxSendForm(callback_function,AAdditionalParams,ButtonObject)
{
var FormNode=ButtonObject.parentNode;
while(FormNode.nodeName.toLowerCase()!='form')
{
var FormNode=FormNode.parentNode;
}
FormID=FormNode.id;
var HiddenInput=document.getElementById(ButtonObject.name);
if(null==HiddenInput&&undefined==HiddenInput||HiddenInput.type!='hidden')
{
var ElementInput=document.createElement("input");
ElementInput.setAttribute("type","hidden");
ElementInput.setAttribute("id",ButtonObject.name);
ElementInput.setAttribute("name",ButtonObject.name);
var InputNode=FormNode.appendChild(ElementInput);
}
if(typeof tinyMCE!='undefined')
{
tinyMCE.triggerSave();
}
var JsHttpRequestSendForm=new JsHttpRequest();
JsHttpRequestSendForm.onreadystatechange=function()
{
if(JsHttpRequestSendForm.readyState==4)
{
document.body.style.cursor='';
HideLoadingScreen();
if(typeof callback_function!='undefined')
{
callback_function(JsHttpRequestSendForm.responseJS);
}
return true;
}
}
var FormAction=FormNode.attributes['action'].value;
var FormMethod=FormNode.getAttribute('method');
FormAction+=(FormAction.indexOf('?')>=0?'&':'?')+AAdditionalParams;
JsHttpRequestSendForm.open(FormMethod,FormAction,true);
JsHttpRequestSendForm.send({query:FormNode});
document.body.style.cursor="wait";
ShowLoadingScreen();
return false;
}
function ShowLoadingScreen()
{
var fade_div=document.getElementById('id_admin_forms_fade');
if(fade_div==null)
{
var fade_div=document.createElement("div");
var body=document.getElementsByTagName("body")[0];
body.appendChild(fade_div);
fade_div.id="id_admin_forms_fade";
fade_div.style.zIndex=999;
fade_div.className="shadowed";
fade_div.style.position='absolute';
fade_div.style.left='50%';
fade_div.style.top='50%';
var fade_div_img=document.createElement("img");
fade_div_img.id='id_fade_div_img';
fade_div_img.src='/hostcmsfiles/images/ajax_loader.gif';
fade_div.appendChild(fade_div_img);
var shadowed_tl=document.createElement("div");
shadowed_tl.className="tl";
fade_div.appendChild(shadowed_tl);
var shadowed_t=document.createElement("div");
shadowed_t.className="t";
fade_div.appendChild(shadowed_t);
var shadowed_tr=document.createElement("div");
shadowed_tr.className="tr";
fade_div.appendChild(shadowed_tr);
var shadowed_l=document.createElement("div");
shadowed_l.className="l";
fade_div.appendChild(shadowed_l);
var shadowed_r=document.createElement("div");
shadowed_r.className="r";
fade_div.appendChild(shadowed_r);
var shadowed_bl=document.createElement("div");
shadowed_bl.className="bl";
fade_div.appendChild(shadowed_bl);
var shadowed_b=document.createElement("div");
shadowed_b.className="b";
fade_div.appendChild(shadowed_b);
var shadowed_br=document.createElement("div");
shadowed_br.className="br";
fade_div.appendChild(shadowed_br);
groupChildElements=fade_div.children;
if(groupChildElements!=undefined)
{
for(i=0;i<groupChildElements.length;i++)
{
if(groupChildElements[i].className=='b'|groupChildElements[i].className=='t')
{
groupChildElements[i].style.width=fade_div.clientWidth+'px';
}
if(groupChildElements[i].className=='r'|groupChildElements[i].className=='l')
{
groupChildElements[i].style.height=fade_div.clientHeight+'px';
}
}
}
fade_div.style.display='none';
}
fade_div.style.display='block';
var arrayPageSize=getPageSize();
var arrayPageSize=getPageSize();
var arrayScrollXY=getScrollXY();
var clientHeight=fade_div.clientHeight;
fade_div.style.top=((arrayPageSize[3]-clientHeight)/2+arrayScrollXY[1])+'px';
var clientWidth=fade_div.clientWidth;
fade_div.style.left=((arrayPageSize[2]-clientWidth)/2+arrayScrollXY[0])+'px';
}
function HideLoadingScreen()
{
fade_div=document.getElementById('id_admin_forms_fade');
if(typeof fade_div!='undefined')
{
fade_div.style.display="none";
}
}
function AddLoadFileField(container_id,inpit_prefix)
{
cbItem=document.getElementById(container_id);
if(cbItem)
{
element_array=cbItem.getElementsByTagName("input");
count_input=element_array.length;
var ElementBr=document.createElement("br");
cbItem.appendChild(ElementBr);
var ElementInput=document.createElement("input");
ElementInput.setAttribute("size","30");
ElementInput.setAttribute("name",inpit_prefix+(count_input+1));
ElementInput.setAttribute("type","file");
ElementInput.setAttribute("title","Прикрепить файл");
cbItem.appendChild(ElementInput);
}
}
function sendBackgroundRequest(action,method,callback_function)
{
var req=new JsHttpRequest();
req.onreadystatechange=function()
{
if(req.readyState==4)
{
document.body.style.cursor='';
if(typeof callback_function!='undefined')
{
callback_function(req.responseJS);
}
return true;
}
}
req.open(method,action,true);
req.send(null);
document.body.style.cursor="wait";
ShowLoadingScreen();
}
var prev_comment=0;
function cr(comment_id)
{
if(prev_comment&&prev_comment!=comment_id)
{
document.getElementById(prev_comment).style.display='none';
}
var div=document.getElementById(comment_id);
if(div.style.display!='block')
{
div.style.display='block';
}
else
{
div.style.display='none';
}
prev_comment=comment_id;
}
var temp_ChildId='';
var temp_CurrenElementId='';
var menu_timeout_id=0;
var filter_timeout_id=0;
function TopMenuOver(CurrenElementId,ChildId)
{
clearTimeout(menu_timeout_id);
if(temp_CurrenElementId!=''
&&temp_CurrenElementId!=CurrenElementId)
{
var oTemp_ChildId=document.getElementById(temp_ChildId);
if(oTemp_ChildId)
{
oTemp_ChildId.style.display="none";
}
}
temp_ChildId=ChildId;
temp_CurrenElementId=CurrenElementId;
if(CurrenElementId==undefined)
{
return false;
}
if(ChildId!='')
{
var oChildId=document.getElementById(ChildId);
if(oChildId)
{
oChildId.style.display="block";
}
}
}
function TopMenuOut(CurrenElementId,ChildId)
{
if(CurrenElementId==undefined)
{
return false;
}
if(ChildId!='')
{
var oChildId=document.getElementById(ChildId);
if(oChildId)
{
menu_timeout_id=setTimeout(function(){oChildId.style.display="none"},300);
}
}
}
function callbackfunction_AddIntoCart(responseJS)
{
sended_request=false;
if(typeof responseJS!='undefined')
{
if(typeof responseJS.cart!='undefined')
{
var little_cart=document.getElementById('little_cart');
if(little_cart)
{
var span=document.createElement("span");
span.style.display='none';
span.innerHTML="Stupid IE. "+responseJS.cart;
runScripts(span.getElementsByTagName('SCRIPT'));
little_cart.innerHTML=responseJS.cart;
}
else
{
alert('Ошибка! Краткая корзина не найдена');
}
}
}
}
function AddIntoCart(shop_path,item_id,item_count)
{
cmsrequest=shop_path+'cart/?ajax_add_item_id='+item_id+'&count='+item_count;
sendRequest(cmsrequest,'get',callbackfunction_AddIntoCart);
return false;
}
function callbackfunction_CheckBlogUrl(responseJS)
{
sended_request=false;
if(typeof responseJS!='undefined')
{
if(typeof responseJS.check_url_result!='undefined')
{
var check_url=document.getElementById('check_url');
if(responseJS.check_url_result==0)
{
check_url.className='error';
html='Адрес занят.';
}
else
{
check_url.className='green';
html='Адрес свободен.';
}
if(check_url)
{
check_url.innerHTML=html;
}
else
{
alert('Ошибка! Блок для вывода результатов запроса не найден');
}
}
}
}
function CheckBlogUrl(blog_path,blog_url,parent_id,id)
{
cmsrequest=blog_path+'?ajax_check_blog_url='+blog_url+'&group_parent_id='+parent_id+'&group_id='+id;
var check_url=document.getElementById('check_url');
if(check_url)
{
check_url.innerHTML='<img src="/hostcmsfiles/images/ajax_loader_mini.gif"/>';
}
sendBackgroundRequest(cmsrequest,'get',callbackfunction_CheckBlogUrl);
return false;
}
function SelectAllItemsByPrefix(ASelect,prefix)
{
element_array=document.getElementsByTagName("input");
if(element_array.length>0)
{
for(var i=0;i<element_array.length;i++)
{
if(element_array[i].name.search(prefix)!=-1)
{
element_array[i].checked=ASelect;
}
}
}
}
if(document.images)
{
var img=new Object();
img["tl_angle_pull_down"]=new Image();
img["tl_angle_pull_down"].src='/images/tl_angle_pull_down.png';
img["tr_angle_pull_down"]=new Image();
img["tr_angle_pull_down"].src='/images/tr_angle_pull_down.png';
img["bl_angle_pull_down"]=new Image();
img["bl_angle_pull_down"].src='/images/bl_angle_pull_down.png';
img["br_angle_pull_down"]=new Image();
img["br_angle_pull_down"].src='/images/br_angle_pull_down.png';
img["ajax_loader_min"]=new Image();
img["ajax_loader_min"].src='/hostcmsfiles/images/ajax_loader_mini.gif';
}
function JsHttpRequest(){
var t=this;
t.onreadystatechange=null;
t.readyState=0;
t.responseText=null;
t.responseXML=null;
t.status=200;
t.statusText="OK";
t.responseJS=null;
t.caching=false;
t.loader=null;
t.session_name="PHPSESSID";
t._ldObj=null;
t._reqHeaders=[];
t._openArgs=null;
t._errors={
inv_form_el:'Invalid FORM element detected: name=%, tag=%',
must_be_single_el:'If used, <form> must be a single HTML element in the list.',
js_invalid:'JavaScript code generated by backend is invalid!\n%',
url_too_long:'Cannot use so long query with GET request (URL is larger than % bytes)',
unk_loader:'Unknown loader: %',
no_loaders:'No loaders registered at all, please check JsHttpRequest.LOADERS array',
no_loader_matched:'Cannot find a loader which may process the request. Notices are:\n%'
}
t.abort=function(){with(this){
if(_ldObj&&_ldObj.abort)_ldObj.abort();
_cleanup();
if(readyState==0){
return;
}
if(readyState==1&&!_ldObj){
readyState=0;
return;
}
_changeReadyState(4,true);
}}
t.open=function(method,url,asyncFlag,username,password){with(this){
if(url.match(/^((\w+)\.)?(GET|POST)\s+(.*)/i)){
this.loader=RegExp.$2?RegExp.$2:null;
method=RegExp.$3;
url=RegExp.$4;
}
try{
if(
document.location.search.match(new RegExp('[&?]'+session_name+'=([^&?]*)'))
||document.cookie.match(new RegExp('(?:;|^)\\s*'+session_name+'=([^;]*)'))
){
url+=(url.indexOf('?')>=0?'&':'?')+session_name+"="+this.escape(RegExp.$1);
}
}catch(e){}
_openArgs={
method:(method||'').toUpperCase(),
url:url,
asyncFlag:asyncFlag,
username:username!=null?username:'',
password:password!=null?password:''
}
_ldObj=null;
_changeReadyState(1,true);
return true;
}}
t.send=function(content){
if(!this.readyState){
return;
}
this._changeReadyState(1,true);
this._ldObj=null;
var queryText=[];
var queryElem=[];
if(!this._hash2query(content,null,queryText,queryElem))return;
var hash=null;
if(this.caching&&!queryElem.length){
hash=this._openArgs.username+':'+this._openArgs.password+'@'+this._openArgs.url+'|'+queryText+"#"+this._openArgs.method;
var cache=JsHttpRequest.CACHE[hash];
if(cache){
this._dataReady(cache[0],cache[1]);
return false;
}
}
var loader=(this.loader||'').toLowerCase();
if(loader&&!JsHttpRequest.LOADERS[loader])return this._error('unk_loader',loader);
var errors=[];
var lds=JsHttpRequest.LOADERS;
for(var tryLoader in lds){
var ldr=lds[tryLoader].loader;
if(!ldr)continue;
if(loader&&tryLoader!=loader)continue;
var ldObj=new ldr(this);
JsHttpRequest.extend(ldObj,this._openArgs);
JsHttpRequest.extend(ldObj,{
queryText:queryText.join('&'),
queryElem:queryElem,
id:(new Date().getTime())+""+JsHttpRequest.COUNT++,
hash:hash,
span:null
});
var error=ldObj.load();
if(!error){
this._ldObj=ldObj;
JsHttpRequest.PENDING[ldObj.id]=this;
return true;
}
if(!loader){
errors[errors.length]='- '+tryLoader.toUpperCase()+': '+this._l(error);
}else{
return this._error(error);
}
}
return tryLoader?this._error('no_loader_matched',errors.join('\n')):this._error('no_loaders');
}
t.getAllResponseHeaders=function(){with(this){
return _ldObj&&_ldObj.getAllResponseHeaders?_ldObj.getAllResponseHeaders():[];
}}
t.getResponseHeader=function(label){with(this){
return _ldObj&&_ldObj.getResponseHeader?_ldObj.getResponseHeader(label):null;
}}
t.setRequestHeader=function(label,value){with(this){
_reqHeaders[_reqHeaders.length]=[label,value];
}}
t._dataReady=function(text,js){with(this){
if(caching&&_ldObj)JsHttpRequest.CACHE[_ldObj.hash]=[text,js];
responseText=responseXML=text;
responseJS=js;
if(js!==null){
status=200;
statusText="OK";
}else{
status=500;
statusText="Internal Server Error";
}
_changeReadyState(2);
_changeReadyState(3);
_changeReadyState(4);
_cleanup();
}}
t._l=function(args){
var i=0,p=0,msg=this._errors[args[0]];
while((p=msg.indexOf('%',p))>=0){
var a=args[++i]+"";
msg=msg.substring(0,p)+a+msg.substring(p+1,msg.length);
p+=1+a.length;
}
return msg;
}
t._error=function(msg){
msg=this._l(typeof(msg)=='string'?arguments:msg)
msg="JsHttpRequest: "+msg;
if(!window.Error){
throw msg;
}else if((new Error(1,'test')).description=="test"){
throw new Error(1,msg);
}else{
throw new Error(msg);
}
}
t._hash2query=function(content,prefix,queryText,queryElem){
if(prefix==null)prefix="";
if((''+typeof(content)).toLowerCase()=='object'){
var formAdded=false;
if(content&&content.parentNode&&content.parentNode.appendChild&&content.tagName&&content.tagName.toUpperCase()=='FORM'){
content={form:content};
}
for(var k in content){
var v=content[k];
if(v instanceof Function)continue;
var curPrefix=prefix?prefix+'['+this.escape(k)+']':this.escape(k);
var isFormElement=v&&v.parentNode&&v.parentNode.appendChild&&v.tagName;
if(isFormElement){
var tn=v.tagName.toUpperCase();
if(tn=='FORM'){
formAdded=true;
}else if(tn=='INPUT'||tn=='TEXTAREA'||tn=='SELECT'){
}else{
return this._error('inv_form_el',(v.name||''),v.tagName);
}
queryElem[queryElem.length]={name:curPrefix,e:v};
}else if(v instanceof Object){
this._hash2query(v,curPrefix,queryText,queryElem);
}else{
if(v===null)continue;
if(v===true)v=1;
if(v===false)v='';
queryText[queryText.length]=curPrefix+"="+this.escape(''+v);
}
if(formAdded&&queryElem.length>1){
return this._error('must_be_single_el');
}
}
}else{
queryText[queryText.length]=content;
}
return true;
}
t._cleanup=function(){
var ldObj=this._ldObj;
if(!ldObj)return;
JsHttpRequest.PENDING[ldObj.id]=false;
var span=ldObj.span;
if(!span)return;
ldObj.span=null;
var closure=function(){
span.parentNode.removeChild(span);
}
JsHttpRequest.setTimeout(closure,50);
}
t._changeReadyState=function(s,reset){with(this){
if(reset){
status=statusText=responseJS=null;
responseText='';
}
readyState=s;
if(onreadystatechange)onreadystatechange();
}}
t.escape=function(s){
return escape(s).replace(new RegExp('\\+','g'),'%2B');
}
}
JsHttpRequest.COUNT=0;
JsHttpRequest.MAX_URL_LEN=2000;
JsHttpRequest.CACHE={};
JsHttpRequest.PENDING={};
JsHttpRequest.LOADERS={};
JsHttpRequest._dummy=function(){};
JsHttpRequest.TIMEOUTS={s:window.setTimeout,c:window.clearTimeout};
JsHttpRequest.setTimeout=function(func,dt){
window.JsHttpRequest_tmp=JsHttpRequest.TIMEOUTS.s;
if(typeof(func)=="string"){
id=window.JsHttpRequest_tmp(func,dt);
}else{
var id=null;
var mediator=function(){
func();
delete JsHttpRequest.TIMEOUTS[id];
}
id=window.JsHttpRequest_tmp(mediator,dt);
JsHttpRequest.TIMEOUTS[id]=mediator;
}
window.JsHttpRequest_tmp=null;
return id;
}
JsHttpRequest.clearTimeout=function(id){
window.JsHttpRequest_tmp=JsHttpRequest.TIMEOUTS.c;
delete JsHttpRequest.TIMEOUTS[id];
var r=window.JsHttpRequest_tmp(id);
window.JsHttpRequest_tmp=null;
return r;
}
JsHttpRequest.query=function(url,content,onready,nocache){
var req=new this();
req.caching=!nocache;
req.onreadystatechange=function(){
if(req.readyState==4){
onready(req.responseJS,req.responseText);
}
}
req.open(null,url,true);
req.send(content);
}
JsHttpRequest.dataReady=function(d){
var th=this.PENDING[d.id];
delete this.PENDING[d.id];
if(th){
th._dataReady(d.text,d.js);
}else if(th!==false){
throw"dataReady(): unknown pending id: "+d.id;
}
}
JsHttpRequest.extend=function(dest,src){
for(var k in src)dest[k]=src[k];
}
JsHttpRequest.LOADERS.xml={loader:function(req){
JsHttpRequest.extend(req._errors,{
xml_no:'Cannot use XMLHttpRequest or ActiveX loader: not supported',
xml_no_diffdom:'Cannot use XMLHttpRequest to load data from different domain %',
xml_no_headers:'Cannot use XMLHttpRequest loader or ActiveX loader, POST method: headers setting is not supported, needed to work with encodings correctly',
xml_no_form_upl:'Cannot use XMLHttpRequest loader: direct form elements using and uploading are not implemented'
});
this.load=function(){
if(this.queryElem.length)return['xml_no_form_upl'];
if(this.url.match(new RegExp('^([a-z]+://[^\\/]+)(.*)','i'))){
if(RegExp.$1.toLowerCase()!=document.location.protocol+'//'+document.location.hostname.toLowerCase()){
return['xml_no_diffdom',RegExp.$1];
}
}
var xr=null;
if(window.XMLHttpRequest){
try{xr=new XMLHttpRequest()}catch(e){}
}else if(window.ActiveXObject){
try{xr=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}
if(!xr)try{xr=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}
}
if(!xr)return['xml_no'];
var canSetHeaders=window.ActiveXObject||xr.setRequestHeader;
if(!this.method)this.method=canSetHeaders&&this.queryText.length?'POST':'GET';
if(this.method=='GET'){
if(this.queryText)this.url+=(this.url.indexOf('?')>=0?'&':'?')+this.queryText;
this.queryText='';
if(this.url.length>JsHttpRequest.MAX_URL_LEN)return['url_too_long',JsHttpRequest.MAX_URL_LEN];
}else if(this.method=='POST'&&!canSetHeaders){
return['xml_no_headers'];
}
this.url+=(this.url.indexOf('?')>=0?'&':'?')+'JsHttpRequest='+(req.caching?'0':this.id)+'-xml';
var id=this.id;
xr.onreadystatechange=function(){
if(xr.readyState!=4)return;
xr.onreadystatechange=JsHttpRequest._dummy;
req.status=null;
try{
req.status=xr.status;
req.responseText=xr.responseText;
}catch(e){}
if(!req.status)return;
try{
eval('JsHttpRequest._tmp = function(id) { var d = '+req.responseText+'; d.id = id; JsHttpRequest.dataReady(d); }');
}catch(e){
return req._error('js_invalid',req.responseText)
}
JsHttpRequest._tmp(id);
JsHttpRequest._tmp=null;
};
xr.open(this.method,this.url,true,this.username,this.password);
if(canSetHeaders){
for(var i=0;i<req._reqHeaders.length;i++){
xr.setRequestHeader(req._reqHeaders[i][0],req._reqHeaders[i][1]);
}
xr.setRequestHeader('Content-Type','application/octet-stream');
}
xr.send(this.queryText);
this.span=null;
this.xr=xr;
return null;
}
this.getAllResponseHeaders=function(){
return this.xr.getAllResponseHeaders();
}
this.getResponseHeader=function(label){
return this.xr.getResponseHeader(label);
}
this.abort=function(){
this.xr.abort();
this.xr=null;
}
}}
JsHttpRequest.LOADERS.script={loader:function(req){
JsHttpRequest.extend(req._errors,{
script_only_get:'Cannot use SCRIPT loader: it supports only GET method',
script_no_form:'Cannot use SCRIPT loader: direct form elements using and uploading are not implemented'
})
this.load=function(){
if(this.queryText)this.url+=(this.url.indexOf('?')>=0?'&':'?')+this.queryText;
this.url+=(this.url.indexOf('?')>=0?'&':'?')+'JsHttpRequest='+this.id+'-'+'script';
this.queryText='';
if(!this.method)this.method='GET';
if(this.method!=='GET')return['script_only_get'];
if(this.queryElem.length)return['script_no_form'];
if(this.url.length>JsHttpRequest.MAX_URL_LEN)return['url_too_long',JsHttpRequest.MAX_URL_LEN];
var th=this,d=document,s=null,b=d.body;
if(!window.opera){
this.span=s=d.createElement('SCRIPT');
var closure=function(){
s.language='JavaScript';
if(s.setAttribute)s.setAttribute('src',th.url);else s.src=th.url;
b.insertBefore(s,b.lastChild);
}
}else{
this.span=s=d.createElement('SPAN');
s.style.display='none';
b.insertBefore(s,b.lastChild);
s.innerHTML='Workaround for IE.<s'+'cript></'+'script>';
var closure=function(){
s=s.getElementsByTagName('SCRIPT')[0];
s.language='JavaScript';
if(s.setAttribute)s.setAttribute('src',th.url);else s.src=th.url;
}
}
JsHttpRequest.setTimeout(closure,10);
return null;
}
}}
JsHttpRequest.LOADERS.form={loader:function(req){
JsHttpRequest.extend(req._errors,{
form_el_not_belong:'Element "%" does not belong to any form!',
form_el_belong_diff:'Element "%" belongs to a different form. All elements must belong to the same form!',
form_el_inv_enctype:'Attribute "enctype" of the form must be "%" (for IE), "%" given.'
})
this.load=function(){
var th=this;
if(!th.method)th.method='POST';
th.url+=(th.url.indexOf('?')>=0?'&':'?')+'JsHttpRequest='+th.id+'-'+'form';
if(th.method=='GET'){
if(th.queryText)th.url+=(th.url.indexOf('?')>=0?'&':'?')+th.queryText;
if(th.url.length>JsHttpRequest.MAX_URL_LEN)return['url_too_long',JsHttpRequest.MAX_URL_LEN];
var p=th.url.split('?',2);
th.url=p[0];
th.queryText=p[1]||'';
}
var form=null;
var wholeFormSending=false;
if(th.queryElem.length){
if(th.queryElem[0].e.tagName.toUpperCase()=='FORM'){
form=th.queryElem[0].e;
wholeFormSending=true;
th.queryElem=[];
}else{
form=th.queryElem[0].e.form;
for(var i=0;i<th.queryElem.length;i++){
var e=th.queryElem[i].e;
if(!e.form){
return['form_el_not_belong',e.name];
}
if(e.form!=form){
return['form_el_belong_diff',e.name];
}
}
}
if(th.method=='POST'){
var need="multipart/form-data";
var given=(form.attributes.encType&&form.attributes.encType.nodeValue)||(form.attributes.enctype&&form.attributes.enctype.value)||form.enctype;
if(given!=need){
return['form_el_inv_enctype',need,given];
}
}
}
var d=form&&(form.ownerDocument||form.document)||document;
var ifname='jshr_i_'+th.id;
var s=th.span=d.createElement('DIV');
s.style.position='absolute';
s.style.display='none';
s.style.visibility='hidden';
s.innerHTML=
(form?'':'<form'+(th.method=='POST'?' enctype="multipart/form-data" method="post"':'')+'></form>')+
'<iframe name="'+ifname+'" id="'+ifname+'" style="width:0px; height:0px; overflow:hidden; border:none"></iframe>'
if(!form){
form=th.span.firstChild;
}
d.body.insertBefore(s,d.body.lastChild);
var setAttributes=function(e,attr){
var sv=[];
var form=e;
if(e.mergeAttributes){
var form=d.createElement('form');
form.mergeAttributes(e,false);
}
for(var i=0;i<attr.length;i++){
var k=attr[i][0],v=attr[i][1];
sv[sv.length]=[k,form.getAttribute(k)];
form.setAttribute(k,v);
}
if(e.mergeAttributes){
e.mergeAttributes(form,false);
}
return sv;
}
var closure=function(){
top.JsHttpRequestGlobal=JsHttpRequest;
var savedNames=[];
if(!wholeFormSending){
for(var i=0,n=form.elements.length;i<n;i++){
savedNames[i]=form.elements[i].name;
form.elements[i].name='';
}
}
var qt=th.queryText.split('&');
for(var i=qt.length-1;i>=0;i--){
var pair=qt[i].split('=',2);
var e=d.createElement('INPUT');
e.type='hidden';
e.name=unescape(pair[0]);
e.value=pair[1]!=null?unescape(pair[1]):'';
form.appendChild(e);
}
for(var i=0;i<th.queryElem.length;i++){
th.queryElem[i].e.name=th.queryElem[i].name;
}
var sv=setAttributes(
form,
[
['action',th.url],
['method',th.method],
['onsubmit',null],
['target',ifname]
]
);
form.submit();
setAttributes(form,sv);
for(var i=0;i<qt.length;i++){
form.lastChild.parentNode.removeChild(form.lastChild);
}
if(!wholeFormSending){
for(var i=0,n=form.elements.length;i<n;i++){
form.elements[i].name=savedNames[i];
}
}
}
JsHttpRequest.setTimeout(closure,100);
return null;
}
}}
function getPageSize()
{
var xScroll,yScroll;
if(window.innerHeight&&window.scrollMaxY)
{
xScroll=window.innerWidth+window.scrollMaxX;
yScroll=window.innerHeight+window.scrollMaxY;
}
else if(document.body.scrollHeight>document.body.offsetHeight)
{
xScroll=document.body.scrollWidth;
yScroll=document.body.scrollHeight;
}
else
{
xScroll=document.body.offsetWidth;
yScroll=document.body.offsetHeight;
}
var windowWidth,windowHeight;
if(self.innerHeight)
{
if(document.documentElement.clientWidth)
{
windowWidth=document.documentElement.clientWidth;
}
else
{
windowWidth=self.innerWidth;
}
windowHeight=self.innerHeight;
}
else if(document.documentElement&&document.documentElement.clientHeight)
{
windowWidth=document.documentElement.clientWidth;
windowHeight=document.documentElement.clientHeight;
}
else if(document.body)
{
windowWidth=document.body.clientWidth;
windowHeight=document.body.clientHeight;
}
if(yScroll<windowHeight)
{
pageHeight=windowHeight;
}
else
{
pageHeight=yScroll;
}
if(xScroll<windowWidth)
{
pageWidth=xScroll;
}
else
{
pageWidth=windowWidth;
}
arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);
return arrayPageSize;
}
function getScrollXY()
{
var scrOfX=0,scrOfY=0;
if(typeof(window.pageYOffset)=='number')
{
scrOfY=window.pageYOffset;
scrOfX=window.pageXOffset;
}
else if(document.body&&(document.body.scrollLeft||document.body.scrollTop))
{
scrOfY=document.body.scrollTop;
scrOfX=document.body.scrollLeft;
}
else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop))
{
scrOfY=document.documentElement.scrollTop;
scrOfX=document.documentElement.scrollLeft;
}
return[scrOfX,scrOfY];
}
function CreateWindow(windowId,windowTitle,windowWidth,windowHeight)
{
var windowDiv=document.getElementById(windowId);
if(windowDiv==undefined)
{
var fade_div=document.createElement("div");
fade_div.setAttribute("id",windowId);
var body=document.getElementsByTagName("body")[0];
windowDiv=body.appendChild(fade_div);
}
windowDiv.className="shadowed";
if(windowWidth=='')
{
windowWidth='300px';
}
windowDiv.style.width=windowWidth;
if(windowHeight!='')
{
windowDiv.style.height=windowHeight;
}
var shadowed_tl=document.createElement("div");
shadowed_tl.className="tl";
windowDiv.appendChild(shadowed_tl);
var shadowed_t=document.createElement("div");
shadowed_t.className="t";
windowDiv.appendChild(shadowed_t);
var shadowed_tr=document.createElement("div");
shadowed_tr.className="tr";
windowDiv.appendChild(shadowed_tr);
var shadowed_l=document.createElement("div");
shadowed_l.className="l";
windowDiv.appendChild(shadowed_l);
var shadowed_r=document.createElement("div");
shadowed_r.className="r";
windowDiv.appendChild(shadowed_r);
var shadowed_bl=document.createElement("div");
shadowed_bl.className="bl";
windowDiv.appendChild(shadowed_bl);
var shadowed_b=document.createElement("div");
shadowed_b.className="b";
windowDiv.appendChild(shadowed_b);
var shadowed_br=document.createElement("div");
shadowed_br.className="br";
windowDiv.appendChild(shadowed_br);
if(windowTitle!='')
{
var topbar=document.createElement("div");
topbar.className="topbar";
windowDiv.insertBefore(topbar,windowDiv.childNodes[0]);
}
windowDiv.style.display="none";
var wclose_img=document.createElement("img");
wclose_img.src='/hostcmsfiles/images/wclose.gif';
wclose_img.onclick=function(){HideWindow(windowId);};
if(windowTitle!='')
{
topbar.appendChild(wclose_img);
var textNode=document.createTextNode(windowTitle);
topbar.appendChild(textNode);
}
}
function SlideWindow(windowId)
{
var windowDiv=document.getElementById(windowId);
if(windowDiv==undefined)
{
return false;
}
if(windowDiv.style.display=="block")
{
HideWindow(windowId);
}
else
{
ShowWindow(windowId);
}
}
var prev_window=0;
function ShowWindow(windowId)
{
var windowDiv=document.getElementById(windowId);
if(windowDiv==undefined)
{
return false;
}
if(prev_window&&prev_window!=windowId&&(windowId.indexOf('edit_window_')==0||prev_window.indexOf('edit_window_')!==0))
{
HideWindow(prev_window);
}
prev_window=windowId;
var arrayPageSize=getPageSize();
var arrayScrollXY=getScrollXY();
windowDiv.style.display='block';
var clientHeight=windowDiv.clientHeight;
var clientWidth=windowDiv.clientWidth;
if(clientHeight>arrayPageSize[3])
{
clientHeight=Math.round(arrayPageSize[3]*0.9);
}
if(clientWidth>arrayPageSize[2])
{
clientWidth=Math.round(arrayPageSize[2]*0.9);
}
windowDiv.style.top=((arrayPageSize[3]-clientHeight)/2+arrayScrollXY[1])+'px';
windowDiv.style.left=((arrayPageSize[2]-clientWidth)/2+arrayScrollXY[0])+'px';
}
function deleteChildNodes(node_id)
{
var node=document.getElementById(node_id);
if(node!==undefined)
{
if(node.hasChildNodes())
{
while(node.firstChild)
{
node.removeChild(node.firstChild);
}
}
}
}
function HideWindow(windowId)
{
var windowDiv=document.getElementById(windowId);
if(windowDiv==undefined)
{
return false;
}
if(windowId.indexOf('edit_window_')==0)
{
DisableTinyMCE();
deleteChildNodes(windowId);
windowDiv.parentNode.removeChild(windowDiv);
}
else
{
windowDiv.style.display='none';
}
}
function doSetLocation(shop_country_id,path)
{
var req=new JsHttpRequest();
ShowLoadingScreen();
req.onreadystatechange=function()
{
if(req.readyState==4)
{
document.body.style.cursor='';
HideLoadingScreen();
if(req.responseJS!=undefined)
{
if(req.responseJS.result!=undefined)
{
oSelect=document.getElementById(location_select_id);
oSelect.options.length=0;
oSelect.options[oSelect.options.length]=new Option(" ... ",0);
for(var key in req.responseJS.result)
{
oSelect.options[oSelect.options.length]=new Option(req.responseJS.result[key],key);
}
oCity=document.getElementById(city_select_id);
oCity.options.length=0;
oCity.options[oCity.options.length]=new Option(" ... ",0);
oCityarea=document.getElementById(cityarea_select_id);
oCityarea.options.length=0;
oCityarea.options[oCityarea.options.length]=new Option(" ... ",0);
}
}
return true;
}
}
req.open('get',path+"?action=get_location&shop_country_id="+shop_country_id,true);
req.send(null);
document.body.style.cursor="wait";
}
function doSetCity(shop_location_id,path)
{
var req=new JsHttpRequest();
ShowLoadingScreen();
req.onreadystatechange=function()
{
if(req.readyState==4)
{
document.body.style.cursor='';
HideLoadingScreen();
if(req.responseJS!=undefined)
{
if(req.responseJS.result!=undefined)
{
oSelect=document.getElementById(city_select_id);
oSelect.options.length=0;
oSelect.options[oSelect.options.length]=new Option(" ... ",0);
for(var key in req.responseJS.result)
{
oSelect.options[oSelect.options.length]=new Option(req.responseJS.result[key],key);
}
oCityarea=document.getElementById(cityarea_select_id);
oCityarea.options.length=0;
oCityarea.options[oCityarea.options.length]=new Option(" ... ",0);
}
}
return true;
}
}
req.open('get',path+"?action=get_city&shop_location_id="+shop_location_id,true);
req.send(null);
document.body.style.cursor="wait";
}
function doSetCityArea(shop_city_id,path)
{
var req=new JsHttpRequest();
ShowLoadingScreen();
req.onreadystatechange=function()
{
if(req.readyState==4)
{
document.body.style.cursor='';
HideLoadingScreen();
if(req.responseJS!=undefined)
{
if(req.responseJS.result!=undefined)
{
oSelect=document.getElementById(cityarea_select_id);
oSelect.options.length=0;
oSelect.options[oSelect.options.length]=new Option(" ... ",0);
for(var key in req.responseJS.result)
{
oSelect.options[oSelect.options.length]=new Option(req.responseJS.result[key],key);
}
}
}
return true;
}
}
req.open('get',path+"?action=get_cityarea&shop_city_id="+shop_city_id,true);
req.send(null);
document.body.style.cursor="wait";
}
function GetStyle(drag_object,axis)
{
var str_value="";
if(document.defaultView&&document.defaultView.getComputedStyle)
{
var css=document.defaultView.getComputedStyle(drag_object,null);
str_value=css?css.getPropertyValue(axis):null;
}
else if(drag_object.currentStyle)
{
str_value=drag_object.currentStyle[axis];
if(str_value=='auto')
{
if(axis=='top')
{
str_value=drag_object.offsetTop;
}
else
{
str_value=drag_object.offsetLeft;
}
}
}
return str_value;
}
function Draggable(drag_object)
{
var xDelta=0,
yDelta=0,
xStart=0,
yStart=0;
function EndDrag()
{
document.onmouseup=null;
document.onmousemove=null;
}
function Drag(drag_event)
{
drag_event=drag_event||window.event;
xDelta=xStart-parseInt(drag_event.clientX);
yDelta=yStart-parseInt(drag_event.clientY);
xStart=parseInt(drag_event.clientX);
yStart=parseInt(drag_event.clientY);
drag_object.style.top=(parseInt(drag_object.style.top)-yDelta)+'px';
drag_object.style.left=(parseInt(drag_object.style.left)-xDelta)+'px';
}
function StartDrag(drag_event)
{
drag_event=drag_event||window.event;
xStart=parseInt(drag_event.clientX);
yStart=parseInt(drag_event.clientY);
drag_object.style.top=parseInt(GetStyle(drag_object,'top'))+'px';
drag_object.style.left=parseInt(GetStyle(drag_object,'left'))+'px';
document.onmouseup=EndDrag;
document.onmousemove=Drag;
return false;
}
drag_object.onmousedown=StartDrag;
}
function ShowEditWindow(caption,path,name)
{
var oWindowId='edit_window_'+name;
var oWindow=document.getElementById(oWindowId);
if(oWindow==undefined)
{
CreateWindow(oWindowId,caption,'90%','90%');
var oWindow=document.getElementById(oWindowId);
var ElementDiv=document.createElement("div");
ElementDiv.setAttribute("id","subdiv");
var SubDiv=oWindow.appendChild(ElementDiv);
var DivMessage=document.createElement("div");
DivMessage.setAttribute("id","id_message");
var oDivMessage=SubDiv.appendChild(DivMessage);
var DivContent=document.createElement("div");
DivContent.setAttribute("id","id_content");
var oDivContent=SubDiv.appendChild(DivContent);
var req=new JsHttpRequest();
ShowLoadingScreen();
req.onreadystatechange=function()
{
if(req.readyState==4)
{
document.body.style.cursor='';
HideLoadingScreen();
if(req.responseJS!=undefined)
{
if(typeof req.responseJS.error!='undefined')
{
if(oDivMessage)
{
var span=document.createElement("span");
span.style.display='none';
span.innerHTML="Stupid IE. "+req.responseJS.error;
runScripts(span.getElementsByTagName('SCRIPT'));
oDivMessage.innerHTML=req.responseJS.error;
}
}
if(typeof req.responseJS.form_html!='undefined'&&req.responseJS.form_html!='')
{
cmsrequest=path;
if(cmsrequest!=''
&&function_exists('getCmsUrl')
&&getCmsUrl()!=cmsrequest)
{
setLocation(cmsrequest);
}
if(function_exists('saveLocation'))
{
saveLocation(getCmsUrl());
}
oDivContent.innerHTML=req.responseJS.form_html;
var span=document.createElement("span");
span.style.display='none';
span.innerHTML="Stupid IE. "+req.responseJS.form_html;
runScripts(span.getElementsByTagName('SCRIPT'));
}
}
return true;
}
}
req.open('get',path,true);
req.send(null);
document.body.style.cursor="wait";
}
else
{
DisableTinyMCE();
oDivMessage=document.getElementById("id_message");
oDivMessage.innerHTML='';
}
SlideWindow(oWindowId);
}
function row_over(object)
{
if(object.className=='row_table')object.className='row_table_over';
}
function row_out(object)
{
if(object.className=='row_table_over')object.className='row_table';
}
function row_over_odd(object)
{
if(object.className=='row_table_odd')object.className='row_table_over_odd';
}
function row_out_odd(object)
{
if(object.className=='row_table_over_odd')object.className='row_table_odd';
}
function menu_row_over(object)
{
if(object.className=='menu_out')object.className='menu_over';
}
function menu_row_out(object)
{
if(object.className=='menu_over')object.className='menu_out';
}
function SlideLayer(Num)
{
var el=document.getElementById(Num);
if(el.style.display=="block")
{
el.style.display="none";
}
else
{
el.style.display="block";
}
}
changeFontSizeTimer=new Array();
function HostCMSMenuOver(CurrenElementId,LevelMenu,ChildId)
{
CurrenElement=document.getElementById(CurrenElementId);
if(CurrenElementId==undefined)
{
return false;
}
decor(CurrenElementId,LevelMenu);
if(ChildId!='')
{
ChildId=document.getElementById(ChildId);
showHideMenu(ChildId);
}
}
function HostCMSMenuOut(CurrenElementId,LevelMenu,ChildId)
{
CurrenElement=document.getElementById(CurrenElementId);
if(CurrenElementId==undefined)
{
return false;
}
unDecor(CurrenElementId,LevelMenu);
if(ChildId!='')
{
ChildId=document.getElementById(ChildId);
showHideMenu(ChildId);
}
}
function showHideMenu(ChildId)
{
if(ChildId==undefined)
{
return false;
}
if(ChildId.style.display=="block")
{
ChildId.style.display="none";
}
else
{
ChildId.style.display="block";
groupChildElements=ChildId.children;
if(groupChildElements!=undefined)
{
for(i=0;i<groupChildElements.length;i++)
{
if(groupChildElements[i].className=='b'|groupChildElements[i].className=='t')
{
groupChildElements[i].style.width=ChildId.clientWidth+'px';
}
if(groupChildElements[i].className=='r'|groupChildElements[i].className=='l')
{
groupChildElements[i].style.height=ChildId.clientHeight+'px';
}
}
}
}
}
function changeFontSize(CurrenElementId,change,limit)
{
var CurrenElement=document.getElementById(CurrenElementId);
if(CurrenElement)
{
var CurrFontSize=CurrenElement.style.fontSize?parseInt(CurrenElement.style.fontSize):10;
if(CurrFontSize!=limit)
{
CurrenElement.style.fontSize=(CurrFontSize+change)+'pt';
changeFontSizeTimer[CurrenElementId]=setTimeout('changeFontSize("'+CurrenElementId+'", '+change+', '+limit+')',1);
}
}
}
function decor(CurrenElementId,LevelMenu)
{
var CurrenElemen=document.getElementById(CurrenElementId);
if(LevelMenu==1)
{
CurrenElement.style.background="url('/admin/images/line3.gif') repeat-x 0 100%";
var child=CurrenElement.children;
if(changeFontSizeTimer[CurrenElementId]!='')
{
clearTimeout(changeFontSizeTimer[CurrenElementId]);
}
changeFontSize(CurrenElement.id,1,13);
}
else
{
}
}
function unDecor(CurrenElementId,LevelMenu)
{
var CurrenElemen=document.getElementById(CurrenElementId);
if(LevelMenu==1)
{
clearTimeout(changeFontSizeTimer[CurrenElementId]);
CurrenElement.style.background="url('/admin/images/line1.gif') repeat-x 0 100%";
changeFontSize(CurrenElement.id,-1,10);
}
else
{
}
}
function SetGradeMessage(message_id,grade_val)
{
var req=new JsHttpRequest();
ShowLoadingScreen();
req.onreadystatechange=function()
{
if(req.readyState==4)
{
document.body.style.cursor='';
HideLoadingScreen();
return true;
}
}
req.open('get',"./?action=set_message_grade&helpdesk_message_id="+message_id+"&grade="+grade_val,true);
req.send(null);
document.body.style.cursor="wait";
}
function ReNewCaptcha(captchaKey,captchaHeight)
{
if(document.images['captcha']!=undefined)
{
var antiCache=Math.floor(Math.random()*100000);
document.images['captcha'].src="/captcha.php?get_captcha="+captchaKey+"&height="+captchaHeight+"&anc="+antiCache;
}
}
function ReNewCaptchaById(imageId,captchaKey,captchaHeight)
{
var captchaObject=document.getElementById(imageId);
if(null!=captchaObject&&undefined!==captchaObject)
{
var antiCache=Math.floor(Math.random()*100000);
captchaObject.src="/captcha.php?get_captcha="+captchaKey+"&height="+captchaHeight+"&anc="+antiCache;
}
}
function ShowHide(divId)
{
var windowDiv=document.getElementById(divId);
if(windowDiv==undefined)
{
return false;
}
if(windowDiv.style.display=="block")
{
windowDiv.style.display='none';
}
else
{
windowDiv.style.display='block';
}
}
function callbackfunction_showFormAddItem(responseJS)
{
if(typeof responseJS!='undefined')
{
HideLoadingScreen();
if(typeof responseJS.result!='undefined')
{
html=responseJS.result;
document.getElementById('AddItemForm').innerHTML=html;
runScripts(document.getElementById('AddItemForm').getElementsByTagName('SCRIPT'));
var div_id_message=document.getElementById('AddItemMessage');
if(div_id_message)
{
div_id_message.innerHTML='';
}
}
}
}
function callbackfunction_SendFormItem(responseJS)
{
if(typeof responseJS!='undefined')
{
if(responseJS.message!='undefined')
{
var div_id_message=document.getElementById('AddItemMessage');
if(div_id_message)
{
div_id_message.innerHTML=responseJS.message;
runScripts(div_id_message.getElementsByTagName('SCRIPT'));
window.location.href=(window.location.href.indexOf('#')>=0?window.location.href:window.location.href+'#FocusAddItemMessage');
}
}
}
}
function ShowImgWindow(title,src,width,height)
{
obj=window.open("","","scrollbars=0,dialog=0,minimizable=1,modal=1,width="+width+",height="+height+",resizable=0");
obj.document.write("<html>");
obj.document.write("<head>");
obj.document.write("<title>"+title+"</title>");
obj.document.write("</head>");
obj.document.write("<body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>");
obj.document.write("<img src=\""+src+"\" width=\""+width+"\" height=\""+height+"\" />");
obj.document.write("</body>");
obj.document.write("</html>");
obj.document.close();
}
function getElementsByName_iefix(tag,name)
{
var elem=document.getElementsByTagName(tag);
var arr=new Array();
var iarr=0;
for(i=0;i<elem.length;i++)
{
att=elem[i].getAttribute("name");
if(att==name)
{
arr[iarr]=elem[i];
iarr++;
}
}
return arr;
}
function changeHeightFloatBlockBorder(oBorder,iHeightAttribute,iStyleTop)
{
var iElementHeight=0;
for(i=0;i<oBorder.length;i++)
{
iElementHeight=oBorder[i].parentNode.offsetHeight+iHeightAttribute;
if(iElementHeight>0)
{
oBorder[i].style.height=iElementHeight+'px';
oBorder[i].style.top=iStyleTop+'px';
}
}
}
