﻿var marked_row = new Array;

function setPointer(theRow, theAction, theDefaultColor, thePointerColor)
{
    var theCells = null;
	var theRowNum = null;
	var theMarkColor = "";

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function


 lang = 1;	// 1: Farsi, 0: English
var path = '';  //This must be set after upload!!!
var farsikey = [
   0x0020, 0x0021, 0x061B, 0x066B, 0x00A4, 0x066A, 0x060C, 0x06AF,
   0x0029, 0x0028, 0x002A, 0x002B, 0x0648, 0x002D, 0x002E, 0x002F,
   0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
   0x0038, 0x0039, 0x003A, 0x06A9, 0x003E, 0x003D, 0x003C, 0x061F,
   0x066C, 0x0624, 0x200C, 0x0698, 0x0649, 0x064D, 0x0625, 0x0623,
   0x0622, 0x0651, 0x0629, 0x00BB, 0x00AB, 0x0621, 0x004E, 0x005D,
   0x005B, 0x0652, 0x064B, 0x0626, 0x064F, 0x064E, 0x0056, 0x064C,
   0x0058, 0x0650, 0x0643, 0x062C, 0x005C, 0x0686, 0x00D7, 0x0640,
   0x200D, 0x0634, 0x0630, 0x0632, 0x064A, 0x062B, 0x0628, 0x0644,
   0x0627, 0x0647, 0x062A, 0x0646, 0x0645, 0x067E, 0x062F, 0x062E,
   0x062D, 0x0636, 0x0642, 0x0633, 0x0641, 0x0639, 0x0631, 0x0635,
   0x0637, 0x063A, 0x0638, 0x007D, 0x007C, 0x007B, 0x007E
];

function FKeyDown(x)
{
	   if (lang == 0) {
			sss = 'document[\'' + window.event.srcElement.name + '\'].src=\'http://'+ window.location.host + path + '/images/fa.gif\';';
			eval(sss);

			lang = 1;
			window.status = "Farsi";
			
			ddd = 'document.all.'+ x.name +'.focus();';
			eval(ddd); 
			return true;
		}
		else {
			sss = 'document[\'' + window.event.srcElement.name + '\'].src=\'http://'+ window.location.host + path + '/images/en.gif\';';
			eval(sss);

			lang = 0;
			window.status = "English";

			ddd = 'document.all.'+ x.name +'.focus();';
			eval(ddd);
		    return true;
	      }
	return false;
}

function FKeyPress(frmVar){
    var key = window.event.keyCode;

	if (key==0x000D){
			tempEvalStr = 'document.'+ frmVar +'.submit();';
			eval(tempEvalStr);
		   return true;
		 } 	

		if (key < 0x0020 || key >= 0x00FF){
		   alert('\u0628\u0631\u0627\u064a \u0648\u0631\u0648\u062f \u0645\u062a\u0646 \u0641\u0627\u0631\u0633\u064a\u060c \u0628\u0627\u064a\u062f \u0632\u0628\u0627\u0646 \u0633\u064a\u0633\u062a\u0645 \u0634\u0645\u0627 \u0627\u0646\u06af\u0644\u064a\u0633\u064a \u0628\u0627\u0634\u062f \u0648 \u0641\u0642\u0637 \u0627\u0632 \u0637\u0631\u064a\u0642 \u062f\u06a9\u0645\u0647 \u062a\u063a\u064a\u064a\u0631 \u0632\u0628\u0627\u0646 \u0627\u0642\u062f\u0627\u0645 \u0628\u0647 \u0627\u064a\u0646 \u0639\u0645\u0644 \u0646\u0645\u0627\u064a\u064a\u062f.');
		   return false;
		}

		

	   if (lang == 1) { //If Farsi
			  if (key == 0x0020 && window.event.shiftKey) { // Shift-space -> ZWNJ
				window.event.keyCode = 0x200C;
				return true;
		      }else{
				window.event.keyCode = farsikey[key - 0x0020];
				 if ( farsikey[key-0x0020] == 92){   
					window.event.keyCode = 0x0698;
					return true;
				 }
				 if ( farsikey[key-0x0020] == 8205){   
					window.event.keyCode = 0x067E;
					return true;
				 }
			 return true;
		   }
		}
  

   return true;
}



function frmValidate(frmObj){

	flag=true;
	str = '      \u06af\u0632\u06cc\u0646\u0647 \u0647\u0627\u06cc \u0632\u06cc\u0631 \u0627\u062c\u0628\u0627\u0631\u06cc \u0647\u0633\u062a\u0646\u062f \n The following items are mandatory \n ****************************************\n';
	for(i=0;i<frmObj.length;i++){
		if(frmObj[i].mandatory){
			if(frmObj[i].value == "" || frmObj[i].value == null){
					str = str + '       >>  ' + frmObj[i].name + '\n';
					frmObj[i].style.backgroundColor = "#FFCCCC";
					flag=false;
			}
		}
	}
if(flag==true){
	return true;
}else{
	alert(str);
	return false;
}

}


function ActWindow(url, windheight, windwidth, windtop, windleft){
		var windowParam ;
		windowParam = "" ;
		windowParam += "height=" + windheight + "," ;
		windowParam += "width=" + windwidth + "," ;
		windowParam += "status=no,toolbar=no,menubar=no,scrollbars=no,location=no,resizable=no," ;
		windowParam += "top=" + windtop + "," ;
		windowParam += "left=" + windleft ;
		strSend = window.open(url, null, windowParam) ;
		if (strSend == "" || strSend == null)
			return false ;    // user canceled
		else
			return true ;
		}
		
		
		
		