var im_gui = {

version: '2.1.4',browser: {ie: (navigator.appName == 'Microsoft Internet Explorer'),
ie6: /msie 6/i.test(navigator.userAgent),
ie7: /msie 7/i.test(navigator.userAgent),
ff: (navigator.appName == ''),
java: navigator.javaEnabled(),
ns: (navigator.appName == 'Netscape'),
userAgent: navigator.userAgent.toLowerCase(),
version: parseFloat(navigator.appVersion.substr(21)) || parseFloat(navigator.appVersion)
},

window: {

_dlgWin: null,

newWindow: function(mypage,myname,w,h,scroll,pos){
if (typeof pos == 'undefined') pos='center';
if (typeof scroll == 'undefined') scroll='auto';
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
if (this._dlgWin){ this._dlgWin.close(); }
this._dlgWin = window.open(mypage,myname,settings);
},

getWindowInnerDim: function(){
if (self.innerHeight){ 

return {'width': self.innerWidth, 'height': self.innerHeight};
}else if (document.documentElement && document.documentElement.clientHeight){

return {'width': document.documentElement.clientWidth, 'height': document.documentElement.clientHeight};
}else if (document.body){ 

return {'width': document.body.clientWidth, 'height': document.body.clientHeight};
}
},

getCenterizedPos: function(elemWidth, elemHieght){
var pageScroll = this.getPageScroll();
var centerX = (screen.availWidth/2-elemWidth/2)+pageScroll.x;
var centerY = (screen.availHeight/2-elemHieght/2)+pageScroll.y-80;
return {'x': centerX, 'y': centerY};
},

getPageScroll: function(){
var pageX = pageY = 0;
if (self.pageYOffset){ 

pageX = self.pageXOffset;
pageY = self.pageYOffset;
}else if (document.documentElement && document.documentElement.scrollTop){

pageX = document.documentElement.scrollLeft;
pageY = document.documentElement.scrollTop;
}else if (document.body){

pageX = document.body.scrollLeft;
pageY = document.body.scrollTop;
}
return {'x': pageX, 'y': pageY};
}
},

getBodyDim: function(){
return {
offsetWidth: (/msie/i.test(navigator.userAgent) ? document.body.scrollWidth : window.innerWidth+window.scrollMaxX),
offsetHeight: (/msie/i.test(navigator.userAgent) ? document.body.scrollHeight : window.innerHeight+window.scrollMaxY)
};
},

obj: function(id,type,parent){
return this.misc.obj(id,type,parent);
},

misc: {

obj: function(id,type,parent){
if(type=="tag"){
if(parent && parent.getElementsByTagName(id)){
return parent.getElementsByTagName(id);
}
}else if(type=="name"){
if(document.getElementsByName(id)){
return document.getElementsByName(id)[0];
}
}else{
if(document.getElementById(id)){
return document.getElementById(id);
}
}
return (false);
},

innerData: function(id, data, addingPos){
if(typeof(id)=='object'){
if(typeof(addingPos)=='undefined' || !addingPos){
id.innerHTML = data;
}else if(addingPos=='begin' || addingPos=='before'){
id.innerHTML = data + id.innerHTML;
}else if(addingPos=='end' || addingPos=='after'){
id.innerHTML += data;
}
}else{
if(typeof(addingPos)=='undefined' || !addingPos){
this.obj(id).innerHTML = data;
}else if(addingPos=='begin' || addingPos=='before'){
this.obj(id).innerHTML = data + this.obj(id).innerHTML;
}else if(addingPos=='end' || addingPos=='after'){
this.obj(id).innerHTML += data;
}
}
},

gotoURL: function(url){
document.location.href = url;
},

findPosX: function(obj){
var curleft = 0;
if (obj.offsetParent){
while (obj.offsetParent){
curleft += obj.offsetLeft;
obj = obj.offsetParent;
}
}else{
if (obj.x) curleft += obj.x;
}
return curleft;
},

findPosY: function(obj){
var curtop = 0;
if (obj.offsetParent){
while (obj.offsetParent){
curtop += obj.offsetTop;
obj = obj.offsetParent;
}
}else{
if (obj.y) curtop += obj.y;
}
return curtop;
},

toInt: function(val){
if (val=='' || val==null || val==NaN) val=0;
return (parseInt(val));
},

setSize: function(base,inc){
return ((this.toInt(base)+inc)+'px');
},

textSelection: function(nodeObj, isAvailable){
nodeObj = (typeof(nodeObj)=='string' ? im_gui.misc.obj(nodeObj) : nodeObj);
if (im_gui.browser.ie){
nodeObj.onselectstart = function(){return isAvailable;};
}else if(im_gui.browser.ff){

nodeObj.style.MozUserSelect = (isAvailable ? "" : "none");
}else{
nodeObj.onmousedown = function(){return isAvailable;};
}
}
},

display: {

setOpacity: function(objElement,intOpacity){
if (im_gui.browser.ie){
if(typeof(objElement)=='object'){
objElement.style.filter = "alpha(opacity="+intOpacity+")";
}else{
im_gui.misc.obj(objElement).style.filter = "alpha(opacity="+intOpacity+")";
}
}else{
if(typeof(objElement)=='object'){
objElement.style.opacity = intOpacity/100;
}else{
im_gui.misc.obj(objElement).style.opacity = intOpacity/100;
}
}
},

getObjOpacity: function(obj){
var opc;
if(im_gui.browser.ie){
if(typeof(obj)=='object'){
if (obj && obj.filters && obj.filters.alpha && obj.filters.alpha.opacity){
opc = obj.filters.alpha.opacity;
}else{
setObjOpacity(obj,100);
opc = 100;
}
}else{
if (im_gui.misc.obj(obj) && im_gui.misc.obj(obj).filters && im_gui.misc.obj(obj).filters.alpha && im_gui.misc.obj(obj).filters.alpha.opacity){
opc = im_gui.misc.obj(obj).filters.alpha.opacity;
}else{
setObjOpacity(im_gui.misc.obj(obj),100);
opc = 100;
}
}
}else{
if(typeof(obj)=='object'){
opc = obj.style.opacity*100;
}else{
opc = im_gui.misc.obj(obj).style.opacity*100;
}
}
if (opc==''){
if(typeof(obj)=='object'){
this.setObjOpacity(obj,100);
}else{
this.setObjOpacity(im_gui.misc.obj(obj),100);
}
opc = 100;
}
return (opc);
},

hideDLLObjs: function(){
var elems = im_gui.obj("object","tag",document);
for(var i=0; i<elems.length;i++){
if(
(
elems[i].getAttribute("classid")!=null && 
elems[i].getAttribute("classid")=="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
) || (
elems[i].getAttribute("type")!=null && 
elems[i].getAttribute("type")=="application/x-shockwave-flash"
)
){
elems[i].style.visibility="hidden";
}
}
if(document.all){
elems = im_gui.obj("select","tag",document);
for(var i=0; i<elems.length;i++){
elems[i].style.visibility="hidden";
}
}
},

showDLLObjs: function(){
var elems = im_gui.obj("object","tag",document);
for(var i=0; i<elems.length;i++){
if(
(
elems[i].getAttribute("classid")!=null && 
elems[i].getAttribute("classid")=="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
) || (
elems[i].getAttribute("type")!=null && 
elems[i].getAttribute("type")=="application/x-shockwave-flash"
)
){
elems[i].style.visibility="visible";
}
}
if(document.all){
elems = im_gui.obj("select","tag",document);
for(var i=0; i<elems.length;i++){
elems[i].style.visibility="visible";
}
}
}
},

datetime: {

sectotime: function(secs){
var h,m;
h = Math.floor(secs / 3600);
secs -= h*3600;
m = Math.floor(secs / 60);
secs -= m*60;
secs = Math.round(secs);
if (secs==60) secs = 0;
return ((h>0?(h<10?'0'+h:h)+':':'')+(m<10?'0'+m:m)+':'+(secs<10?'0'+secs:secs));
}
},

string: {

pad: function(num,pad,size,side){
if(typeof(side)=='undefined'){var side='';}
if (num.length == size) return(num);
for (var i=num.length-1 ; i<size ; i++){
if (side=='right'){
num += ""+pad;
}else if (side=='left'){
num = ""+pad+num;
}else{
num = ""+pad+num+pad;
}
}
return (num);
},

limit_str: function(str, maxLength){
return (str.length > maxLength-4 ? str.substr(0, maxLength) + ' ...' : str);
}
},

input: {

initTxtInputs: function(){
var inps = im_gui.misc.obj("input","tag",document);
for(i=0;i<inps.length;i++){
if(inps[i].getAttribute("type")=='text'){
if(inps[i].getAttribute("invertValue")=='yes'){
inps[i].onfocus = function (){im_gui.input.invertValue(this,"focus",this.defaultValue);};
inps[i].onblur = function (){im_gui.input.invertValue(this,"blur",this.defaultValue);};
}
}
}
var inps = im_gui.misc.obj("textarea","tag",document);
for(i=0;i<inps.length;i++){
if(inps[i].getAttribute("invertValue")=='yes'){
inps[i].onfocus = function (){im_gui.input.invertValue(this,"focus",this.defaultValue);};
inps[i].onblur = function (){im_gui.input.invertValue(this,"blur",this.defaultValue);};
}
}
},

invertValue: function(objInput, evntRaised, strTxt){
if (evntRaised=="focus"){
if(objInput.value==strTxt){objInput.value='';}
}else if (evntRaised=="blur"){
if(objInput.value==''){objInput.value=strTxt;}
}
}
},

css: {
addClass: function(obj, theClassName){
if(typeof(obj)=='string'){var obj = im_gui.obj(obj);}
obj.className = (obj.className=="" ? theClassName : (obj.className.indexOf(theClassName)==-1 ? +" "+theClassName : obj.className));
},

removeClass: function(obj, theClassName){
if(typeof(obj)=='string'){var obj = im_gui.obj(obj);}
var regExp = new RegExp("\s?"+theClassName, "g");
obj.className = obj.className.replace(regExp, "");
}
}
};var im_center = {
curDiv_num: 0,
_is_cover_screen: false,
_is_dragndrop: false,
sizesArr: new Array(),

show: function(sizeKey, objContent, isMkCover, isMkDragNDrop){
if(typeof(sizeKey)=='string' && typeof(this.sizesArr[sizeKey])=='undefined'){sizeKey = 'default';}
if(typeof(isMkCover)=='undefined' || isMkCover==''){var isMkCover=this._is_cover_screen;}
if(typeof(isMkDragNDrop)=='undefined' || isMkDragNDrop==''){var isMkDragNDrop=this._is_dragndrop;}
var objSize= (typeof(sizeKey)=='string' ? this.sizesArr[sizeKey] : sizeKey);
var objPos = im_gui.window.getCenterizedPos(objSize.width, objSize.height);
var divCenterObj = document.createElement('div');
this.curDiv_num++;
if(isMkCover){
var divCoverObj= document.createElement('div');
with(divCoverObj){
className = "im_coverDiv";
id= "im_coverDiv_"+this.curDiv_num;
onclick = function(){im_center.close();}
with(style){
position = "fixed"; 
left = "0px";
top = "0px";
width= "100%";
height= "100%";
}
}
im_gui.display.hideDLLObjs();
document.body.appendChild(divCoverObj);
}
if(isMkDragNDrop){if(typeof(im_dragndrop)=="object"){im_dragndrop.set(divCenterObj);}}
with(divCenterObj){
id= "im_centerDiv_"+this.curDiv_num;
className= "im_centerDiv";
with(style){
position = "absolute";
left = objPos.x+"px";
top = objPos.y+"px";
width= objSize.width+"px";
height= objSize.height+"px";
}
innerHTML = objContent;
}
document.body.appendChild(divCenterObj);
},

close: function(){
if(this.curDiv_num > 0){
var divCenterObj = im_gui.misc.obj('im_centerDiv_'+this.curDiv_num);
document.body.removeChild(divCenterObj);
var divCoverObj = im_gui.misc.obj('im_coverDiv_'+this.curDiv_num);
if(divCoverObj){document.body.removeChild(divCoverObj);}
this.curDiv_num--;
if(this.curDiv_num==0){im_gui.display.showDLLObjs();}
}
},

innerContent: function(data){
im_gui.misc.innerData('im_centerDiv_contentCell_'+this.curDiv_num, data);
},

appendObj: function(obj){
if(typeof(obj)=='object'){
im_gui.obj('im_centerDiv_contentCell_'+this.curDiv_num).appendChild(obj);
}
},

templates: {
defaultTmpl: '<table border="0" cellpadding="0" cellspacing="0" class="tblPopup"><tr class="rowTop"><td class="right">&nbsp;</td><td class="bg">&nbsp;</td><td class="left">&nbsp;</td></tr><tr class="rowSeperator"><td class="right">&nbsp;</td><td class="bg" align="left"><img src="/_media/images/layout/popup/close.gif" class="pointer" alt="" title="סגור" onclick="javascript: im_center.close();" /></td><td class="left">&nbsp;</td></tr><tr class="rowTitle"><td class="right">&nbsp;</td><td class="titleTd"><table border="0" cellpadding="0" cellspacing="0" style="table-layout: auto;"><tr><td>&nbsp;{TITLE}</td></tr></table></td><td class="left">&nbsp;</td></tr><tr class="rowSeperator"><td class="right">&nbsp;</td><td class="bg" align="left">&nbsp;</td><td class="left">&nbsp;</td></tr><tr class="rowMiddle"><td class="right">&nbsp;</td><td class="bg content" id="im_centerDiv_contentCell_{DIVNUM}" valign="top">{CONTENT}</td><td class="left">&nbsp;</td></tr><tr class="rowBottom"><td class="right">&nbsp;</td><td class="bg">&nbsp;</td><td class="left">&nbsp;</td></tr></table>',
galleryImg: '<table border="0" cellpadding="0" cellspacing="0" class="tblPopup"><tr class="rowTop"><td class="right">&nbsp;</td><td class="bg">&nbsp;</td><td class="left">&nbsp;</td></tr><tr class="rowSeperator"><td class="right">&nbsp;</td><td class="bg" align="left"><img src="/_media/images/layout/popup/close.gif" class="pointer" alt="" title="סגור" onclick="javascript: im_center.close();" /></td><td class="left">&nbsp;</td></tr><tr class="rowMiddle"><td class="right">&nbsp;</td><td class="bg content" id="im_centerDiv_contentCell_{DIVNUM}" valign="top">{CONTENT}</td><td class="left">&nbsp;</td></tr><tr class="rowBottom"><td class="right">&nbsp;</td><td class="bg">&nbsp;</td><td class="left">&nbsp;</td></tr></table>',
customCloseBtn: '<table border="0" cellpadding="0" cellspacing="0" class="tblPopup"><tr class="rowTop"><td class="right">&nbsp;</td><td class="bg">&nbsp;</td><td class="left">&nbsp;</td></tr><tr class="rowSeperator"><td class="right">&nbsp;</td><td class="bg" align="left"><img src="/_media/images/layout/popup/close.gif" class="pointer" alt="" title="סגור" onclick="javascript: {CLOSEBTN};" /></td><td class="left">&nbsp;</td></tr><tr class="rowTitle"><td class="right">&nbsp;</td><td class="titleTd"><table border="0" cellpadding="0" cellspacing="0" style="table-layout: auto;"><tr><td>&nbsp;{TITLE}</td></tr></table></td><td class="left">&nbsp;</td></tr><tr class="rowSeperator"><td class="right">&nbsp;</td><td class="bg" align="left">&nbsp;</td><td class="left">&nbsp;</td></tr><tr class="rowMiddle"><td class="right">&nbsp;</td><td class="bg content" id="im_centerDiv_contentCell_{DIVNUM}" valign="top">{CONTENT}</td><td class="left">&nbsp;</td></tr><tr class="rowBottom"><td class="right">&nbsp;</td><td class="bg">&nbsp;</td><td class="left">&nbsp;</td></tr></table>',

compile: function(args, tmplName){
if(typeof(tmplName)=='undefined' || tmplName==''){var tmplName='defaultTmpl';}
var templateLayout = eval('this.'+tmplName);
for(key in args){templateLayout = templateLayout.replace('{'+key+'}', args[key]);}
templateLayout = templateLayout.replace(/{DIVNUM}/g, im_center.curDiv_num+1);
return templateLayout;
}
}
};
im_center.sizesArr['default'] = {width: 300, height: 200};var im_ajax = {

isAjaxProcessing: false,
isDebug: false,
xmlhttp: null,
_retFunc: null,send: function(page,retFunc,extras,isFromSalat,isGetXML){
if (typeof(isFromSalat)== "undefined") isFromSalat = false;
if (typeof(isGetXML)== "undefined") isGetXML= false;
if (typeof(extras)=="undefined") extras = '';
this.xmlhttp = this._createXMLHTTPObject();
extras = 'file='+page+'&'+extras;
if (this.xmlhttp){
if (isFromSalat){
this.xmlhttp.open("POST", "/salat2/_ajax/ajax.index.php", true);
}else{
this.xmlhttp.open("POST", "/_ajax/ajax.index.php", true);
}
if (this.isDebug) alert('before ajax');
this._retFunc = retFunc;
this.xmlhttp.onreadystatechange = function(){

try{ if (im_ajax.xmlhttp.readyState == 4){ if (im_ajax.xmlhttp.status == 200){
if (this.isDebug) alert('in ajax');
this.isAjaxProcessing = false;
document.body.style.cursor = "auto";
retFunc((isGetXML ? im_ajax.xmlhttp.responseXML : im_ajax.xmlhttp.responseText));
}}}catch(e){ alert("XMLHTTP Error\n\n"+e.message); this.isAjaxProcessing=false; }
};
this.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

this.isAjaxProcessing = true;
this.xmlhttp.send(extras);
document.body.style.cursor = "wait";
return (true);
}else{
alert("You browser does not support Ajax functionality");
return (false);
}
},

innerData: function(id, data, addingPos){
if(typeof(id)=='object'){
if(typeof(addingPos)=='undefined' || !addingPos){
id.innerHTML = data;
}else if(addingPos=='begin' || addingPos=='before'){
id.innerHTML = data + id.innerHTML;
}else if(addingPos=='end' || addingPos=='after'){
id.innerHTML += data;
}
}else{
if(typeof(addingPos)=='undefined' || !addingPos){
this.obj(id).innerHTML = data;
}else if(addingPos=='begin' || addingPos=='before'){
this.obj(id).innerHTML = data + this.obj(id).innerHTML;
}else if(addingPos=='end' || addingPos=='after'){
this.obj(id).innerHTML += data;
}
}
},

evalScript: function(){
var tmp = document.getElementById('ajaxScript');
if (tmp){
if(tmp.innerHTML && tmp.innerHTML!=''){
try{
eval(tmp.innerHTML);
tmp.parentNode.removeChild(tmp);
}catch(e){

}
}
}
},

sendMulti: function(arrReqs,isFromSalat){

},

_createXMLHTTPObject: function(){
var xmlhttpTmp = false;
var factories = this._XMLHttpFactories();
for (var i=0;i<factories.length;i++){
try{
xmlhttpTmp = factories[i]();
}catch (e){
continue;
}
break;
}
return xmlhttpTmp;
},

_XMLHttpFactories: function(){
return[
function () {return new XMLHttpRequest()},
function () {return new ActiveXObject("Msxml2.XMLHTTP")},
function () {return new ActiveXObject("Msxml3.XMLHTTP")},
function () {return new ActiveXObject("Microsoft.XMLHTTP")}
];
}

};var im_form = {

_defLangName : 'he',
_defLangName : _curLang,

_langsArr : new Array('he', 'en'),

_lang : {
'he' : {
'isNull' : "נא להזין מידע בשדה {FIELD}.",
'isTooShort' : "נא להזין לפחות {NUM} תווים בשדה {FIELD}.",
'isTooLong' : "נא להזין לכל היותר {NUM} תווים בשדה {FIELD}.",
'isNotNumber' : "נא להזין נתונים מספריים בלבד בשדה {FIELD}.",
'isNotBigger' : "ערך השדה {FIELD_1} חייב להיות גדול משדה {FIELD_2}.",
'isNotMultiplied' : "ערך השדה {FIELD_1} חייב להיות גדול משדה {FIELD_2} פי {NUM}.",
'isNotSmaller' : "ערך השדה {FIELD_1} חייב להיות קטן משדה {FIELD_2}.",
'isNotPositive': "ערך השדה {FIELD} אינו מספר חיובי.",
'isNotNegative': "ערך השדה {FIELD} אינו מספר שלילי.",
'isNotInt': "ערך השדה {FIELD} אינו מספר שלם.",
'isNotFloat': "ערך השדה {FIELD} אינו מספר עשרוני.",
'isNotEmail' : "אי מייל אינו תקין.",
'isNotEqualPassword' : "אימות סיסמא נכשלה.",
'isNotPhone' : "מספר טלפון בשדה {FIELD} אינו תקין.",
'isNotPrice' : "מחיר אינו תקין.",
'isNotHeb' : "נא להזין תווים בעברית בלבד בשדה {FIELD}.",
'isNotEng' : "נא להזין תווים באנגלית בלבד בשדה {FIELD}.",
'isNotChecked' : "חובה לסמן שדה {FIELD}.",
'isNotFile' : "חובה לבחור קובץ לשדה {FIELD}.",
'isNotAllowedExt' : "סיומת קובץ לא מורשת לשדה {FIELD}."
},
'en' : {
'isNull' : "{FIELD} field is required.",
'isTooShort' : "Please enter at least {NUM} chars. in {FIELD} field.",
'isTooLong' : "Please enter maximum {NUM} chars. in {FIELD} field.",
'isNotNumber' : "Please enter only numeric chars in {FIELD} field.",
'isNotBigger' : "Value of field {FIELD_1} must be bigger than the value of {FIELD_2}.",
'isNotMultiplied' : "Value of field {FIELD_1} must be {NUM} times the value of {FIELD_2}.",
'isNotSmaller' : "Value of field {FIELD_1} must be smaller than the value of {FIELD_2}.",
'isNotPositive': "Value of field {FIELD} must be a positive number.",
'isNotNegative': "Value of field {FIELD} must be a negative number.",
'isNotInt': "Value of field {FIELD} must be an integer number.",
'isNotFloat': "Value of field {FIELD} must be a decimal number.",
'isNotEmail' : "Invalid E-Mail address.",
'isNotEqualPassword' : "Second password field is not the same as the first one",
'isNotPhone' : "Value of field {FIELD} must a valid phone number",
'isNotPrice' : "Price is invalid",
'isNotHeb' : "Please enter only Hebrew characters in the {FIELD} field",
'isNotEng' : "Please enter only English characters in {FIELD} field",
'isNotChecked' : "You have to check the {FIELD} field",
'isNotAgreeTerms' : "You have to agree terms and conditions",
'isNotFile' : "You have to select file to the {FIELD} field",
'isNotAllowedExt' : "The file extention is not allowed for the {FIELD} field"
}
},

checkForm: function(formID, isBreakByAlert, isSubmitOnSuccess){
if(typeof(isBreakByAlert)=='undefined'){var isBreakByAlert = true;}
if(typeof(isSubmitOnSuccess)=='undefined'){var isSubmitOnSuccess = false;}
var str = this.validate(formID, 'inputErrorClass', isBreakByAlert);
if(str.indexOf('<ok />') == -1){
if(!isBreakByAlert){
alert(str.replace('<err />', ''));
}
return false;
}
if(isSubmitOnSuccess){document.getElementById(formID).submit();}else{return true;}
},

submitAjaxForm: function(formID, frmAction, finishFunction, isToSalat){
function submitAjaxForm_done(data){
alert(data);
}
var str = this._makeAjaxForm(formID);
if(str.indexOf('<err />')==-1){
im_ajax.send(frmAction, finishFunction ? finishFunction : im_form.submitAjaxForm_done, str, isToSalat);
}else{
return false;
}
},

_makeAjaxForm: function(formID){
var str = this.checkForm(formID);
if(str==false){return "<err />";}else{str = "";}
var formElement = document.getElementById(formID);
var inputsArr= formElement.elements;
for(i=0;i<inputsArr.length;i++){
switch(inputsArr[i].type.toLowerCase()){
case "radio":
case "checkbox":
if(inputsArr[i].checked){str += inputsArr[i].name + "=" + inputsArr[i].value + "&";}
break;
case "select-one":
case "select-multiple":
str += inputsArr[i].name + "=" + inputsArr[i].options[inputsArr[i].selectedIndex].value + "&";
break;
case "option":
case "reset":
break;
default:
str += inputsArr[i].name + "=" + inputsArr[i].value + "&";
}
}
str = str.substr(0,str.length-1);
return str;
},

validate: function(formID, errorClass, isBreakByAlert, langName){
if(formID=='' || !document.getElementById(formID)){alert("ERROR: '"+formID+"' Is not found!");return '';}
if(typeof(langName)=='undefined' || !this.is_inArray(langName, this._langsArr)){langName = this._defLangName;}
if(typeof(isBreakByAlert)=='undefined' || isBreakByAlert==null){isBreakByAlert = false;}
var theElem;
var formElement = document.getElementById(formID);
var inputsArr= formElement.elements;
var inpDefValue = inpValue = inpName = required = reqType = reqName = reqValue = err = fileExt = extParams = "";
var i = j = 0;
var isChecked = false;
var fieldArr = new Array();
for(i=0; i < inputsArr.length; i++){
theElem = inputsArr[i];
inpName = theElem.name;
required = theElem.getAttribute('required');
if(required!='' && required!=null){
if(!this._is_inArray(inpName, fieldArr)){
fieldArr[fieldArr.length] = inpName;
required= required.split(';');
reqType = required[0].split(':')[0];
reqName = required[0].split(':')[1];
reqValue = required[0].split(':')[2];
extParams= required[1];
inpValue = theElem.value;
inpDefValue = theElem.defaultValue;
if(inpValue!=inpDefValue || extParams.toUpperCase().indexOf('ALLOW_DEFAULT')==-1){
switch(theElem.type.toLowerCase()){
case "checkbox":
case "radio":
for(isChecked=false,j=0;j<inputsArr.length && !isChecked;j++){if(inputsArr[j].type==theElem.type && inputsArr[j].name==inpName && inputsArr[j].checked){isChecked = true;}}
if(!isChecked){
err += reqValue ? reqValue : this._setErrMsg(langName, (reqType=='terms' ? 'isNotAgreeTerms' : 'isNotChecked'), '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);return err;}
}else{this._removeErrClass(theElem, errorClass);}
break;
case "select-one":
case "select-multiple":
if(theElem.options[theElem.selectedIndex].value==''){
err += reqValue ? reqValue : this._setErrMsg(langName, 'isNotChecked', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);return err;}
}else{this._removeErrClass(theElem, errorClass);}
break;
case "file":
fileExt = inpValue.split('.');
fileExt = fileExt[fileExt.length-1].toLowerCase();
extParams = extParams.split(",")[0].split("|");
if(inpValue==''){
err += reqValue ? reqValue : this._setErrMsg(langName, 'isNotFile', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);return err;}
}else{
if(!this._is_inArray(fileExt,extParams)){
err += reqValue ? reqValue : this._setErrMsg(langName, 'isNotAllowedExt', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);return err;}
}else{this._removeErrClass(theElem, errorClass);}
}
break;
case "text":
case "hidden":
case "password":
case "textarea":
extParams = extParams ? extParams.split(':') : inpValue.length;
if(extParams.length>1){extParams[2] = extParams[1].substring(extParams[1].indexOf(','));extParams[1] = extParams[1].substring(0, extParams[1].indexOf(','));}
if(inpValue==inpDefValue || inpValue==''){
err +=  this._setErrMsg(langName, 'isNull', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else if( ((reqType!='numeric') || (extParams[0]>0)) && (inpValue.length < extParams[0]) ){
err += this._setErrMsg(langName, 'isTooShort', Array("{FIELD}","{NUM}"), Array(reqName,extParams[0]));
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else if( ((reqType!='numeric') || (extParams[0]>0)) && (inpValue.length > extParams[1]) ){
err += this._setErrMsg(langName, 'isTooLong', Array("{FIELD}","{NUM}"), Array(reqName,extParams[1]));
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{
switch(reqType.toLowerCase()){
case "any": this._removeErrClass(theElem, errorClass); break;
case "numeric":
if(!this._is_valid_string(inpValue, 'NUMBER')){
err += reqValue ? reqValue : this._setErrMsg(langName, 'isNotNumber', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{
this._removeErrClass(theElem, errorClass);
if(extParams.join().toUpperCase().indexOf('POSITIVE') > -1){
if(parseInt(inpValue) < 0){
err += this._setErrMsg(langName, 'isNotPositive', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{this._removeErrClass(theElem, errorClass);}
}else if(extParams.join().toUpperCase().indexOf('NEGATIVE') > -1){
if(parseInt(inpValue) > 0){
err += this._setErrMsg(langName, 'isNotNegative', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{this._removeErrClass(theElem, errorClass);}
}
if(extParams.join().toUpperCase().indexOf('INT') > -1){
if(!this._is_valid_string(inpValue, 'INT')){
err += this._setErrMsg(langName, 'isNotInt', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{this._removeErrClass(theElem, errorClass);}
}else if(extParams.join().toUpperCase().indexOf('FLOAT') > -1){
if(!this._is_valid_string(inpValue, 'FLOAT')){
err += this._setErrMsg(langName, 'isNotFloat', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{this._removeErrClass(theElem, errorClass);}
}
switch(extParams[0].toUpperCase()){
case 'GREATER_THAN':
if(inpValue<=parseInt(eval('formElement.'+extParams[1]).value+extParams[3])){
err += this._setErrMsg(langName, 'isNotBigger', Array("{FIELD_1}","{FIELD_2}"), Array(reqName,extParams[2]));
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{this._removeErrClass(theElem, errorClass);}
break;
case 'SMALLER_THAN':
if(inpValue>=parseInt(eval('formElement.'+extParams[1]).value+extParams[3])){
err += this._setErrMsg(langName, 'isNotSmaller', Array("{FIELD_1}","{FIELD_2}"), Array(reqName,extParams[2]));
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{this._removeErrClass(theElem, errorClass);}
break;
case 'MULTIPLIED_BY':
if(inpValue!=parseInt(eval('formElement.'+extParams[1]).value*extParams[3])){
err += this._setErrMsg(langName, 'isNotMultiplied', Array("{FIELD_1}","{FIELD_2}","{NUM}"), Array(reqName,extParams[2],extParams[3]));
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{this._removeErrClass(theElem, errorClass);}
break;
}
}
break;
case "email":
if(!this._is_valid_string(inpValue, 'EMAIL')){
err += reqValue ? reqValue : this._setErrMsg(langName, 'isNotEmail', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{this._removeErrClass(theElem, errorClass);}
break;
case "phone":
if(!this._is_valid_string(inpValue, 'PHONE')){
err += reqValue ? reqValue : this._setErrMsg(langName, 'isNotPhone', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{this._removeErrClass(theElem, errorClass);}
break;
case "price":
if(!this._is_valid_string(inpValue, 'PRICE')){
err += reqValue ? reqValue : this._setErrMsg(langName, 'isNotPrice', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{this._removeErrClass(theElem, errorClass);}
break;
case "hebrew":
if(!this._is_valid_string(inpValue, 'HEBREW')){
err += reqValue ? reqValue : this._setErrMsg(langName, 'isNotHeb', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{this._removeErrClass(theElem, errorClass);}
break;
case "english":
if(!this._is_valid_string(inpValue, 'ENGLISH')){
err += reqValue ? reqValue : this._setErrMsg(langName, 'isNotEng', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{this._removeErrClass(theElem, errorClass);}
break;
case "password":
if(extParams && extParams!=''){
if(inpValue!=eval('formElement.'+extParams[1]).value){
err += reqValue ? reqValue : this._setErrMsg(langName, 'isNotEqualPassword', '{FIELD}', reqName);
this._setErrClass(theElem, errorClass);
if(isBreakByAlert){alert(err);theElem.focus();return err;}
}else{this._removeErrClass(theElem, errorClass);}
}
break;
default:
break;
}
}
break;
default:
break;
}
}
}
}
}
return (err=='' ? '<ok />' : '<err />'+err);
},

_is_inArray: function(str, arr){
for(i in arr){if(str == arr[i]){return true;}}
return false;
},

_setErrClass: function(theElem, errorClass){
if(theElem.className.indexOf(errorClass) == -1){
theElem.setAttribute('orgClass',theElem.className);
theElem.className =  (theElem.className=="" ? errorClass : theElem.className + " " + errorClass);
}
},

_removeErrClass: function(theElem, errorClass){
var ptrn = new RegExp(" ?"+errorClass);
theElem.className = theElem.className.replace(ptrn, "");
},

_setErrMsg: function(langName, errKey, tmplArr, replaceArr){
var errorStr = this._lang[langName][errKey];
if(typeof(tmplArr)=='string'){
errorStr = errorStr.replace(tmplArr,replaceArr);
}else{
for(i in tmplArr){errorStr = errorStr.replace(tmplArr[i],replaceArr[i])}
}
return errorStr + "\n";
},_is_valid_string: function(testStr, format){
var ptrn = "";
switch(format.toUpperCase()){
case 'INT': ptrn = "^\-?[0-9]+$"; break;
case 'FLOAT': ptrn = "^\-?[0-9]+\.[0-9]+$"; break;
case 'PHONE': ptrn = "^(:?[0-9]+\-)*[0-9]+$"; break;
case 'NUMBER': ptrn = "^\-?[0-9\.?]+[^\.]$"; break;
case 'PRICE': ptrn = "^[0-9]+(:?\.[0-9]+)?$"; break;
case 'HEBREW': ptrn = "[א-ת ]+"; break;
case 'ENGLISH': ptrn = "[a-z ]+"; break;
case 'EMAIL': ptrn = "^[\-a-z\w\.]+@([\-a-z0-9]+\.)+[a-z]{2,}$"; break;
case 'PASSWORD': ptrn = "[\w]+"; break;
}
ptrn = new RegExp(ptrn);
return ptrn.test(testStr);
}
};function doTagSearch(theTag){
im_gui.obj('frmSearch').txtQuery.value = theTag;
im_gui.obj('frmSearch').submit();
}
