//------------------------------------------ var globalFrm = null; var Utf8 = { encode : function (string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, decode : function (utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } } //------------------------------------------ sprintfWrapper = { init : function () { if (typeof arguments == 'undefined') { return null; } if (arguments.length < 1) { return null; } if (typeof arguments[0] != 'string') { return null; } if (typeof RegExp == 'undefined') { return null; } var string = arguments[0]; var exp = new RegExp(/(%([%]|(\-)?(\+|\x20)?(0)?(\d+)?(\.(\d)?)?([bcdfosxX])))/g); var matches = new Array(); var strings = new Array(); var convCount = 0; var stringPosStart = 0; var stringPosEnd = 0; var matchPosEnd = 0; var newString = ''; var match = null; while (match = exp.exec(string)) { if (match[9]) { convCount += 1; } stringPosStart = matchPosEnd; stringPosEnd = exp.lastIndex - match[0].length; strings[strings.length] = string.substring(stringPosStart, stringPosEnd); matchPosEnd = exp.lastIndex; matches[matches.length] = { match: match[0], left: match[3] ? true : false, sign: match[4] || '', pad: match[5] || ' ', min: match[6] || 0, precision: match[8], code: match[9] || '%', negative: parseInt(arguments[convCount]) < 0 ? true : false, argument: String(arguments[convCount]) }; } strings[strings.length] = string.substring(matchPosEnd); if (matches.length == 0) { return string; } if ((arguments.length - 1) < convCount) { return null; } var code = null; var match = null; var i = null; for (i=0; i= (this.newHeight - (headHeight + footHeight))) { this.tbody.style.overflow = '-moz-scrollbars-vertical'; for (x=0; x'; document.body.appendChild(d); var i = document.getElementById(n); if (c && typeof(c.onComplete) == 'function') { i.onComplete = c.onComplete; } return n; }, form : function(f, name) { f.setAttribute('target', name); }, submit : function(f, c) { AIM.form(f, AIM.frame(c)); if (c && typeof(c.onStart) == 'function') { return c.onStart(); } else { return true; } }, loaded : function(id) { var i = document.getElementById(id); if (i.contentDocument) { var d = i.contentDocument; } else if (i.contentWindow) { var d = i.contentWindow.document; } else { var d = window.frames[id].document; } if (d.location.href == "about:blank") { return; } if (typeof(i.onComplete) == 'function') { i.onComplete(d.body.innerHTML); } } } //------------------------------------------ function getStyle(el, property) { if (!el) { return null; } if (el.currentStyle) { var tmp = property.split('-'); property = tmp[0]; for (var i = 1; i < tmp.length; i++) { property += tmp[i].slice(0, 1).toUpperCase() + tmp[i].slice(1); } return el.currentStyle[property]; } else if (window.getComputedStyle) { return document.defaultView.getComputedStyle(el, null).getPropertyValue(property); } return null; } //------------------------------------------ function setPointer(theRow, thePointerColor) { if (typeof(theRow.style) == 'undefined' || typeof(theRow.cells) == 'undefined') { return false; } var row_cells_cnt = theRow.cells.length; for (var c = 0; c < row_cells_cnt; c++) { theRow.cells[c].bgColor = thePointerColor; } return true; } //------------------------------------------ function About(){ iLeft = (screen.width/2) - 250; iTop = (screen.height/2) - 150; window.open("index.php?component=common&page=wce.about&headfoot=no","Popup","width=300,height=210,top="+iTop+",left="+iLeft+",dependent=yes"); } function calll(){ iLeft = (screen.width/2) - 250; iTop = (screen.height/2) - 150; window.open("index.php?component=common&page=wce.calll&headfoot=no","Popup","width=600,height=400,top="+iTop+",left="+iLeft+",dependent=yes"); } //------------------------------------------ function pdm(){ iLeft = (screen.width/2) - 150; iTop = (screen.height/2) - 50; window.open("../pdm/pdm.php","Popup","scrollbars=yes,dependent=yes"); } //------------------------------------------ PositionX = (screen.width/2) - 250; PositionY = (screen.height/2) - 150; defaultWidth = 500; defaultHeight = 500; var AutoClose = true; if (parseInt(navigator.appVersion.charAt(0))>=4){ var isNN=(navigator.appName=="Netscape")?1:0; var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;} var optNN='scrollbars=no,addressbar=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY; var optIE='scrollbars=no,addressbar=no,width=150,height=100,left='+PositionX+',top='+PositionY; //------------------------------------------ function popImage(imageURL,imageTitle){ if (isNN){imgWin=window.open('about:blank','',optNN);} if (isIE){imgWin=window.open('about:blank','',optIE);} with (imgWin.document){ writeln('Loading...');writeln(''); writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){'); writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}'); writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);'); writeln('width=100-(document.body.clientWidth-document.images[0].width);'); writeln('height=100-(document.body.clientHeight-document.images[0].height);'); writeln('window.resizeTo(width,height);}');writeln('if (isNN){'); writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}'); writeln('function doTitle(){document.title="View Image";}');writeln(''); if (!AutoClose) writeln('') else writeln(''); writeln(''); close(); } } //------------------------------------------ var bikky = document.cookie; function getCookie(name) { var index = bikky.indexOf(name + "="); if (index == -1) return null; index = bikky.indexOf("=", index) + 1; var endstr = bikky.indexOf(";", index); if (endstr == -1) endstr = bikky.length; return unescape(bikky.substring(index, endstr)); } function setCookie(name, value) { if (value != null && value != "") document.cookie=name + "=" + escape(value) + ";"; bikky= document.cookie; } var bikkys = document.cookie; function getexpirydate(nodays){ var UTCstring; Today = new Date(); nomilli=Date.parse(Today); Today.setTime(nomilli+nodays*24*60*60*1000); UTCstring = Today.toUTCString(); return UTCstring; } function getcookietime(cookiename) { var cookiestring=""+document.cookie; var index1=cookiestring.indexOf(cookiename); if (index1==-1 || cookiename=="") return ""; var index2=cookiestring.indexOf(';',index1); if (index2==-1) index2=cookiestring.length; return unescape(cookiestring.substring(index1+cookiename.length+1,index2)); } function setcookietime(name,value,duration){ cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration); document.cookie=cookiestring; bikkys= document.cookie; if(!getcookietime(name)){ return false; } else{ return true; } } //------------------------------------------ function getInputsByName( name ) { var results = []; results.numChecked = 0; var input = document.getElementsByTagName("input"); for ( var i = 0; i < input.length; i++ ) { if ( input[i].name == name ) { results.push( input[i] ); if ( input[i].checked ) results.numChecked++; } } return results; } //------------------------------------------ var errMsg = { required: { msg: "This field is required.", test: function(obj) { if ( obj.type == "checkbox" || obj.type == "radio" ) return getInputsByName( obj.name ).numChecked; else return obj.value.length > 0 && obj.value != obj.defaultValue && !/^\s*$/.test(obj.value); } }, number: { msg: "Not a valid number.", test: function(obj) { return !isNaN(parseFloat(obj.value, 10)); } }, email: { msg: "Not a valid email address.", test: function(obj) { return !obj.value || /^[a-z0-9_+.-]+\@([a-z0-9-]+\.)+[a-z0-9]{2,4}$/i.test( obj.value ); } }, phone: { msg: "Not a valid phone number.", test: function(obj) { var m = /(\d{3}).*(\d{3}).*(\d{4})/.exec( obj.value ); if ( m ) obj.value = "(" + m[1] + ") " + m[2] + "-" + m[3]; return !obj.value || m; } }, date: { msg: "Not a valid date.", test: function(obj) { return !obj.value || /^\d{2}\/\d{2}\/\d{2,4}$/.test(obj.value); } }, url: { msg: "Not a valid URL.", test: function(obj) { return !obj.value || obj.value == 'http://' || /^https?:\/\/([a-z0-9-]+\.)+[a-z0-9]{2,4}.*$/.test( obj.value ); } }, same: { msg: "Should be same as %s.", test: function(obj) { return (obj.value == $('obj.hzP1').value); } }, rangc: { msg: "Should have between %s and %s characters.", test: function(obj) { return (obj.value.length >= obj.hzP1 && obj.value.length <= obj.hzP2); } }, rangn: { msg: "Should be between %s and %s.", test: function(obj) { return (obj.value >= obj.hzP1 && obj.value <= obj.hzP2); } } }; //------------------------------------------ function validateForm( form, load ) { var valid = true; for ( var i = 0; i < form.elements.length; i++ ) { hideErrors( form.elements[i] ); if ( ! validateField( form.elements[i], load ) ) valid = false; } return valid; } //------------------------------------------ function validateField( elem, load ) { var errors = []; for ( var name in errMsg ) { var re = new RegExp("(^|\\s)" + name + "(\\s|$)"); var classInfos = elem.className.toString().split(':'); if (classInfos.length > 1) { elem.className = classInfos[0]; elem.hzP1 = classInfos[1]; elem.hzP2 = classInfos[2]; } if ( re.test( elem.className ) && !errMsg[name].test( elem ) ) errors.push( sprintf(errMsg[name].msg, elem.hzP1, elem.hzP2) ); } if ( errors.length ) showErrors( elem, errors ); return (errors.length == 0); } //------------------------------------------ function hideErrors( elem ) { var next = elem.nextSibling; if ( next && next.nodeName == "UL" && next.className == "errors" ) elem.parentNode.removeChild( next ); } //------------------------------------------ function showErrors( elem, errors ) { var next = elem.nextSibling; if ( next && ( next.nodeName != "UL" || next.className != "errors" ) ) { next = document.createElement( "ul" ); next.className = "errors"; elem.parentNode.insertBefore( next, elem.nextSibling ); } for ( var i = 0; i < errors.length; i++ ) { var li = document.createElement( "li" ); li.innerHTML = errors[i]; next.appendChild( li ); } } //------------------------------------------ function watchFields( form ) { for ( var i = 0; i < form.elements.length; i++ ) { form.elements[i].onblur = function() { return validateField( this ); }; } } //------------------------------------------ errorOnHzServer = function(myDiv) { myDiv.innerHTML = '
ERROR: can NOT communicate with web server!
'; } //------------------------------------------ function updateDIV1(myFrm, myDiv) { var options = {onFailure: errorOnHzServer(myDiv), onSuccess: responseParams1 , parameters: 'rspLoc='+myDiv.id}; myDiv.innerHTML = componentLoadingTag; myFrm.request(options); } //------------------------------------------ responseParams1 = function(response){ $('grid').innerHTML = response.responseText; resetForm(this.globalFrm); getCurrentCredit(); } //------------------------------------------ function updateDIV2(myFrm, myDiv) { var options = {onFailure: errorOnHzServer(myDiv), onSuccess: responseParams2 , parameters: 'rspLoc='+myDiv.id}; myDiv.innerHTML = componentLoadingTag; myFrm.request(options); } //------------------------------------------ responseParams2 = function(response){ $('gridAll').innerHTML = response.responseText; resetForm(this.globalFrm); getCurrentCredit(); } //------------------------------------------ function updateDIV3(myFrm, myDiv) { var options = {onFailure: errorOnHzServer(myDiv), onSuccess: responseParams3 , parameters: 'rspLoc='+myDiv.id}; myDiv.innerHTML = componentLoadingTag; myFrm.request(options); } //------------------------------------------ responseParams3 = function(response){ $('gridChild').innerHTML = response.responseText; resetForm(this.globalFrm); getCurrentCredit(); } //------------------------------------------ function updateDIV(myFrm, myDiv, myButton) { //first of all we disable form button to prevent multi submission if(typeof myButton == 'object') { myButton.style.visibility='hidden'; this.globalBtn = myButton; } var options = {onFailure: errorOnHzServer(myDiv), onSuccess: responseParams , parameters: 'rspLoc='+myDiv.id}; myDiv.innerHTML = componentLoadingTag; myFrm.request(options); this.globalFrm = myFrm; } //------------------------------------------ responseParams = function(response){ if(typeof this.globalBtn == 'object') { this.globalBtn.style.visibility=''; } var backDataObj = response.responseText.toQueryParams(); $(backDataObj.rspLoc).style.color = (backDataObj.rspErr == 0 ? "green" : "red"); $(backDataObj.rspLoc).innerHTML = backDataObj.rspMsg; if (typeof doAfterCompeleteRecieve == 'function') doAfterCompeleteRecieve(backDataObj); if (backDataObj.rspErr == 0){ resetForm(this.globalFrm); } getCurrentCredit(); } //------------------------------------------ function createFrmAction(){ var queryObj = document.URL.toQueryParams(); return ((document.URL.split('?'))[0]).gsub('index.php','') + queryObj.component + '/' + queryObj.page.gsub('wce','wme') + '.php'; } //------------------------------------------ function confirmDelete(id){ if(confirm(componentConfirmDeleteTag)) { //var form = document.getElementsByTagName("form")[0]; //form.action = createFrmAction(); form.reset(); form.identity.value = id; form.act.value = 'del'; $('gridFeedback').innerHTML = componentLoadingTag; updateDIV(form, $('gridFeedback')); mode='del'; } } //------------------------------------------ function getData(id){ //var form = document.getElementsByTagName("form")[0]; //form.action = createFrmAction(); form.reset(); form.identity.value = id; form.act.value = 'get'; updateDIV(form, $('gridFeedback')); } //------------------------------------------ function colorTab(tabId) { for (var i=0;i<15 ; i++) { var t=document.getElementById(i.toString()); if(t!=null) { t.style.color='gray'; } } $(tabId).style.color='#0099FF'; } //------------------------------------------ function colorTabSMS(tabId) { for (var i=0;i<15 ; i++) { var t=document.getElementById(i.toString()); if(t!=null) { t.style.color='gray'; } } $(tabId).style.color='#0099FF'; } //------------------------------------------ function resetForm(frm){ frm.select('input[type="text"]').each( function(input) { input.clear(); } ); } //------------------------------------------ function getCurrentCredit(){ var url = 'crdt/wme.crdt.php'; new Ajax.Request(url, { method: 'get', onSuccess: function(transport) { var div = $("user_credit"); div.innerHTML = transport.responseText; } }); } var farsikey = [ 0x0020, 0x0021, 0x061B, 0x066B, 0x00A4, 0x066A, 0x060C, 0x06AF, 0x0029, 0x0028, 0x002A, 0x002B, 0x0648, 0x002D, 0x002E, 0x002F, 0x06F0, 0x06F1, 0x06F2, 0x06F3, 0x06F4, 0x06F5, 0x06F6, 0x06F7, 0x06F8, 0x06F9, 0x003A, 0x06A9, 0x003E, 0x003D, 0x003C, 0x061F, 0x066C, 0x0624, 0x200C, 0x0698, 0x06CC, 0x064D, 0x0625, 0x0623, 0x0622, 0x0651, 0x0629, 0x00BB, 0x00AB, 0x0621, 0x004E, 0x005D, 0x005B, 0x0652, 0x064B, 0x0626, 0x064F, 0x064E, 0x0056, 0x064C, 0x0058, 0x0650, 0x0643, 0x062C, 0x0698, 0x0686, 0x00D7, 0x0640, 0x067E, 0x0634, 0x0630, 0x0632, 0x06CC, 0x062B, 0x0628, 0x0644, 0x0627, 0x0647, 0x062A, 0x0646, 0x0645, 0x0626, 0x062F, 0x062E, 0x062D, 0x0636, 0x0642, 0x0633, 0x0641, 0x0639, 0x0631, 0x0635, 0x0637, 0x063A, 0x0638, 0x007D, 0x007C, 0x007B, 0x007E ]; function FKeyDown() { if (window.event.ctrlKey && window.event.altKey) { if (lang == 0) { lang = 1; window.defaultStatus = "Farsi Mode"; } else { lang = 0; window.defaultStatus = "English Mode"; } return false; } return true; } function FKeyPress() { var key = window.event.keyCode; if (key < 0x0020 || key >= 0x00FF) return; if (lang == 1) { //If Farsi if (key == 0x0020 && window.event.ctrlKey) // Shift-space -> ZWNJ window.event.keyCode = 0x200C; else window.event.keyCode = farsikey[key - 0x0020]; } return true; } function LangFar (myobj) { myobj.style.textAlign = "right"; myobj.style.direction = "rtl"; myobj.focus(); lang = 1; } function LangEng (myobj) { myobj.style.textAlign = "left"; myobj.style.direction = "ltr"; myobj.focus(); lang = 0; } function NMask(evt){ if((evt.keyCode < 48 ) || (evt.keyCode > 57 )) evt.keyCode = 0; } function CMask(evt){ if(evt.keyCode < 58 && evt.keyCode > 47 ) evt.keyCode = 0; } function SSNCheck(vmc) { var mc; mc = vmc.value; if (mc.length == 10) { if (mc == '0000000000' || mc == '2222222222' || mc == '3333333333' || mc == '4444444444' || mc == '5555555555' || mc == '6666666666' || mc == '7777777777' || mc == '8888888888' || mc == '9999999999') { alert('کد ملی اشتباه است'); vmc.focus(); return false; } c = parseInt(mc.charAt(9)); n = parseInt(mc.charAt(0)) * 10 + parseInt(mc.charAt(1)) * 9 + parseInt(mc.charAt(2)) * 8 + parseInt(mc.charAt(3)) * 7 + parseInt(mc.charAt(4)) * 6 + parseInt(mc.charAt(5)) * 5 + parseInt(mc.charAt(6)) * 4 + parseInt(mc.charAt(7)) * 3 + parseInt(mc.charAt(8)) * 2; r = n - parseInt(n / 11) * 11; if ((r == 0 && r == c) || (r == 1 && c == 1) || (r > 1 && c == 11 - r)) { return true; } else { alert('کد ملی اشتباه است'); vmc.focus(); return false; } } else { alert('لطفا 10 رقم کد ملی را وارد نمایید'); vmc.focus(); return false; } } //Talk to CS function pg2cs(message, identity) { window.postMessage("pg|cs|" + message + "#" + identity, "*"); console.log("pg2cs: ","pg|cs|" + message + "#" + identity); // window.postMessage("cs|pg|payres|0400000133493000005056209351115000000003000#" + identity + ",1,newCardPanel", base_url); } /** * International string formatter, used for currency with defaukt values * @param integer nu string to format , default number * @param string lang language default is fa-IR * @param string style type of formatting default is currency * @param string styleVal style of formatting default is IRR * @returns string */ function inf(nu, style='currency' , lang='fa-IR', styleVal = 'IRR'){ var settings = new Object(); if(style !== '') { settings.style = style; settings[style] = styleVal; } return new Intl.NumberFormat(lang, settings).format(nu); }