var current_domain='http://www.ecommtools.com';
var static_path='http://static.ecommtools.com';
var js_core='1.0';

var curret_location=new String(document.location);
if(curret_location.match(/^https:/)){current_domain='https://www.ecommtools.com'}

document.write('<div id="info_fader" onclick="CloseInfoWindow()" style="display:none;position:fixed;width:100%;height:100%;left:0px;top:0px;right:0px;bottom:0;background-color:#FFFFFF;z-index:1000;opacity:0.8;-moz-opacity:0.8;-khtml-opacity:0.8;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=80)"></div>');
document.write('<div id="info_block" style="display:none;position:fixed;width:800px;height:450px;top:0px;left:0px;margin:0px;border:0;z-index:1002;"></div>');
document.write('<div id="info_shadow" style="display:none;position:fixed;width:800px;height:450px;top:0px;left:0px;margin:0px;border:0;z-index:1001;background-color:#000000;opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=10)"></div>');

function OpenInfoWindow(div_id,info_window_w,info_window_h,info_url,bck_color,use_shadow){
if(typeof info_window_w=='undefined'||info_window_w=='def'){info_window_w=800}
if(typeof info_window_h=='undefined'||info_window_h=='def'){info_window_h=450}
if(typeof bck_color=='undefined'){bck_color='#FFFFFF'}

var window_w=getWindowWidth();
var window_h=getWindowHeight();

if(info_window_w>window_w){info_window_w=window_w-50}
if(info_window_h>window_h||(info_window_h-window_h)>40){info_window_h=window_h-100}

var info_div=document.getElementById('info_block');
info_div.style.width=info_window_w+'px';
info_div.style.height=info_window_h+'px';
info_div.style.left=Math.round(getWindowWidth()/2-info_window_w/2)+'px';
info_div.style.top=Math.round(getWindowHeight()/2-info_window_h/2-40)+'px';

var shadow_div=document.getElementById('info_shadow');
shadow_div.style.width=info_window_w+'px';
shadow_div.style.height=info_window_h+'px';
shadow_div.style.left=Math.round(getWindowWidth()/2-info_window_w/2)+10+'px';
shadow_div.style.top=Math.round(getWindowHeight()/2-info_window_h/2-50)+55+'px';

var close_button='<table width="100%" border="0" cellspacing="0" cellpadding="0" style="paddin:0px;margin:0px"><tr><td>&nbsp;</td><td align="center" width="32"><img src="'+current_domain+'//images//close_w.png" width="32" height="32" alt="X" border="0" onclick="CloseInfoWindow()" style="cursor:pointer"></td></tr></table>\n';
var DisplayedInfo="";
if(div_id!="iframe"){
	DisplayedInfo=document.getElementById(div_id).innerHTML;
	document.getElementById('info_block').innerHTML=close_button+'<div id="information" align="center" style="font-family: Tahoma, Arial; font-size: 10pt; padding: 0px; background-color: White; background-image: url('+current_domain+'//images//features_shadow.png); background-repeat: repeat-x; width:100%; height:100%; overflow: auto; border-width:1px;border-color:Silver;border-style:solid">'+DisplayedInfo+'</div>';
}
else{
	var iframe_data='<iframe src="'+info_url+'"style="width:100%;height:100%;border:0;" marginwidth="0" marginheight="0" frameborder="0" align="left">error</iframe>';
	document.getElementById('info_block').innerHTML=close_button+'<div id="information" style="width:100%; height:100%; overflow: auto; background-color:White; border-width:1px;border-color:Silver;border-style:solid">'+iframe_data+'</div>';
}

document.getElementById('info_fader').style.display="block";
document.getElementById('info_block').style.display="block";
document.getElementById('info_shadow').style.display="block";

document.onkeydown=KeyPress;
}

function KeyPress(e){
var key;
if (window.event){key=window.event.keyCode;}
else{key=e.keyCode;}
if(key==27){CloseInfoWindow()}
}

