
 var showAlert = false;
 function validationHilight(_id, _valid)
 {
    _el(_id).className=(!_valid)?"notValid":"";
 }
 function updateValidate(arr_validate)
 {
     for (key in arr_validate)
     {
          valdate[key] = arr_validate[key];
     }
 }
 function validateForm()
 {
 //if form has no validation proerties it need to return true always
    var valid = true;
    var errors= new Array();
    var match_el, match_el_id=false;
    if(typeof(validate)=='undefined' || typeof(aliases)=='undefined'){ return true;}
    for (var id in validate)
    {
        validationHilight(id,1);
        if(_el(id))
        {
            if(_el(id).value=='')
            {
                errors[id]='Not filled';
                validationHilight(id,0);
                var valid = false;
            }
            var re = new RegExp(validate[id],'i');
            if(_el(id).value)
            {
              var result = _el(id).value.match(re);
              if(!result)
              {
                  if(!errors[id])
                      errors[id]='Filled incorrectly';
                  validationHilight(id,0);
                  var valid = false;
              }
            }
        }
    }
    for (var id in match)
    {
        match_el = _el(id).value;
        if(match_el_id)
        {
           if(match_el != _el(match_el_id).value)
           {
              errors[match_el_id]='Not match';
              errors[id]='Not match';
              validationHilight(id,0);
              var valid = false;
           }
        }
        else
        {
            match_el_id = id;
        }
    }
    if(!valid)
    {
        var s='An arrors has occured during validation your data. Fill correctly next fields:' + '<br><ul>';
        var first = 1;
        for( var e in errors)
        if(e&&errors[e]&&typeof(e)!='undefined')
        {
            s=((s)?s:'')+((first)?'':'') + '<li class="alertTextField">' + aliases[e] + " - " + errors[e] + '</li>';
       //      s=((s)?s:'')+((first)?'':'') + '' +aliases[e] + '\r\n';
            first=false;

        }
         s+='</ul>';
        //s+='\r\n\r\n';
        if(window.parent)
        {
          showalertReg(s, 'alert_mes', '', 1);
        }
        else
        {
           showalertReg(s, 'alert_mes', '', 0);
        }
    }
    return valid;
 }
  //for parent window
 function getScrollXYP() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.parent.pageYOffset;
    scrOfX = window.parent.pageXOffset;
  } else if( window.parent.document.body && ( window.parent.document.body.scrollLeft || window.parent.document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = window.parent.document.body.scrollTop;
    scrOfX = window.parent.document.body.scrollLeft;
  } else if( window.parent.document.documentElement && ( window.parent.document.documentElement.scrollLeft || window.parent.document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = window.parent.document.documentElement.scrollTop;
    scrOfX = window.parent.document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

 function CloseWindowP(x){
         if(window.parent.document.getElementById(x) != 'undefined'){
            var xWin = window.parent.document.getElementById(x);
            var back = window.parent.document.getElementById(x+ '_back_alert');
            window.parent.document.body.removeChild(xWin);
            window.parent.document.body.removeChild(back) ;
         }
}
 function CloseWindow(x){
         if(document.getElementById(x) != 'undefined'){
            var xWin = document.getElementById(x);
            var back = document.getElementById(x+ '_back_alert');
            document.body.removeChild(xWin );
            document.body.removeChild(back) ;
         }
}

    function FindWindSizeP() {
  var isIE = (navigator.appName.toLowerCase() == "microsoft internet explorer")
  var isNN = (navigator.appName.toLowerCase() == "netscape")
  var myWidth = 0, myHeight = 0;
  if( typeof( window.parent.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.parent.innerWidth;
    myHeight = window.parent.innerHeight;
  } else if( window.parent.document.documentElement && ( window.parent.window.parent.document.documentElement.clientWidth || window.parent.document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = window.parent.document.documentElement.clientWidth;
    myHeight = window.parent.document.documentElement.clientHeight;
  } else if( window.parent.document.body && ( window.parent.document.body.clientWidth || window.parent.document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = window.parent.document.body.clientWidth;
    myHeight = window.parent.document.body.clientHeight;
  }
  return [myWidth, myHeight];
}
 ///////////////////////////////////////////
 //for same window//////////////////////////
    function FindWindSize() {
  var isIE = (navigator.appName.toLowerCase() == "microsoft internet explorer")
  var isNN = (navigator.appName.toLowerCase() == "netscape")
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth, myHeight];
}
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
///////////////////////////////////////////////////////////////
 function showalertReg(xMessage,xId,xClass, parent){
          	var alertmes = document.getElementById(xId);
          	if(parent){
          	   var sizeWin = FindWindSizeP();
          	   var elemBody = window.parent.document.body;
          	   var back = window.parent.document.createElement('div');//xId+'_back_alert'
          	   var scroll  = getScrollXYP();
          	   var sizeWin = FindWindSizeP();
          	   var size
          	}
          	else
          	{
          	   var scroll = getScrollXY();
               var elemBody = document.body;
          	   var sizeWin = FindWindSize();
          	   var scroll  = getScrollXY();
          	   var back = document.createElement('div');
          	}

                back.id                 = xId+'_back_alert';
          		back.style.display      = 'block';
                back.style.zIndex       = 1000 + (intTopZIndex++);
          	    back.className          = 'blackBig';
          	    back.style.top          = 0;
          	    back.style.left         = 0;
                back.style.width = sizeWin[0] + scroll[0] + "px";
	            back.style.height = sizeWin[1] + scroll[1] + "px";
	            if(parent){
          		      var Bigalertmes = window.parent.document.createElement("div");
          		}else{
          		      var Bigalertmes = document.createElement("div");
          		}
          	    Bigalertmes.className = 'bigAlert';
          	    Bigalertmes.id = xId;
          	    Bigalertmes.style.left = parseInt(sizeWin[0]/2) + scroll[0] - 120 + "px";
          	    Bigalertmes.style.top  = parseInt(sizeWin[1]/2) + scroll[1] - 90 + "px";
          	     if(parent){
          	                alertmes = window.parent.document.createElement("div");
          	     }else{
          	                alertmes = document.createElement("div");
          	     }
          	    alertmes.style.width = '260px';
          	         if(xClass){
          	             alertmes.className = xClass;
          	         }else{
          	             alertmes.className = 'ShowAlert';
          	         }
          	     if(parent){
          	             var alertplase = window.parent.document.createElement("div");
          	     }else{
          	             var alertplase = document.createElement("div");
          	     }
          	    alertplase.className = "textAlert";
          	    alertplase.innerHTML = xMessage;
          	     if(parent){
          	         var alrtimpl = window.parent.document.createElement("div");
          	     }else{
          	         var alrtimpl = document.createElement("div");
          	     }

          	    alrtimpl.className = "imagealert";
          	      if(parent){
          	              var button = window.parent.document.createElement("button");
          	      }else{
          	              var button = document.createElement("button");
          	      }
          	    button.className = "alertButton";
          	  //  button.src = "images/buttons/OK.gif";
               if(!parent)
               {
          	    button.onclick = new Function("CloseWindow('" + xId + "');showAlert=false;");
                 var textOn = document.createTextNode("OK");
               }
               else
               {
                 button.onclick = new Function("CloseWindowP('" + xId + "');showAlert=false;");
                  var textOn = window.parent.document.createTextNode("OK");
               }

          	    alertmes.appendChild(alrtimpl);
          	    alertmes.appendChild(alertplase);
          	    button.appendChild(textOn);
          	    alertmes.appendChild(button);
          	    Bigalertmes.appendChild(alertmes);
          	    elemBody.appendChild( back );
          	    Bigalertmes.style.zIndex = 1000 + (intTopZIndex++);
          	    elemBody.appendChild(Bigalertmes);
                Bigalertmes.focus();
          	    return false;
  }



