////построение всех гет элементов///////////////////////////////////////////////
var GET=new Array();
function GET_v()
{
var dd=new Date();
GET.c_y=dd.getFullYear();
GET.c_m=dd.getMonth()+1;
var url=document.location.href;
if(url.indexOf("?")>0)
 {
 var t=url.split ("?");
 url=t[1].split ("&");
 for(var i=0; i< url.length ; i++)
  {
  t=url[i].split ("=");
  GET[t[0]]=t[1];
  }
 }
}
////////////////////////////////////////////////////////////////////////////////
GET_v();
/*############################################################################*/
var bw=new lib_bwcheck()
messages=new Array()
fromX = 10;
fromY = 10;
var px = bw.ns4||window.opera?"":"px";
var descx = 0;
var descy = 0;
var oDesc;

function pl_overeffect(object){
	object.style.border = "1px solid #c0c0c0";
}
function pl_outeffect(object){
	object.style.border = "1px solid #ffffff";
}

function draw_product_image(p_id){
	document.write('<strong>'+p_id+'</strong>');
}

function mouse_menu_effect(obj, el_id){
	if(obj.className == 'mouse_over_menu'){
		obj.className='mouse_out_menu'
	} else {
		obj.className='mouse_over_menu';
	}
}

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
function makeObj(obj){								
   	this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;
	if(!this.evnt) return false
	this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;	
   	this.wref=bw.dom||bw.ie4?this.evnt:bw.ns4?this.css.document:0;		
	this.writeIt=b_writeIt;																
	return this
}

function b_writeIt(text){
	if (bw.ns4){this.wref.write(text);this.wref.close()}
	else this.wref.innerHTML = text
}

function popmousemove(e){descx=bw.ns4||bw.ns6?e.pageX:event.x; descy=bw.ns4||bw.ns6?e.pageY:event.y}

function popup(num){
    if(oDesc){
		oDesc.writeIt('<div class="clDescription">'+messages[num]+'</div>')
		if(bw.ie5||bw.ie6) descy = descy+document.body.scrollTop
		oDesc.css.left = (descx+fromX)+px
		oDesc.css.top = (descy+fromY)+px
		oDesc.css.visibility = "visible"
    }
}
function popout(){
	if(oDesc) oDesc.css.visibility = "hidden"
}
function setPopup(){
   	if(bw.ns4)document.captureEvents(Event.MOUSEMOVE)
    document.onmousemove = popmousemove;
	oDesc = new makeObj('divDescription')
}
//##############20080407 aladin.od.ua@mail.ru##############################################################################
function ProEdit(VarType,input_id)
{
var t=input_id.value;
if(VarType=='Dec')
	{
	var temp=t;
	t=t.replace(/\.{2,}/g, ".");		//удаление двойной точки
	t=t.replace(/-{2,}/g, "-");		//удаление двойной точки
	t=t.replace(/[^0-9.-]+/g, '');		//удаление всех не цифровых символов и точки
	t=t.replace(/(\d{4})\w+/g, "$1.");	//удаление лишних символов после точки
	t=t.replace(/\.(\d{2})[0-9.]+/g, ".$1");//удаление лишних символов после точки
	if(temp!=t)
		{
//		alert('от 0.00 до 9999.99');
		}
	}
if(VarType=='Int')
	{
	t=t.replace(/[^0-9]+/g, '');		//удаление всех не цифровых символов
	}
if(VarType=='CHAR')
	{
	t=t.toLocaleUpperCase();		//перевод в заглавный символ
	var temp=t;
	t=t.replace(/[^A-ZА-Я]/, '');		//удаление всех не букв
	t=t.substr(0,1);			//отделение только первого символа
	if(temp!=t)
		{
//		alert('Только одна большая буква');
		}
	}
if(VarType=='char')
	{
	t=t.replace(/^[0-9]+/g, '');		//удаление всех цыфр в начале предложения
	}
if(VarType=='Phone') //+3 дописывать в коде
	{
	t=t.replace(/[^0-9]$/g, '');
	t=t.replace(/(\d{11})\w/g, "$1");
	}
if(VarType=='DataY')
	{
	var temp=t;
	t=t.replace(/^[^12]/, '');
	t=t.replace(/[^0-9]$/g, '');
	t=t.replace(/(\d{4})\w/g, "$1");	//удаление лишних символов после точки
	if(temp!=t)
		{
//		alert('1YYY или 2YYY');
		}
	}
if(VarType=='DataA') //дата + время
	{
	t=t.replace(/^[^12]/, ""); 
	t=t.replace(/^(.)\D/, "$1"); 
	t=t.replace(/^(..)\D/, "$1");
	t=t.replace(/^(...)\D/, "$1");
	t=t.replace(/^(....)[^-]/, "$1-");
	t=t.replace(/^(.....)[^01]/, "$1");
	t=t.replace(/^(.....0)\D/, "$1");
	t=t.replace(/^(.....1)[^012]/, "$1");
	t=t.replace(/^(.......)[^-]/, "$1-");
	t=t.replace(/^(........)[^0-3]/, "$1");
	t=t.replace(/^(........[^012])\D/, "$1");
	t=t.replace(/^(........3)[^01]/, "$1");
	t=t.replace(/^(.........)\D/, "$1");
	t=t.replace(/^(..........)\S/, "$1 ");
	t=t.replace(/^(...........)[^0-2]/, "$1");
	t=t.replace(/^(............)\D/, "$1");
	t=t.replace(/^(.............)[^:]/, "$1:");
	t=t.replace(/^(..............)[^0-5]/, "$1");
	t=t.replace(/^(...............)\D/, "$1");
	t=t.replace(/^(................)[^:]/, "$1:");
	t=t.replace(/^(.................)[^0-5]/, "$1");
	t=t.replace(/^(..................)\D/, "$1");
	t=t.replace(/^(...................)\w+/, "$1");
	}

if(VarType=='Email')
	{
	t=t.replace(/\.{2,}/g, ".");		//удаление двойной точки
	t=t.replace( /[^\w\-\d\.@]/g, "" );		
	t=t.replace( /^[^a-z\d]/i, "" );		
	t=t.replace( /(@.*)@/g, "$1" );		
	t=t.replace( /@\./, "@" );		
	t=t.replace( /[^\w\d\-\.@]/g, "" );		
	}
if(t!=input_id.value) input_id.value = t;
}
////////////////////////////////////////////////////////////////////////////////
function helpmy(that_is,id,f)
{
if(f==1)
 {
 $.post(
  '/external.php?event=ajax&subevent=help',
  {
    that_is: that_is,
    id: id
  },
  data_help_w
 );
 }
else
 {
 $.post(
  '/external.php?event=ajax&subevent=help',
  {
    that_is: that_is,
    id: id
  },
  data_help
 );
 } 
}
////////////////////////////////////////////////////////////////////////////////
function data_help(data)
{
if(data)
 {
 var left=300;
 var top=YY + document.documentElement.scrollTop-20;
 document.getElementById("help").style.top=top+"px";
 document.getElementById("help").style.left=left+"px";
 document.getElementById("help").style.zIndex=99999;
 document.getElementById("help").style.backgroundColor='#fff';
 document.getElementById("help").style.position="absolute";
 document.getElementById("help").style.display="";
 document.getElementById("help").innerHTML=data;
 }
}