function CloseInfoWindow(){
document.getElementById('info_block').innerHTML="";
document.getElementById('info_block').style.display="none";
document.getElementById('info_shadow').style.display="none";
document.getElementById('info_fader').style.display="none";
}

function getWindowWidth(){
return document.compatMode=='CSS1Compat'&&!window.opera?document.documentElement.clientWidth:document.body.clientWidth
}

function getWindowHeight(){
return window.innerHeight||(document.documentElement && document.documentElement.clientHeight)||(document.body.clientHeight)
}

function loginform(form){
if(!form.user.value){alert("Не указано имя пользователя");form.user.focus();return false}
if(!form.password.value){alert("Не указан пароль");form.password.focus();return false}
}

function invalidchars(field){
if(field.value.match(/[^\040a-zA-Z0-9_\-\!\@\#\$\%\^\&\*\(\)\+\=\{\}\[\]\;\:\.\>\<\,\\\/\`\~\|]/)){alert('Введены недопустимые символы!\nВозможно, у вас включена русская раскладка клавиатуры.');field.value="";return false}
}

function loginlabel(data){
if(data=='login')
{
if(!document.forms.login.user.value){document.getElementById('f_login').style.display='block'}
else{document.getElementById('f_login').style.display='none'}
}

if(data=='password'){
if(!document.forms.login.password.value){document.getElementById('f_password').style.display='block'}
else{document.getElementById('f_password').style.display='none'}
}
}

function checkdata(form){
if(!form.email.value){alert("Не указан e-mail адрес");form.email.focus();return false}
if(!form.email.value.match(/^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,4}$/i)){alert("Неправильный формат e-mail адреса");form.email.focus();return false}
if(!form.username.value){alert("Не указано желаемое имя пользователя");form.username.focus();return false}
if(!form.pass.value){alert("Не указан пароль");form.pass.focus();return false}
if(form.pass.value!=form.pass2.value){alert("Введенные пароли не совпадают");form.pass.value="";form.pass2.value="";form.pass.focus();return false}
}

function aff_check(form){
if(!form.id.value){alert("Не указано имя партнера");form.id.focus();return false}
if(!form.pass.value){alert("Не указан пароль партнера");form.pass.focus();return false}
}

function fhelp(id){
var url=static_path+'/help/'+id+'.html';
window.open(url,'','width=450,height=300,left=300,top=200,scrollbars=yes,resizable=yes,location=no,menubar=no,toolbar=0,statusbar=0');
return false
}

var curtainBottom=0;

function ClipDivOpen(div_id,div_height)
{
    if (curtainBottom < div_height)
    {
	curtainBottom += 10;
	document.getElementById(div_id).style.clip = 'rect(auto, auto, '+ curtainBottom +'px, auto)';
	setTimeout(function(){ClipDivOpen(div_id,div_height)},0);
	}
}

function ClipDivClose(div_id,div_height)
{
    if (curtainBottom > 0)
    {
	curtainBottom -= 10;
	document.getElementById(div_id).style.clip = 'rect(auto, auto, '+ curtainBottom +'px, auto)';
	setTimeout(function(){ClipDivClose(div_id,div_height)},0);
	}
}

function DefineUserTag(ID)
{
var TmpID=ID+'_tags';
InsertUserTag(ID,document.getElementById(TmpID).value)
}

function InsertUserTag(ID,InsertData)
{
var FieldID=document.getElementById(ID);
if(document.selection)
{
FieldID.focus();
sel=document.selection.createRange();
sel.text=InsertData;
}
else if(FieldID.selectionStart||FieldID.selectionStart=='0')
{
var startPos=FieldID.selectionStart;
var endPos=FieldID.selectionEnd;
FieldID.value=FieldID.value.substring(0,startPos)
+ InsertData
+ FieldID.value.substring(endPos,FieldID.value.length);
}
else{FieldID.value+=InsertData}
}

