/*
 * Copyright © 2008 Multimedia Company CSC (www.cural.ru)
 * $Date: 2008-06-11 15:55:31 +0600 (Wed, 11 Jun 2008) $
 * $Version: 1.0.1 $
 */
var win,newwin,preview,mailWindow,textWindow;function dw(B){return(B)?document.writeln(B):false}function ow(R,S,M,Q,P,O,T){var U=document,N="",V,L;Q=Q?"yes":"no";P=P?"yes":"no";L="toolbar="+Q+",menubar="+Q+",location="+Q+",status="+Q+",scrollbars="+P+",resizable="+O;if(S){L+=",width="+S}else{if(U.body.clientWidth){L+=",width="+U.body.clientWidth}else{L+=",width="+window.innerWidth}}if(M){L+=",height="+M}else{if(U.body.clientHeight){L+=",height="+U.body.clientHeight}else{L+=",height="+window.innerHeight}}if(T){if(S&&window.screen.availWidth){L+=",left="+Math.round((window.screen.availWidth-parseInt(S))/2)}if(M&&window.screen.availHeight){L+=",top="+Math.round((window.screen.availHeight-parseInt(M))/2)}}V=window.open(R,N,L);V.focus();return V}newwin=function(F,D,E){ow(F,D,E,true,true,true,true)};preview=function(F,D,E){ow(F,D,E,false,false,false,true)};mailWindow=function(F,D,E){if(!win||win.closed){win=ow(F,D,E,false,true,false,true)}else{win.focus()}};textWindow=function(F,D,E){ow(F,D,E,false,false,false,true)};var Forms={};Forms.conf={prefix_req_field_id:"req",prefix_error_elem_id:"error",prefix_help_elem_id:"help",error_field_classname:"input-field-error"};Forms.Form=function(B,A){B=(null!=B&&"object"==typeof B)?B:document.getElementById(B);if(null==B){return false}this.oForm=B;this.aFields={};this.aButtons={};this.aLabels={};this.reqprefix=A||Forms.conf.prefix_req_field_id;this.init()};Forms.Field=function(B,A){this.oField=B;this.pType=A||""};Forms.Button=function(A,B){this.oButton=A;this.pType=B||""};Forms.Label=function(A,B){this.oLabel=A;this.pFor=B};Forms.Form.prototype.init=function(){var N=this,F,E,C,D,K,I,H,B,A,M,J,L;I=this.oForm.elements;for(F=0,C=I.length;F<C;F++){switch(I[F].type){case"submit":this.aButtons[I[F].type]=new Forms.Button(I[F],L);I[F].onclick=function(){return function(){if(N.validate()){this.value="Loading...";this.disabled=true;this.form.submit()}else{return false}}}();break;case"reset":this.aButtons[I[F].type]=new Forms.Button(I[F],L);I[F].onclick=function(){return function(){return confirm(this.value+"?")}}();break;default:B=(I[F].name)?I[F].name:I[F].id;if(-1!=B.indexOf(this.reqprefix+":")){A=B.replace(this.reqprefix+":","");L=I[F].value.replace(/\s.*/gi,"");if(""==A){continue}if(null!=I[A]&&"object"==typeof I[A]){this.aFields[A]=new Forms.Field(I[A],L);if(null==this.oForm.focally){if(""==I[A].value&&1==I[A].tabIndex){this.oForm.focally=A;I[A].focus()}}}}}}H=this.oForm.getElementsByTagName("label");for(F=0,C=H.length;F<C;F++){if(H[F].htmlFor&&null!=this.aFields[H[F].htmlFor]){this.aLabels[H[F].htmlFor]=new Forms.Label(H[F],H[F].htmlFor);K=document.getElementById(Forms.conf.prefix_help_elem_id+":"+H[F].htmlFor);if(null!=K&&"object"==typeof K){H[F].onclick=function(O){return function(){if("none"==N.getElementStyle(O,"display")){O.style.display="block"}else{O.style.display="none"}return true}}(K);H[F].style.borderBottom="1px dashed"}else{H[F].title=""}}}J=this.oForm.getElementsByTagName("a");for(F=0,C=J.length;F<C;F++){if(-1!=J[F].id.indexOf(Forms.conf.prefix_req_field_id+":")){B=J[F].id.replace(Forms.conf.prefix_req_field_id+":","");if(-1!=B.indexOf(":")){A=B.substr(0,B.indexOf(":"));B=B.substr(B.indexOf(":")+1);var G=[];M=this.oForm.getElementsByTagName(A);for(E=0,D=M.length;E<D;E++){if(B==M[E].className){G[G.length]=M[E]}}J[F].onclick=function(O){return function(){var Q,P;P=O.childNodes.length;if(P>1){for(Q=0;Q<P;Q++){O.childNodes[Q].style.display=("none"==N.getElementStyle(O.childNodes[Q],"display"))?"block":"none"}}for(Q=0,P=G.length;Q<P;Q++){G[Q].style.display=("none"==N.getElementStyle(G[Q],"display"))?"block":"none"}return false}}(J[F]);break}}}return true};Forms.Form.prototype.validate=function(){var D,C,A,F=this.aFields,B=true,E=null;for(D in F){switch(F[D].oField.type){case"text":case"hidden":case"file":case"textarea":case"password":B=this.errorHandler(F[D],F[D].oField.value);break;case"radio":for(C=1,A=F[D].oField[F[D].oField.name].length;C<A;C++){if(F[D].oField[F[D].oField.name][C].checked){B=false;break}}break;case"checkbox":B=F[D].oField.checked;break;case"select-one":B=(0==F[D].oField.options.length)?true:this.errorHandler(F[D],F[D].oField.options[F[D].oField.selectedIndex].value);break;case"select-multiple":for(C=1,A=F[D].oField.options.length;C<A;C++){if(F[D].oField.options[C].selected){B=this.errorHandler(F[D],F[D].oField.options[C].value)}}break;default:}if(!B){this.errorShower(F[D],B)}else{E=(null==E)?F[D]:E}}if(null!=E){this.errorShower(E,true);return false}return true};Forms.Form.prototype.errorHandler=function(G,H){var B=true,F=G.pType,C,A,D,E="";if(null==H||"undefined"==H||0==H.length){return B}switch(F){case"login":if(3>H.length||20<H.length){B=true}else{D=/^[a-zA-Z0-9-]+$/;B=(H.match(D))?false:true}break;case"surname":D=/\s{2,}/;H=H.replace(D," ");G.oField.value=H;if(3>H.length||30<H.length){B=true}else{D=/^([à-ÿÀ-ßa-zA-Z]+[-\s]?[à-ÿÀ-ßa-zA-Z]+)+$/;B=(H.match(D))?false:true}break;case"email":D=/\.{2,}/;H=H.replace(D,".");G.oField.value=H;if(7>H.length||40<H.length){B=true}else{D=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;B=(H.match(D))?false:true}break;case"passw":case"code":if(3>H.length||32<H.length){B=true}else{D=/^[a-zA-Z0-9]+$/;B=(H.match(D))?false:true}break;case"imgcode":if(6!=H.length){B=true}else{D=/^[a-zA-Z0-9]+$/;B=(H.match(D))?false:true}break;case"phone":D=/[^0-9]/g;E=H.replace(D,"");if(8==E.charAt(0)||7==E.charAt(0)){E=E.substr(1)}if(9<E.length||12>E.length){H="8 ";for(C=0,A=E.length;C<A;C++){if(7<A){H+=(0==C)?"(":((3==C)?") ":"")}H+=E.charAt(C)+((((7>=A&&C==2)||C==4||C==7||C==9)&&E.charAt(C+1))?"-":"")}G.oField.value=H;B=false}break;case"int":case"number":case"float":D=/[,\.]{2,}/;H=H.replace(D,".");if(G.oField.value){G.oField.value=H}D=/^-?(\d+)\.?(\d+)?$/;B=(H.match(D))?false:true;break;case"text":case"string":case"message":H=H.toString();B=(H.length>=3)?false:true;break;default:}return B};Forms.Form.prototype.errorShower=function(F,B){var D,E,A,C;A=document.getElementById(Forms.conf.prefix_error_elem_id+":"+F.oField.id);C=document.getElementById(Forms.conf.prefix_help_elem_id+":"+F.oField.id);if(null!=A&&"object"==typeof A){if(B){A.style.display="block";E=F.oField.className.replace(Forms.conf.error_field_classname,"");switch(F.oField.type){case"text":case"file":case"textarea":case"password":F.oField.className=(""==E)?Forms.conf.error_field_classname:E+" "+Forms.conf.error_field_classname;F.oField.focus()}if(F.oField.select){F.oField.select()}if(null!=C&&"object"==typeof C){C.style.display="block"}}else{A.style.display="none";F.oField.className=F.oField.className.replace(Forms.conf.error_field_classname,"");if(null!=C&&"object"==typeof C){C.style.display="none"}return true}}return false};Forms.Form.prototype.getElementStyle=function(C,A,B){var D="",B=B||A;if(null==C||"object"!=typeof C||!A){return D}if(C.currentStyle){D=C.currentStyle[A]}else{if(window.getComputedStyle&&B){D=window.getComputedStyle(C,"").getPropertyValue(B)}}return D};function iepngfix(B){if(/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){var A;if("IMG"==B.tagName){if(/\.png$/.test(B.src)){A=B.src;B.src="/img/n.gif"}}else{A=B.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);if(A){A=A[1];B.runtimeStyle.backgroundImage="none"}}if(A){B.runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+A+"',sizingMethod='crop')"}}}function shl(){var A=shl.arguments,E=document,B,D,C=A[0]?1:0;for(B=2;B<A.length;B++){if(null!=(D=(null!=A[B]&&typeof A[B]=="object")?A[B]:E.getElementById(A[B]))){if(D.style){D.style.display=(C)?"block":"none"}}}setCookie(A[1],C,"","/")};function setCookie(F,E,A,D,B,C){document.cookie=escape(F)+"="+escape(E)+(A?";expires="+A.toGMTString():"")+(D?";path="+D:"")+(B?";domain="+B:"")+(C?"; secure":"")}function getCookie(F){var E=document,C,A,D="",B=E.cookie.indexOf(escape(F)+"=");if(B!=-1){C=B+(escape(F)+"=").length;A=E.cookie.indexOf(";",C);if(A!=-1){D=unescape(E.cookie.substring(C,A))}else{D=unescape(E.cookie.substring(C))}}return(D)};