////////////////////////////////////////////////////////////////////////////////
function data_help_w(data)
{
if(data)
 {
 
 var tmp='<html><TITLE>Результат запроса</TITLE>';
 tmp+='<META http-equiv="Content-Type" content="text/html; charset=windows-1251">';
 tmp+='<link rel="stylesheet" type="text/css" href="stylesheet.css">';
 tmp+='<body>';
 tmp+=data;
 tmp+='</body>';
 tmp+='</html>';
 w = window.open("","_blank","top=0, left=0, width=800, heigth=580, resizable=yes, scrollbars=1,status=1");
 w.document.write(tmp);
 }
}
////////////////установка кука//////////////////////////////////////////////////////////////////////
function setCookie (name, value, path,domain)
{
expires= new Date(2020,12,31);
      document.cookie = name + "=" + escape(value) +
        "; expires=" + expires.toGMTString() +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "");
}
////////////////вытаскивание значения кука//////////////////////////////////////////////////////////
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}
////////////////удаление кука///////////////////////////////////////////////////////////////////////
function deleteCookie(name, path, domain) {
        if (getCookie(name)) {
                document.cookie = name + "=" + 
                ((path) ? "; path=" +
				 path : "") +
                ((domain) ? "; domain=" + 
				domain : "") +
                "; expires=Thu, 01-Jan-70 00:00:01 GMT"
        }
}        
////////////////////////////////////////////////////////////////////////////////
function send_form(form,f)
{
var eSearch = document.forms[form].elements;
var inp=new Object();
for(var i=0; i< eSearch.length ; i++)
 {
 if(eSearch[i].name!='')
  {
  inp[eSearch[i].name]=eSearch[i].value;
  }
 }
if(f==1)
 {
 $.post('/external.php?event=ajax&subevent=help',inp,repl_send_f); 
 }
else
 {
 $.post('/external.php?event=ajax&subevent=help',inp,repl_send); 
 }  
}
////////////////////////////////////////////////////////////////////////////////
function repl_send(data)
{
if(data.length>1) {alert (data);}
document.getElementById('help').style.display='none';
}
////////////////////////////////////////////////////////////////////////////////
function repl_send_f(data)
{
document.getElementById('help').style.display='none';
if(data.length>1) {eval(data);}
}
////////////////////////////////////////////////////////////////////////////////
function str_replace(o,n,str)
{

var i=0;
o=(o=="")?" ":o;
while(true)
 {
 i = str.indexOf(o,i);
 if(i>=0)
  {
  str=str.substr(0,i)+n+str.substr(i+o.length);
  }
 else break;
  }

return str;
};

