var www=/www\./g;
var this_domain=document.domain.replace(www,"");
var current_domain='http://'+this_domain;
var static_path='http://static.'+this_domain;

var CurrentLang='en';
if(this_domain.match(/\.ru/)){CurrentLang='ru'}

var LangENG = new Array("Please enter your Username", "Password does not entered", "Invalid characters were entered. Please use A-Z letters and figures (0-9) only", "Enter Email", "Please enter your email address", "Error! Please enter a valid email address", "Please enter your desired Username", "Please enter your Affiliate ID", "Username (Login)", "Create Password", "Warning! Password must be not less than 6 symbols for more secure");
var LangRU = new Array("Не указано имя пользователя", "Не указан пароль", "Введены недопустимые символы!\nВозможно, у вас включена русская раскладка клавиатуры.\nИспользуйте символы латинского алфавита и цифры", "Введите Email", "Не указан e-mail адрес", "Неправильный формат e-mail адреса", "Введите желаемое имя пользователя (login)", "Не указано имя партнера", "Пользователь (Login)", "Укажите пароль", "Внимание! Пароль должен быть не менее 6 символов. Это увеличивает безопасность!");
var Lang=LangENG
if(CurrentLang=='ru'){Lang=LangRU}

if(window.jQuery)
{
$(document).ready(function(){
  $.fn.alignCenter = function() {
   var marginLeft = Math.max(40, parseInt($(window).width()/2 - $(this).width()/2)) + 'px';
   var marginTop = Math.max(40, parseInt($(window).height()/2 - $(this).height()/2)) + 'px';
   return $(this).css({'margin-left':marginLeft, 'margin-top':marginTop});
  };
});
}

var jq_div="";

function anichange (objName) {
  if ( $(objName).css('display') == 'none' ) {
    $(objName).animate({height: 'show'}, 400);
  } else {
    $(objName).animate({height: 'hide'}, 200);
  }
}

document.write('<div id="info_fader" class="hidden" onclick="CloseInfoWindow()" style="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" class="hidden" style="position:fixed;width:800px;height:450px;top:0px;left:0px;margin:0px;border:0;z-index:1002;"></div>');
document.write('<div id="info_shadow" class="hidden" style="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 JQ_OpenInfoWindow(div_id,info_window_w,info_window_h,info_url,bck_color){
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'}

if($.browser.msie){
$('#info_fader').height($(document).height()).toggleClass('hidden');
}
else{
$('#info_fader').height($(document).height()).toggleClass('hidden').fadeTo('slow', 0.3);
}

jq_div=div_id
document.getElementById(div_id).style.left=Math.round(this.getWindowWidth()/2-info_window_w/2)+'px';
document.getElementById(div_id).style.top=Math.round(this.getWindowHeight()/2-info_window_h/2)+'px';

$('#'+div_id).animate({height: 'show'}, 300)

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(this.getWindowWidth()/2-info_window_w/2)+10+'px';
shadow_div.style.top=Math.round(this.getWindowHeight()/2-info_window_h/2)+40+'px';

$('#info_shadow').animate({height: 'show'}, 300)

/*
document.getElementById('info_shadow').style.display="block";
$('#info_block')
.html($('#'+div_id).html())
.toggleClass('hidden');
*/
   
document.onkeydown=KeyPress;
}

function OpenInfoWindow(div_id,info_window_w,info_window_h,info_url,bck_color){
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="padding: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";
if(jq_div!=""){document.getElementById(jq_div).style.display="none"}
document.getElementById('info_shadow').style.display="none";
document.getElementById('info_fader').style.display="none";

/*
$('#info_shadow').toggleClass('hidden').removeAttr('style');
$('#info_fader').toggleClass('hidden');
*/
}

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(Lang[0]);form.user.focus();return false}
if(!form.password.value){alert(Lang[1]);form.password.focus();return false}
}

function invalidchars(field){
if(field.value.match(/[^\040a-zA-Z0-9_]/)){alert(Lang[2]);field.value="";return false}
}

function RegisterData(form){
if(!form.email.value||form.email.value==Lang[3]){alert(Lang[4]);form.email.focus();return false}
if(!form.email.value.match(/^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,4}$/i)){alert(Lang[5]);form.email.focus();return false}
if(!form.username.value||form.username.value==Lang[8]){alert(Lang[6]);form.username.focus();return false}
if(!form.pass.value||form.pass.value==Lang[9]){alert(Lang[1]);form.pass.focus();return false}
if(form.pass.value.length<6){alert(Lang[10]);form.pass.focus();return false}
}

function aff_check(form){
if(!form.id.value){alert(Lang[7]);form.id.focus();return false}
if(!form.pass.value){alert(Lang[1]);form.pass.focus();return false}
}

function mailtoadmin_label()
{
if(!findorder.query.value){document.getElementById('querylabel').style.display='block'}
else{document.getElementById('querylabel').style.display='none'}
}

function HideDiv(id)
{
document.getElementById(id).style.display='none'
}

function CheckMailToAdminForm()
{
if(!document.mailtoadmin.message.value){alert("Не введено сообщение администратору");document.mailtoadmin.message.focus();return false}
}

function anichange(objName){
  if ( $(objName).css('display') == 'none' ) {
    $(objName).animate({height: 'show'}, 400);
  } else {
    $(objName).animate({height: 'hide'}, 200);
  }
}
