/**********************sof string functions**********************************************/
//var SITEPATH = '/gp/nourtek/';
String.prototype.count=function(s1) { 
	return (this.length - this.replace(new RegExp(s1,"g"), '').length) / s1.length;
}
String.prototype.countChar=function(c) { 
	var vlen = this.length;
	var j=0;
	if(this.indexOf(c) > -1){
		for(var i=0;i<vlen;i++){
			if(c == this.charAt(i)){
				j++;	
			}	
		}
	}
	return j;
}

String.prototype.trim =function(){ return this.replace(/^\s+|\s+$/g,"")};
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim =function(){ return this.replace(/^\s+/,"")};
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
String.prototype.rtrim =function(){ return this.replace(/\s+$/,"")};
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
String.prototype.trimall = function(){ return trimall(this)};
function trimall(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function chkwhitespace(s){
		//alert(s);
		var i;
		var returnString = "";
		// Search through string's characters one by one.
		// If character is not a whitespace, append to returnString.
		for (i = 0; i < s.length; i++)
		{   
		// Check that current character isn't whitespace.
		var c = s.charAt(i);
		if (c === " ") return true;
		}
		return false;
	}
function str_replace(s,r){
		var rl = r.length;
		var sl = s.length;
		s = s.substring(rl,sl);
		return s;
}
function str_replace1(ser,rpl,str){
	var si = str.indexOf(ser);
	while(si != -1){
		var str = str.replace(ser, rpl)
		si = str.indexOf(ser);
		if(si == -1)break;
	}
	return str;
}
function chkSomeCh(obj,csch){
	var obj = obj;
	var s = obj.value;
	csch = csch+"";
	var sch = "`~'";
	if(csch != "undefined" && csch !== ""){
		sch = csch;
	}
	var sch_len = sch.length;
	for(var i=0; i<sch_len;i++){
		var c = sch.charAt(i);
		if(s.indexOf(c) != -1){
			var ns = str_replace1(c,"",s);
			obj.value = ns;
			//alert(ns);
		}
	}
}
/***********************eof string function**************************************/

var brs = {
	Browser: (function(){
    var ua = navigator.userAgent;
    var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
    return {
      IE:             !!window.attachEvent && !isOpera,
      Opera:          isOpera,
      WebKit:         ua.indexOf('AppleWebKit/') > -1,
      Gecko:          ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1,
      MobileSafari:   /Apple.*Mobile.*Safari/.test(ua)
    }
  })()
};
function brsVersion(){
	var ua      = navigator.userAgent.toLowerCase();
	var msip = ua.indexOf('msie');
	var msiv      = ua.substring(msip,msip+8);
	var msiarr = msiv.split(" ");
	var msiarr1 = msiarr[1].split(".");	
	return msiarr1[0];
}
function addLoadEvent(func) {
  var existonload = window.onload;
  if (typeof window.onload != 'function') {
	if (window.addEventListener) 
	{
		window.addEventListener('load', func, false); 
	} 
	else if (window.attachEvent) // for IE
	{
		window.attachEvent('onload', func);
	}
    //window.onload = func;
  } else {
	  
    /*window.onload = function() {
      if(oldonload){oldonload();}
      func();
    }*/
  
  	if (window.addEventListener) 
	{
		if(existonload){window.addEventListener('load', existonload, false);}
		window.addEventListener('load', func, false); 
	} 
	else if (window.attachEvent) // for IE
	{
		if(existonload){window.attachEvent('onload', existonload);}
		window.attachEvent('onload', func);
	}
  }
}




var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;
var maxDigitsInIPhoneNumber =15;
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;

    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
function countChar(val, c){
	var vlen = val.length;
	var j=0;
	if(val.indexOf(c) > -1){
		for(var i=0;i<vlen;i++){
			if(c == val.charAt(i)){
				j++;	
			}	
		}
	}
	return j;
}
function phoneValidator(phoneValue){
	var strPhone = phoneValue;
	var bracket=5;
	strPhone=trimall(strPhone);
	var lbrn= strPhone.countChar("(");
	var rbrn= strPhone.countChar(")");
	//alert(lbrn%rbrn);
	if(lbrn>0 && lbrn%rbrn !=0) return false;
	if(lbrn>0 && rbrn%lbrn !=0) return false;
	if(lbrn>0 && rbrn%lbrn ==0){
		for(var i=0;i<strPhone.length;i++){
			if(strPhone.charAt(i)=="(" && strPhone.charAt(i+1) == "(")return false; 
			if(strPhone.charAt(i)==")" && strPhone.charAt(i+1) == ")")return false; 
			if(strPhone.charAt(i)=="(" && strPhone.charAt(i+1) == ")")return false; 
			 
		}	
		
	}
	if(strPhone.indexOf("+")>1) return false;
	if(strPhone.countChar("+")>1)return false;
	
	if(strPhone.indexOf("-")!=-1)bracket=bracket+1;
	if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false;
	var brchr=strPhone.indexOf("(");
	var rbac = strPhone.indexOf(")");
	
	if(strPhone.indexOf("-")!=-1 && (strPhone.indexOf("-")==(brchr+1) || strPhone.indexOf("-")== (brchr -1)))return false;
	if(strPhone.indexOf("-")!=-1 && (strPhone.indexOf("-")==(rbac+1) || strPhone.indexOf("-")== (rbac -1)))return false;
	if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+4)!=")")return false;
	
	if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false;
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	//alert(s.length);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber && s.length <= maxDigitsInIPhoneNumber );
}
function chkPhone(obj){
	var id = obj;
	if(typeof obj == 'object'){
		id = obj.id;
	}
	var y;
	var Phone = $(id);
	
	var Novalidate = "not-required";
	var noval = $HC(id,Novalidate);
	if(noval==true && Phone.value==""){
		return true;
	}
	if ((Phone.value==null)||(Phone.value=="")){
		alert("Please Enter your Phone Number");
		Phone.focus();
		return false;
	}
	if (phoneValidator(Phone.value)==false){
		alert("Please Enter a Valid Phone Number");
		//Phone.value="";
		Phone.focus();
		return false;
	}
	return true;
}
function phone(myfield, e){
	
	var key;
	var keychar;
	var fieldid = myfield.id;
	
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);
	
	if ((key==null) || (key==0) || (key==8) || 
		(key==9) || (key==13) || (key==27) ||
		(key==40) || (key==41) || (key==32)||
		(key==43)|| (key==45))
	  { 
	  	 return true;
	  }
	
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	  { 
		  if($('div'+fieldid)){
			removeElement('div'+fieldid);
		  }
	  	 removeErrorBorder(fieldid);
		
	 	 return true;
	  
	  }
	
	
	
	else
	 {  return false;}
}


function numbersonly(myfield, e)
{
	var key;
	var keychar;
	var fieldid = myfield.id;
	
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key==null) || (key==0) || (key==8) || 
		(key==9) || (key==13) || (key==27) )
	  { 
		 return true;
	  }
	
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	  { 
		  if($('div'+fieldid)){
			removeElement('div'+fieldid);
		  }
	  	 removeErrorBorder(fieldid);
		
	 	 return true;
	  
	  }
	
	
	
	else
	 {  return false;}
}

function decimalNumber(obj, e){
	var key;
	var keychar;
	var fieldid = obj.id;
	var txtnv = $v(fieldid);
	var arrn = txtnv.split(".");
	var arrnlen = arrn.length;
	
	if(window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);
	
	if(chIN(key, keychar)==true){
		if($('div'+fieldid)){
			removeElement('div'+fieldid);
		}
		return true;
	}
	else if(keychar=="."){
		if(arrnlen==1){
			
			return true;
		}
		else{return false;}
	}
	else{return false;}
}

function chIN(key, keychar){
	if ((key==null) || (key==0) || (key==8) || 
		(key==9) || (key==13) || (key==27) )
	{ 
		 return true;
	}
	else if ((("0123456789").indexOf(keychar) > -1)){ 
		return true;
	}
	else{return false;}
}

function chkNumber(val){
	var len = val.length;
	var char='';
	var rev = false;
	var j=0;
	for(var i=0; i<len; i++){
		
		char = val.substr(i, 1);
		
		if ((("0123456789").indexOf(char) > -1)){
			j++;
		}
	}
	if(len>0 && j==len){rev = true;}
	
	return rev;
}

/*********************************************************************************************** 
	This validate function is calling from the formsubmit event of the form 
	and its takes form name or the form object as an argument and validate the 
	form elements of input type{ text and file}, and tagname textarea. if you are
	not specifing any class like{required} in the element it will validate every elements
	in the form. if you specify {not-required} as class then it leaves the element and 
	validate the next element. you can validate email address and date by specifying {email} 
	and {valid-date} as class in the element. 
************************************************************************************************/

function validate(frmobj)
{
	//alert(frmobj.name);
	var formName=frmobj;
	var formId;
	if(typeof formName == 'object'){
		formName = frmobj.name;
		formId = frmobj.id;
	}
	formId = document.forms[formName].id;
	
	var formlength = document.forms[formName].elements.length;//document.frmoder.elements.length;
	//alert(formlength);
	var str=str1='';
	var strtag ='';
	var tiem=0;
	var uelm=0;
	var rev = false;
	var msgBox = false;
	var Novalidate = "not-required";
	var Valdate = "required"; 
	var hasVal = true;
	var emailClass ="email";
	var dateClass = "valid-date";
	var otherClass ="gencode";
	var numberClass ="numbers";
	var phoneClass ="valid-phone";
	var otherId = "btngencode";
	var passcom = "passcom";
	var alter = "alter";
	var objarrp = Array(); //array for passwords
	var objarra = Array(); //array for alter fields
	var email=/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
	var errdistypeClass = 'errorinmsgbox';
	var errdistypeClass1 = 'errorinbtm';
	var peles = $EBC("passcom");//$EC(passcom);
	var plen =0;
	if(peles.length>0)plen=peles.length; 
	// alert(plen);
	var aeles = $EBC("alter");//$EC(passcom);
	var alen =0;
	if(aeles.length>0)alen=aeles.length; 
	
	msgBox = $HC(formId, errdistypeClass);
	msgbtm = $HC(formId, errdistypeClass1);
	var num_yesval =0;
	for(var i=0; i<formlength; i++){
		var obj = document.forms[formName].elements[i];//document.frmoder.elements[i];
		if(obj.id)
		var id = obj.id;
		if($HC(id,Valdate)){
			num_yesval +=1;	
		}
	}
	//alert(num_yesval);
	for(var i=0; i<formlength; i++)
	{
		var obj = document.forms[formName].elements[i];//document.frmoder.elements[i];
		if(obj.id)
		if(obj.type=="text")
		{
			
			tiem +=1;
			uelm +=1;
			//alert('text '+tiem);
			var id = obj.id;
			var noval = $HC(id,Novalidate);
			var yesval =$HC(id,Valdate);
			//alert(yesval);
			if(yesval == true || num_yesval==0){
				if(!noval){
					
					var altercl = $HC(id,alter);
					
					if(IsEmpty(id))
					{
						var otheri = $HC(id,otherClass);
						if(otheri){
							if(msgBox){
								showMsgFocus(id, 'Field should not be empty !');
							}
							else if(msgbtm){
								addElement(otherId, ' Required');
								if($('div'+otherId)){
									$('div'+otherId).style.display = 'block';
								}
							}
							else{
								addElement(otherId, ' Required');
							}
						errorBorder(id);
							if(msgBox){break;}
						}else{
								if(msgBox){
									showMsgFocus(id, 'Field should not be empty !');
								}
								else if(msgbtm){
									addElement(id, ' Required');
									if($('div'+id)){
										$('div'+id).style.display = 'block';
									}
								}
								else{
									addElement(id, ' Required');
								}
								
							errorBorder(id);
							if(msgBox){break;}
						}
						/*$('div'+id).style.display='inline';
						$('div'+id).innerHTML="Required";*/
						
					}
					else
					{
						if(msgBox == false){
							removeElement('div'+id);
						}
						removeErrorBorder(id);
						
						//str +=id+' '+i+',';
						var eti = $HC(id,emailClass);
						var dti = $HC(id, dateClass);
						var otheri = $HC(id,otherClass);
						var numOnly = $HC(id, numberClass);
						var validph = $HC(id, phoneClass);
						if(eti)
						{ 
							emailvalue = $v(id);
							if(email.test(emailvalue))
							{
								uelm -=1;
								if(msgBox == false){
									removeElement('div'+id);
								}
								removeErrorBorder(id);
								if($('div'+id))
								$('div'+id).style.display='none';
							}
							else
							{
								if(msgBox){
									showMsgFocus(id, 'Invalid Email Address is entered !');	
									errorBorder(id);
									break;
								}
								else if(msgbtm){
									addElement(id, ' Invalid Email Address is entered !');
									if($('div'+id)){
										$('div'+id).style.display = 'block';
									}
								}
								else{
									addElement(id, ' Invalid Email');
								}
								errorBorder(id);
								
							}
						}
						else if(dti)
						{
							dt = $v(id);
							
							if(validDate(dt))
							{
								uelm -=1;
								if(msgBox == false){
									removeElement('div'+id);
								}
								removeErrorBorder(id);
							}
							else
							{
								if(msgBox){
									showMsgFocus(id, 'Invalid Date is entered !');	
								}
								else{
									addElement(id, 'Invalid Date');
								}
								errorBorder(id);
							}
						}
						else if(otheri){
							uelm -=1;
							if(msgBox == false){
								removeElement('div'+otherId);
							}
							
							removeErrorBorder(id);
						}
						
						else if(numOnly){
							var nmonly = chkNumber($v(id));
							if(nmonly){
								uelm -=1;
								if(msgBox == false){
									if($('div'+id)){removeElement('div'+id);}
								}
								removeErrorBorder(id);
							}
							else{
								if(msgBox){
									showMsgFocus(id, 'Please enter Number only!');	
								}
								else{
									addElement(id, 'Invalid Number');
								}
								errorBorder(id);	
								if(msgBox){break;}
							}
						}
						
						else if(validph){
							var vldph = phoneValidator($v(id));
							if(vldph){
								uelm -=1;
								if(msgBox == false){
									if($('div'+id)){removeElement('div'+id);}
								}
								removeErrorBorder(id);
							}
							else{
								if(msgBox){
									showMsgFocus(id, 'Please enter valid phone number!');	
								}
								else{
									addElement(id, 'Invalid Phone');
								}
								errorBorder(id);	
								if(msgBox){break;}
							}
						}
						else
						{
							uelm -=1;
							if(msgBox == false){
								if($('div'+id))
								removeElement('div'+id);
							}
							
						}
					
					}
				}
				else{
					uelm -=1;
				}
			}
			else{
				uelm -=1;	
			}
		}
		else if(obj.type=="password"){
			id = obj.id;
			tiem +=1;
			uelm  +=1;
			//alert('pwd '+tiem);
			var noval = $HC(id,Novalidate);
			var yesval =$HC(id,Valdate);
			var spv = $HC(id,passcom);
			
			if(yesval == true || num_yesval==0){
				if(!noval){
					
					if(!IsEmpty(id)){
						if(msgBox == false){
							removeElement('div'+id);
						}
						removeErrorBorder(id);
						if(spv==true){
							objarrp.push(id);
							//alert(objarrp.length);
							var pwdarrlen = objarrp.length;
							if(pwdarrlen==plen){
								
								if(pwdTest(objarrp)== true){
									uelm -=pwdarrlen;
								}
								else{
									for(var pai=0;pai<pwdarrlen;pai++){
										if(!msgBox){
											addElement(objarrp[pai], ' Not Matched');
										}
										else if(msgbtm){
											addElement(objarrp[pai], ' Not Matched');
											if($('div'+objarrp[pai])){
												$('div'+objarrp[pai]).style.display = 'block';
											}
										}
										errorBorder(objarrp[pai]);
									}
									if(msgBox){
										showMsgFocus(objarrp[pwdarrlen-1], 'Re type password is not mathced with the password!');		
									}
								}
							}
							
						}
						else{uelm -=1;}
						
					
					}
					else{
						
						if(msgBox){
							showMsgFocus(id, 'Field should not be empty !');	
						}
						else if(msgbtm){
							addElement(id, ' Required');
							if($('div'+id)){
								$('div'+id).style.display = 'block';
							}
						}
						else{
							addElement(id, ' Required');	
						}
						errorBorder(id);
						if(msgBox){break;}
					
					}
				
				}
				else{uelm -=1;}
				}
			else{
				uelm -=1;
			}
		}
		else if(obj.type=="file"){
			id = obj.id;
			tiem +=1;
			uelm  +=1;
			var noval = $HC(id,Novalidate);
			var yesval =$HC(id,Valdate);
			if(yesval == true || num_yesval==0){
				if(!noval){
					if(!IsEmpty(id)){
						uelm -=1;
						if(msgBox == false){
							removeElement('div'+id);
						}
						removeErrorBorder(id);
					}
					else{
						if(msgBox){
							showMsgFocus(id, 'Field should not be empty !');	
						}
						else{
							addElement(id, ' Required');	
						}
						errorBorder(id);
						if(msgBox){break;}
					}
				}
				else{uelm -=1;}
				}
			else{
				uelm -=1;
			}
		}
		
		
		else
		{
			id = obj.id;
			strtag1 = obj.tagName;
			//alert(strtag1);
			strtag1 = strtag1.toLowerCase();
			//alert(strtag1);
			if(strtag1=='textarea'){
				//strtag += strtag1;
				tiem +=1;
				uelm  +=1;
				var noval = $HC(id,Novalidate);
				var yesval =$HC(id,Valdate);
				if(yesval == true || num_yesval==0){
					if(!noval){
						if(!IsEmpty(id)){
							uelm -=1;
							if(msgBox == false){
								removeElement('div'+id);
							}
							removeErrorBorder(id);
						}
						else
						{
							if(msgBox){
								showMsgFocus(id, ' Field should not be empty !');	
							}
							else{
								addElement(id, ' Required');	
							}
							
							errorBorder(id);
							if(msgBox){break;}
						}
					}
					else{
						uelm -=1;	
					}
					}
				else{
					uelm -=1;	
				}
			}
			
			else if(strtag1=='select'){
				//strtag += strtag1;
				tiem +=1;
				uelm  +=1;
				var noval = $HC(id,Novalidate);
				var yesval =$HC(id,Valdate);
				if(yesval == true || num_yesval==0){
					if(!noval){
						
						if(!EmptySelectBox(id)){
							uelm -=1;
							if(msgBox == false){
								removeElement('div'+id);
							}
							removeErrorBorder(id);
						}
						else
						{
							if(msgBox){
								showMsgFocus(id, ' Please select a value !');	
							}
							else{
								addElement(id, ' Required');	
							}
							
							errorBorder(id);
							if(msgBox){break;}
						}
					}
					else{
						uelm -=1;	
					}
					}
				else{
					uelm -=1;	
				}
			}
			
			
			
		}
		
		
	}
	if($('divmyListBox')){
		var mylistbox = document.getElementById('divmyListBox');
		if($HC(mylistbox,Valdate)){
			tiem +=1;
			uelm  +=1;
			var mlbvldate = false; 
			mlbvldate = chkMLB();
			if(mlbvldate !== false){
				uelm -=1;	
			}
			//alert(mylistbox.className);
		}
	}
	//alert('Total No. of Elements: '+tiem+'\n\n Total No. of unfilled elements: '+uelm);
	
	if(tiem>0 && uelm==0){
		rev = true; 
		//alert(rev);
	}
	//alert(str+'\n\n'+str1+'\n\n'+strtag+'\n\n'+tiem);
	//alert(rev);
	return rev;
}

function getObjectList(objname){
	var objlist = document.getElementsByName(objname);
	return objlist;
}
function IsEmpty(id) {
	
	var value = trim($(id).value);
   if ((value.length==0) ||
	(value.length==' ') ||
   (value==null)) {
      return true;
   }
   else { return false; }
   
}
function empty() {
        return this == '';
}
function EmptySelectBox(id){
	//alert(id);
	var index = $(id).selectedIndex;
	
	var seltext = $(id).options[index].text;
	var selvalue = $(id).options[index].value;
	var selectt = seltext.toLowerCase();
	var selectv = seltext.toLowerCase();
	//alert(selvalue+'\n h: '+seltext+'\n h: '+selectv);
	var ind = selectt.indexOf('select');
	var ind1 = selectv.indexOf('select');
	if(seltext=='' || seltext.length==0 || ind> -1 ){
		if(ind == -1 ){return false;}
		if(selectt.indexOf('selected') > -1 ){return false;}
		return true;
	}
	else{return false;}
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
function emailTest(emv)
{
	var email=/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
	return email.test(emv);
}

/*check the password field have the same value.*/
function pwdTest(pwdarr){
	if(pwdarr.length>0){
		var palen = pwdarr.length;
		var pwd1val = $v(pwdarr[0]);
		var pwdt =0;
		for(var i=0; i<palen; i++){
			var pwdval = $v(pwdarr[i]);
			if(pwd1val==pwdval) pwdt++;
		}
		if(palen==pwdt){return true;}
		else{return false;}
	}
	else{return false;}
}

document.getCssClassValueById = function(id){
	var elemid = id;
	var obj = document.getElementById(elemid);
	var elemClass = obj.getAttribute("class") || obj.getAttribute("className");
	elemClass = elemClass.toLowerCase();
	elemClass = elemClass.replace(/^\s+|\s+$/g,"");// remove the left right space
	
	eCA = elemClass.split(" ");
	elemClass = eCA[0];
	var cc = "."+elemClass;
	
	var ccv = document.getCssValue(cc); 
	return ccv;
};
document.getCssValue= function(fc){
	var str='';
	var a_s = document.styleSheets;
	var sl = a_s.length;
	
	for(var si=0; si < sl; si++){
		var s = a_s[si];
		var srules = s.cssRules ? s.cssRules : s.rules;
		var totalrules=srules.length;
		var crt = fc.toLowerCase();
		for (var i=0; i<totalrules; i++){
			var str_srule = srules[i].selectorText.toLowerCase();
			//var str123 = "str_srule len: "+str_srule.length +" crt len: "+crt.length;
			//str += "<br />"+str123+"<br /> "+srules[i].selectorText;
			if(str_srule == crt){
				return srules[i].style;
				break;
			}
		}
	}
	return false;
};
document.getHeightByIdOrObj = function(id){
	var obj = id;
	if(typeof obj !== 'object'){
		if(document.getElementById(obj)){
			obj = document.getElementById(obj);
		}
	}
	if(typeof obj === 'object'){
		
		var objStyle;
		var h;
		if(obj.currentStyle){
			objStyle = obj.currentStyle;
		}
		else if(document.defaultView.getComputedStyle){
			objStyle = document.defaultView.getComputedStyle(obj,'');
		}
		else{
			objStyle = {
				height: (function(){
					return obj.offsetHeight+'px';
				})()
			};
		}
		h = objStyle.height;
		return h;	
	}
	return false;
}

document.getCssById = function(id){
	
	
	
	var elemid = id;
	var ccv = document.getCssClassValueById(elemid);
	var cssid = "#"+elemid;
	cssid = cssid.toLowerCase();
	var civ = document.getCssValue(cssid);
	var obj = document.getElementById(elemid);
	var inLineCss = obj.getAttribute('style');
	return 	{
			cssClassValue: ccv,
			cssIdValue: civ,
			inLineCss: inLineCss
			};
	
};
document.getElementsByClassName = function(className){
    var nodes = document.getElementsByTagName('*');
    var matches = new Array();
    for(i=0;i<nodes.length;i++){
        var tmp = nodes[i].getAttribute('class') || nodes[i].getAttribute('className');
        if(tmp == className) matches[matches.length] = nodes[i];
    }
    return matches;
}
document.hasClassName = function(element, className) {
    if (!(element = $(element))) return;
    var elementClassName = element.className;
    return (elementClassName.length > 0 && (elementClassName == className ||
      new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
  }
 
var $HC = function(element, className) {
    if (!(element = $(element))) return;
    var elementClassName = element.className;
	//alert(elementClassName);
    return (elementClassName.length > 0 && (elementClassName == className ||
      new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
}

var $EC = function(className){
	var nodes = document.getElementsByTagName('*');
    var matches = new Array();
    for(i=0;i<nodes.length;i++){
        var tmp = nodes[i].getAttribute('class') || nodes[i].getAttribute('className');
        if(tmp == className) matches[matches.length] = nodes[i];
    }
    return matches;
}
var $ECN = function(className){
	var nodes = document.getElementsByTagName('*');
	
    var matches = new Array();
    for(i=0;i<nodes.length;i++){
        var tmp = nodes[i].getAttribute('class') || nodes[i].getAttribute('className');
		var tmpclass =new RegExp("(^|\\s)" + className + "(\\s|$)");
		
        if(tmpclass.test(tmp)){
			matches[matches.length] = nodes[i];	
		}
		//if(tmp == className) matches[matches.length] = nodes[i];
    }
    return matches;
}

function $EBC(className){
	var nodes = document.getElementsByTagName('*');
    var matches = new Array();
    for(i=0;i<nodes.length;i++){
		var id = nodes[i].id;
       
		if((id!="" || id !=" " || id!="undefined") && id.length>0){
			var tmp1 = $HC(id, className);
			//alert(tmp1);
			if(tmp1 === true){ 
				//matches.push(nodes[i]);
				matches[matches.length] = nodes[i];
			}
		}
    }
	return matches;
}

function $(element) {
	if (arguments.length > 1) {
    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
      elements.push($(arguments[i]));
    return elements;
	}
	else{
		if(isString(element))
		element = document.getElementById(element);
		return element;
	}
}
function $v(element){
	return $(element).value;
}
function isString(a) {
    return typeof a === 'string';
}
function validDate(v)
{
	var regex = /^(\d{2})\-(\d{2})\-(\d{4})$/;
	if(!regex.test(v)) return false;
	var d = new Date(v.replace(regex, '$2/$1/$3'));
	return s=( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
				(parseInt(RegExp.$1, 10) == d.getDate()) && 
				(parseInt(RegExp.$3, 10) == d.getFullYear() );
}
function removeElement(rmvelm)
{
	var y=0;
	
	if(typeof rmvelm != 'object'){
		if($(rmvelm)){
		rmvelm = $(rmvelm);
		y=1;
		}
	}
	
	if(typeof rmvelm == 'object'){
		y=1;
	}
	if(y>0){
 	var parent = rmvelm.parentNode;
  	parent.removeChild(rmvelm);
	}
}
function insertAfter(newElement,targetElement)
{
	if(typeof newElement != 'object'){
		newElement = $(newElement); 	
	}
	if(typeof targetElement != 'object'){
		targetElement = $(targetElement); 	
	}
	
	var parent = targetElement.parentNode;
	//if the parents lastchild is the targetElement...
	
	if(parent.lastchild == targetElement) 
	{
		//add the newElement after the target element.
		parent.appendChild(newElement);
	}
	else
	{
		// else the target has siblings, insert the new element between the target and it's next sibling.
		parent.insertBefore(newElement, targetElement.nextSibling);
	}
	
}

function addElement(obj,txtmsg)
{
	//alert(obj);
	var space = "";
	var targetElement = $(obj);
	var newdiv = document.createElement('div');
	var newdiv_id = newdiv.tagName.toLowerCase()+obj;
	
	newdiv.setAttribute('id', newdiv_id);

	if(this.brs.Browser.IE){
		if(brsVersion()<=7){
			newdiv.setAttribute('className', 'validation-advice');
		}
		else{
			newdiv.setAttribute('class', 'validation-advice');
		}
	}
	else{
		newdiv.setAttribute('class', 'validation-advice');
	}
	
	newdiv.innerHTML =space+space+txtmsg;
	
    
	if(!$(newdiv_id))
	insertAfter(newdiv, targetElement);
	
	return newdiv_id;
}
function addClass(obj, classval){
	var obj = obj;
	if(typeof obj != 'object'){
		if($(obj))
		obj = $(obj);
	}
	
	if(this.brs.Browser.IE){
		if(brsVersion()<=7){
			obj.setAttribute('className', classval);
		}
		else{
			obj.setAttribute('class', classval);
		}
	}
	else{
		obj.setAttribute('class', classval);
	}
	
}
function setClass(obj, classval){
	var obj = obj;
	if(typeof obj != 'object'){
		if($(obj))
		obj = $(obj);
	}
	
	if(this.brs.Browser.IE){
		if(brsVersion()<=7){
			obj.setAttribute('className', classval);
		}
		else{
			obj.setAttribute('class', classval);
		}
	}
	else{
		obj.setAttribute('class', classval);
	}
}
function setAtt(obj, atttype, attval){
	var obj = obj;
	if(typeof obj != 'object'){
		if($(obj))
		obj = $(obj);
	}
	
	var getatt = obj.getAttribute(atttype);
	obj.setAttribute(atttype, attval, getatt);
}
function setText(obj, txtmsg, cssClass)
{
	if($(obj)){
		var obj = $(obj);
		obj.innerHTML = txtmsg;
		if(this.brs.Browser.IE){
			if(brsVersion()<=7){
				obj.setAttribute('className', cssClass);
			}
			else{
				obj.setAttribute('class', cssClass);		
			}
		}
		else{
			obj.setAttribute('class', cssClass);
		}
	}
}

function c()
{
	var objhead = document.getElementsByTagName('head');
	var style = document.createElement('style');
	insertAfter(style, objhead);
}

function chkLogin(txtuname, txtpwd){
	var rev = false;
	if($(txtuname) && $(txtpwd)){
		if(!IsEmpty(txtuname) && !IsEmpty(txtpwd)){rev=true;}
		else{
			var fid = (IsEmpty(txtuname))? txtuname : txtpwd;
			var fidlabel = (IsEmpty(txtuname))? "User Name" : "Password";
			showMsgFocus(fid,  fidlabel+' should not be empty !');
		}
	}
	return rev;
}

function logOut(){
	var url = 'sys-action.php?signout'
	window.location.href  = url;
}
function redirect(url){
	
	window.location  = url;
}
function formSubmit(frm, url){
	var form = document.forms[frm];
	
	if(typeof form == 'object'){
		var y = false;
		if(url=='undefined'){url=""; y=true;}
		else{
			
			var df = url.indexOf('delete')
			var ef = url.indexOf('edit')
			if((df>0) || (ef>0)){
				
				var ceo = checkElement("radio",frm);
				var cec = checkElement("checkbox",frm);
				if(ceo==true){
					
					var cv = confirm("Do you really want this action ");
					if(cv==true){y=true;}
					else{y=false;}
				}
				else if(cec==true){
					
					
					if(ef>0){
						var cchecked = countcheck("checkbox",frm);
						if(cchecked > 1){
							alert("Select one record at a time to edit.");	
						}
						else{
							var cv = confirm("Do you really want this action ");
							if(cv==true){y=true;}
							else{y=false;}
						}
					}
					else{
						var cv = confirm("Do you really want this action ");
						if(cv==true){y=true;}
						else{y=false;}
					}
					
				}
				else{
					alert("No records are selected \n please select one.");
				}
			}
			else{y=true;}
		}
		
		if(y==true){
			var actionurl = form.getAttribute('action');
			form.action = url;
			//alert(actionurl +':'+actionurl.length);
			if(url === "" && actionurl.length > 6){
				form.action = actionurl;
			}
			
			disf = form.id.indexOf('dis'); 
			//alert(disf);
			if(disf<=0){
				if(validate(form)){
					form.submit();
				}
			}else{
				form.submit();
			}
		}
	}
}

function checkOrderDelboy(frm){
	var ckd = checkElement("checkbox",frm);
	if(ckd==true){
		var form = document.forms[frm];	
		form.action ="action.php";
		form.submit();
	}
	else{alert("No records are selected \n please select one.");return false;}
}
function countcheck(eleType,frm){
	var formName=frm;
	var j=0;
	if(typeof formName == 'object'){
		formName = formName.name;; 	
	}
	var formlength = document.forms[formName].elements.length;
	var y=false;
	for(var i=0; i<formlength; i++)
	{
		var obj = document.forms[formName].elements[i];//document.frmoder.elements[i];
		if(obj.id)
		if(obj.type==eleType)
		{
			var id = obj.id;
			if($(id).checked){
				y=true;
				j++;
				
			}
			else{y=false;}
			
		}
	}
	return j;
}
function checkElement(eleType,frm){
	var formName=frm;
	if(typeof formName == 'object'){
		formName = formName.name;; 	
	}
	var formlength = document.forms[formName].elements.length;
	var y=false;
	for(var i=0; i<formlength; i++)
	{
		var obj = document.forms[formName].elements[i];//document.frmoder.elements[i];
		if(obj.id)
		if(obj.type==eleType)
		{
			var id = obj.id;
			if($(id).checked){
				y=true;
				break;
			}
			else{y=false;}
			
		}
	}
	return y;
}
//select all check boxes on given name
function selectAll(obj, rch){
	var obj = obj
	var spnchkall = 'spnchkall';
	if(typeof obj != 'object'){
		if($(obj))
		obj = $(obj);
	}
	var rchk = 	rch;
	var rchk_a = document.getElementsByName(rchk);
	var rchkl = rchk_a.length;
	//alert(rchkl);
	if(obj.checked !== false){
		obj.setAttribute('alt','Unselect All');
		obj.setAttribute('title','Unselect All');
		if($(spnchkall)){$(spnchkall).innerHTML = "Unselect All";}
		for(var i=0; i < rchkl; i++){
			rchk_a.item(i).checked = true;	
		}
	}
	else{
		obj.setAttribute('alt','Select All');
		obj.setAttribute('title','Select All');
		if($(spnchkall)){$(spnchkall).innerHTML = "Select All";}
		for(var i=0; i < rchkl; i++){
			rchk_a.item(i).checked = false;	
		}	
	}
	
}

function setProdCode(txtid, selid){
	var txtid = txtid;
	if(typeof txtid == 'object'){
		txtid = txtid.id;
	}
	var selid = selid;
	if(typeof selid == 'object'){
		selid = selid.id;	
	}
	
	var index = $(selid).selectedIndex;
	var selvalue = $(selid).options[index].text;
	var tblname = "products";
	var colname = "prod_code";
	var suffix = "-";
	var genlen = 3;
	if(selvalue!=''){
		var url ='ied.php?gencode='+selvalue+'&tblname='+tblname+'&colname='+colname+'&suffix='+suffix+'&genlen='+genlen;
		//alert(url);
		new Ajax.Request(url,
		{
			method:'get',
			onSuccess: function(transport){
			var response = transport.responseText || "no response text";
			//alert(response);
			var prodcode ='';
			var str = response.split("-");
			if(str.length>1){
				prodcode = response;
				$(txtid).value=prodcode;
			}
			else{
				//$(txtid).value=str;
				
				//alert('Something went wrong...Hello');
			}
			
		},
		onFailure: function(){ alert('Something went wrong...'); }
		});
		
	}
	else{
		alert("Please select a category \n for generating the Product Code");	
	}
	
	
	
}
function showMsgFocus(obj, msg){
	alert(msg);
	$(obj).focus();
}
function errorBorder(obj){
	$(obj).style.border='1px solid #F49A9A';
}
function removeErrorBorder(obj){
	$(obj).style.border='1px solid #999999';	
}
function redirectUsingVal(url, id){

	var surl='';
	var rev = false;
	
	if(typeof id === 'object'){
		id = id.id;
	}
	
	if($(id).type=="text"){
		if(!IsEmpty(id)){
			surl = url+$v(id);
			rev = true;
		}
	}
	else{
		var index = $(id).selectedIndex;
		var selvalue = $(id).options[index].value;
		surl= url+selvalue; 
		rev=true;
	}
	if(rev==true){
		redirect(surl);
	}
}
/* this addAttByClassName function add attribute by class name 
by taking 3 arguments{classname, attribute type and attribute value}*/
function addAttByClassName(className, attType, attValue){
	var numOfForms = document.forms.length;
	var nfelm=0;
	//alert('Number of form: '+numOfForms);
	
	
	for(f=0; f<numOfForms; f++){
		nfelm = document.forms[f].elements.length;
		nf = f+1;
		//alert('Number of element in the form no. '+nf+' is: '+nfelm);	
		for(i=0;i<nfelm; i++){
			var obj = document.forms[f].elements[i];
			if(obj.id)
			var id = obj.id;
			var hsc = $HC(id, className);
			if(hsc){
				//alert('class '+className+' position is: '+i);
				setAtt(id, attType, attValue);
				
			}
		}
	}

}
function addFunToElement(){
	var numarr = $EBC("numbers");
	var decarr = $EBC("decimals");
	var phonearr = $EBC("phone");
	if(phonearr.length>0){
		addAttByClassName("phone", "onkeypress", "return phone(this, event);");
		addAttByClassName("phone", "onblur", "return chkPhone(this);");
	}
	if(numarr.length>0){
		addAttByClassName("numbers", "onkeypress", "return numbersonly(this, event);");
	}
	if(decarr.length>0){
		addAttByClassName("decimals", "onkeypress", "return decimalNumber(this, event);");
	}
}
function addNumCheckToElement(){
	
	addAttByClassName("numbers", "onkeypress", "return numbersonly(this, event);");
}
function disInPos(obj){
	if(typeof obj != 'object'){
		obj =  $(obj);
	}
	
	var val = obj.value;
	var elmId = 'txtname'+val;
	
	if($(elmId))
	$(elmId).style.display='inline';
	setAtt(elmId, "onkeypress", "return numbersonly(this, event);");
	
	var objasdf = $EC('prodpos');
	
	var elemlen = objasdf.length;
	for(i=0; i<elemlen;i++){
		var emId = objasdf[i].id;
		if(emId!=elmId){
			$(emId).style.display='none';
		}
	}
}


function disProdEle(obj){
	
	var id = obj.id;
	var arr = id.split("_");
	var prodid = arr[1];
	
	var radioId ='rdo'+prodid;
	if($(radioId)){
		//alert(radioId);
		$(radioId).checked="checked";
	}
	var divid ='divposin_'+prodid;
	var btnid = 'btnsetpos'+prodid;
	var txtid = 'txtprodpos_'+prodid;
	if($(divid)){
		$(divid).style.visibility="visible";
		
		if($(txtid)){
			$(txtid).style.display='inline';
			setAtt(txtid, "onkeypress", "return numbersonly(this, event);");
		}
		if($(btnid)){
			$(btnid).style.display='inline';
		}
	}
	var objarr = $EC('divprodpos');
	var chkele = document.getElementsByName('rdo[]');
	
	var elemlen = objarr.length;
	for(i=0; i<elemlen;i++){
		var emId = objarr[i].id;
		
		if(emId!=divid){
			$(chkele.item(i).id).checked = false;
			$(emId).style.visibility='hidden';
			var arrele = emId.split("_");
			var proId = arrele[1];
			if($('txtprodpos_'+proId))$('txtprodpos_'+proId).style.display='none';
			if($('btnsetpos'+proId))$('btnsetpos'+proId).style.display='none';
		}
	}
	
}
function dis_cpc_cpp(selid){
	chkProdPos(selid);
	discpc(selid);
}
function fillsel(selid, fillselid, oselvalue, tblname, dcol, wcol,selidvalue){
	var selid = selid;
	
	if(typeof selid == 'object'){
		if(selid)
		selid = selid.id;
	}
	if($(selid)){
		var index = $(selid).selectedIndex;
		var selvalue = $(selid).options[index].value;
		//alert(selvalue);
		if(selvalue === '0'){
			selvalue = selidvalue;
		}
		if(selvalue!=''){
			var url ='ied.php?fillsel='+selvalue+'&tblname='+tblname+'&dcol='+dcol+'&wcol='+wcol;
			//alert(url);
			new Ajax.Request(url,
			{
				method:'get',
				onSuccess: function(transport){
				var response = transport.responseText || "no response text";
				//alert(response);
				var cy;//cy: checkcomma
				var ny; //ny: check ^
				cy = response.indexOf('~');
				ny = response.indexOf('^');
				var posarr;
				
				var selmneupos = document.getElementById(fillselid);
				if(cy !== -1 || ny !== -1){
					posarr = response.split("~");
					//alert(posarr.length);
					
					selmneupos.options.length = 0;
					selmneupos.options[0] = new  Option('Select One', 0);
				
					for(var i=0;i<posarr.length;i++){
						var s = posarr[i];
						if(s.indexOf('^') !== -1){
							var sa = s.split("^");
							var vl = sa[0];
							var tx = sa[1];
							selmneupos.options[i+1] = new  Option(tx, vl);	
						}
						else{
							selmneupos.options[i+1] = new  Option(posarr[i], i+1);	
						}
					}
					if(oselvalue){
						selmneupos.value=oselvalue;
					}
				}
				else{
					selmneupos.options.length = 0;
					selmneupos.options[0] = new  Option('Select One', 0);	
				}
				
				
			},
			onFailure: function(){ alert('Something went wrong...'); }
			});
			
		}
	}
}
/*******************************************************************************************/
function fillsub(cat, divid, fillingtype)
{
	
	//var cat =document.getElementById(cat).value;
	var index =document.getElementById(cat).selectedIndex;
		
	if(fillingtype == 'select')
	{
		cat= document.getElementById(cat).options[index].text;
	}
	else
	{
		cat=document.getElementById(cat).options[index].value;
	}
	
		//alert('ehlo'+cat);
		if(cat == 'Select Categories'){}
		else{
		var durl ='ied.php?fillsubcat='+cat+'&divid='+divid+'&fillingtype='+fillingtype;
			new Ajax.Updater(divid, durl, { method: 'get' });
			//alert(durl);
		}
		
}
/***************************************************************************************************/
function chkProdPos(selid){
	var selid = selid;
	
	if(typeof selid != 'object'){
		if($(selid))
		selid = $(selid);
	}
	
	var index = $(selid).selectedIndex;
	var selvalue = $(selid).options[index].value;
	
		if(selvalue!=''){
		var url ='ied.php?chkProdPos&cat_id='+selvalue;
		//alert(url);
		new Ajax.Request(url,
		{
			method:'get',
			onSuccess: function(transport){
			var response = transport.responseText || "no response text";
			//alert(response);
			
			var prodpos = 0;
			prodpos = trim(response);
			if(chkNumber(prodpos)){
				
				$('divchkprodpos').innerHTML='(Please enter 1 to '+prodpos+' in the Textbox)';
			}
			else{
				//$(txtid).value=str;
				
				//alert('Something went wrong...Hello');
			}
			
		},
		onFailure: function(){ alert('Something went wrong...'); }
		});
		
	}
		
}
function setTXT(obj,text){
	if($(obj)){
		$(obj).value = text;	
	}
}
function setSTT(selid, txtid, tv){
	
	var index = $(selid).selectedIndex;
	var selvalue ='';
	if(tv=='text'){
		selvalue = $(selid).options[index].text;
	}
	else{
		selvalue = $(selid).options[index].value;
	}
	//alert(selvalue);
	if($(txtid))$(txtid).value=selvalue;
	
}

function getText(id){
	return $(id).value;	
}


function addMoreField(txtid, divclass){
	var space = "";
	var divelem = $EBC(divclass);
	alert(divelem.length);
	/*var targetElement = $(obj);
	var newdiv = document.createElement('div');
	var newdiv_id = newdiv.tagName.toLowerCase()+obj;
	
	newdiv.setAttribute('id', newdiv_id);

	if(this.brs.Browser.IE){
		if(brsVersion()<=7){
			newdiv.setAttribute('className', 'validation-advice');
		}
		else{
			newdiv.setAttribute('class', 'validation-advice');
		}
	}
	else{
		newdiv.setAttribute('class', 'validation-advice');
	}
	
	newdiv.innerHTML =space+space+txtmsg;
	
    
	if(!$(newdiv_id))
	insertAfter(newdiv, targetElement);
	
	return newdiv_id;*/
}

function divshow(divid,divin, divins){
	// this function takes div id and the id initial
	var divs = document.getElementsByTagName('div');
	var divlen = divs.length;
	if($(divid)){
		$(divid).style.display ='block';
		$(divins).style.display ='block';
		for(var i=0; i<divlen ; i++){
			var divid1 = divs.item(i).id;
			var index = divid1.indexOf(divin);
			if(divid1 != divid && index != -1){
				$(divid1).style.display = 'none';	
			}
		}
	}
	else{
		$(divins).style.display ='none';
		for(var i=0; i<divlen ; i++){
			var divid1 = divs.item(i).id;
			var index = divid1.indexOf(divin);
			if(index != -1){
				$(divid1).style.display = 'none';	
			}
		}	
	}

}

function elem2show(obj1, obj2){
	$(obj1).style.display ='block';
	$(obj2).style.display = 'none';	
}
function chpwd(id1, id2, id3, id4){
	var obj1 = $(id1);
	var obj2 = $(id2);
	if(obj1.style.display == 'none'){
		obj1.style.display ='block';
		//obj2.style.display ='none';
		obj2.innerHTML = "<a href=\"javascript: chpwd('divchpwd','spnchpwd','txtpwd','txtpwd1');\">I don't want to change the password</a><br />";
		$(id3).disabled=false;
		setAtt(id3, 'class', 'inputbox passcom');
		$(id4).disabled=false;
		setAtt(id4, 'class', 'inputbox passcom');
		
		if(this.brs.Browser.IE){
			if(brsVersion()<=7){
				setAtt(id3, 'className', 'inputbox passcom');
				setAtt(id4, 'className', 'inputbox passcom');
			}
		}
		
	}
	else{
		obj1.style.display ='none';
		//obj2.style.display ='none';
		obj2.innerHTML = "<a href=\"javascript: chpwd('divchpwd','spnchpwd','txtpwd','txtpwd1');\">Change Password</a>";
		setAtt(id3, 'class', 'inputbox not-required');
		setAtt(id4, 'class', 'inputbox not-required');	
		$(id3).disabled=true;
		$(id4).disabled=true;
		if(this.brs.Browser.IE){
			if(brsVersion()<=7){
				setAtt(id3, 'className', 'inputbox passcom');
				setAtt(id4, 'className', 'inputbox passcom');
			}
		}
	}
	
}
function disField(selid,selval,disf){
	var index = $(selid).selectedIndex;	
	var selvalue = $(selid).options[index].value;
	var seltext = $(selid).options[index].text;
	if(selval == selvalue){
		
		$(disf).style.visibility= 'visible';
	}
	else{
		$(disf).style.visibility= 'hidden';
		$(disf).value = seltext;
	}
}

function editdelete(id, tblname, edit){

		
		var txtcat='txtproperty';
		var txtid='txtid';
		var btn ='btns';
		var divid ='divcan';
		var url ='ied.php?id='+id+'&tblname='+tblname+'&edit='+edit;
		var btntext='Update';
		//alert(url);
		new Ajax.Request(url,
		{
		method:'get',
		onSuccess: function(transport){
		var response = transport.responseText || "no response text";
		//alert(response);
		var str = response.split("~");
		var id = str[0];
		var txt =str[1];
		document.getElementById('canhid').value=0;
		
		if(tblname === 'city'){
			txtcat = 'txtcity';
			btn = 'btncity';
			document.getElementById('canhid').value=1;
		}
		if(tblname === 'banklist'){
			txtcat = 'txtbankname';	
		}
		document.getElementById(txtcat).value=txt;
		document.getElementById(txtid).value=id;
		document.getElementById(btn).value=btntext;
		document.getElementById(divid).style.display='block';
		
		//alert("Success! \n\n" + response);
		},
		onFailure: function(){ alert('Something went wrong...') }
		});

		//new Ajax.Updater('divcat', 'ied.php?id='+id+'&msg='+type+'&edit='+edit, { method: 'get' });
	
}
function ins(cat, tblname)
	{
		//alert('Hello');
		
		
		//var surl= document.getElementById('surl').value;
		var btnid= 'btns';
		var na=document.getElementById(cat).value;
		var divid='divcat';
		var txtid='txtid';
		if(tblname=='properties')
		{	
			var index =document.getElementById('selpropertytype').selectedIndex;
			var cate = document.getElementById('selpropertytype').options[index].value;
			na = na+'&cat='+cate;
			btnid ='btnsp';
			divid ='divprty';
			txtid='txtid1';
		}
		if(tblname=='city')
		{	
			btnid ='btncity';
			divid ='divcity';
			
		}
		
		var bt = document.getElementById(btnid).value;
		
		if(bt == 'Create')
		{
			bt='insert';
			//canc();
		}
		if(bt == 'Update')
		{
			var id = document.getElementById(txtid).value;
			//alert(id);
			bt='update&id='+id;
			canc();
			
		}
		var insurl = 'ied.php?name='+na+'&tblname='+tblname+'&ins='+bt+'&divid='+divid;
		//alert(insurl);
		//alert('hello'+ cat)
		new Ajax.Updater(divid, insurl, { method: 'get' });
	}
	function del(id, tblname)
	{
		var delurl='ied.php?id='+id+'&ins=del'+'&tblname='+tblname;
		var divid='divcat';
		if(tblname=='properties')
		{
			divid='divprty';
			//var cate = document.getElementById('cat').value;
			//delurl='ied.php?id='+id+'&ins=del'+'&tblname='+tblname+'&cat='+cate;
		}
		if(tblname=='rightsidebanners')
		{
			divid='divrightban';
			//var cate = document.getElementById('cat').value;
			//delurl='ied.php?id='+id+'&ins=del'+'&tblname='+tblname+'&cat='+cate;
		}
		else if(tblname=='city'){
			divid = 'divcity';	
		}
		
		//alert(delurl);
		new Ajax.Updater(divid, delurl, { method: 'get' });
	}
function canc()
{
	
	
	var canhid = document.getElementById('canhid').value;
	//alert(canhid);
	if(canhid==0)
	{
		document.getElementById('btns').value='Create';
		document.getElementById('txtid').value='';
		if($('txtproperty')){$('txtproperty').value='';}
		if($('txtbankname')){$('txtbankname').value='';}
		//document.getElementById('txtproperty').value='';
		document.getElementById('divcan').style.display='none';
	}
	else if(canhid==1)
	{
		document.getElementById('btncity').value='Create';
		document.getElementById('txtid').value='';
		document.getElementById('txtcity').value='';
		document.getElementById('divcan').style.display='none';
	}
}
function editProperties(id)
{
		
		var txtcat='selpropertytype';
		var txtid='txtid';
		var btn ='btnproReg';
		var divid ='divcan';
		var url ='ied.php?id='+id+'&editProperties';
		var btntext='Update';
		//alert(url);
		new Ajax.Request(url,
		{
		method:'get',
		onSuccess: function(transport){
		var response = transport.responseText || "no response text";
		//alert(response);
		var str = response.split("~");
		var id = str[0];
		var txt =str[1];
		//alert(txt);
		document.getElementById('canhid').value=0;
		document.getElementById(txtcat).value=txt;
		document.getElementById(txtid).value=id;
		document.getElementById('txtpropertyname').value=str[2];
		document.getElementById('selprolocation').value=str[3];
		document.getElementById('txtstreetaddress').value=str[4];
		document.getElementById('txtbudget').value=str[5];
		document.getElementById('txtventurehightlight').value=str[8];
		document.getElementById('txtdescriptions').value=str[6];
		document.getElementById('txtfoundation').value=str[11];
		
		document.getElementById('txtwalls').value=str[12];
		document.getElementById('txtplastering').value=str[13];
		document.getElementById('txtdoors').value=str[14];
		
		document.getElementById('txtwindows').value=str[15];
		document.getElementById('txtflooring').value=str[16];
		document.getElementById('txtkitchenfeatures').value=str[17];
		
		document.getElementById('txtbathrooms').value=str[18];
		document.getElementById('txtelectricalfeatures').value=str[19];
		document.getElementById('txtsecurity').value=str[20];
		
		document.getElementById('txtlifts').value=str[21];
		document.getElementById('txtgarden').value=str[22];
		document.getElementById('txtgenerator').value=str[23];
		
		document.getElementById('txtwatersupply').value=str[24];
		document.getElementById('txtutilities').value=str[25];
		document.getElementById('txtextrafeatures').value=str[26];
		
		document.getElementById('txtinternalroad').value=str[27];
		document.getElementById('txtnotes').value=str[28];
		document.getElementById('txtamenities').value=str[10];
		
		document.getElementById('hidrootmap').value=str[29];
		document.getElementById('hidtypicalplan').value=str[30];
		document.getElementById('hidpropertyimage').value=str[9];
		document.getElementById('hidprtylogo').value=str[31];
		
		if($(btn)){
			document.getElementById(btn).value=btntext;	
		}
		if($(divid)){
			document.getElementById(divid).style.display='block';	
		}
		
		fn_bedroom();
		var prtVal = document.getElementById('selpropertytype').options[document.getElementById('selpropertytype').selectedIndex].text;
		var buildup_area = trim(str[7]);
		
		//alert(buildup_area);
		if(prtVal === 'Flat / Apartment' || prtVal === 'Farm House' || prtVal === 'Individual House'){
			var ba_arr = buildup_area.split('<br />');
			var ba_arr_len = ba_arr.length;
			//alert(ba_arr_len);
			document.getElementById('selavailableproperty').value = ba_arr_len-1;
			fncreate('selavailableproperty');
			var a_ba_arr_len = ba_arr_len -1;
			for(var i=0; i < a_ba_arr_len; i++){
				
				var flatid = 'txtflno'+(i+1);
				var bhkid = 'txtbhk'+(i+1);
				var baid = 'txtba'+(i+1);
				//alert(flatid);
				
				var ba_arr_arr = trim(ba_arr[i]);
				var ba_arr_arr = ba_arr_arr.split(',');
				
				var ba_flat_arr = trim(ba_arr_arr[0]);
				var ba_flat_arr = ba_flat_arr.split(' ');
				var ba_flat_No = ba_flat_arr[ba_flat_arr.length -1]; 
				document.getElementById(flatid).value = ba_flat_No;
				//alert(ba_flat_No);
				
				var ba_bhk_arr = trim(ba_arr_arr[1]);
				var ba_bhk_arr = ba_bhk_arr.split(' ');
				var ba_bhk_No = ba_bhk_arr[ba_bhk_arr.length -1];
				document.getElementById(bhkid).value = ba_bhk_No;
				//alert(ba_bhk_No);
				
				var ba_ba_arr = trim(ba_arr_arr[2]);
				var ba_ba_arr = ba_ba_arr.split(' ');
				var ba_ba_No = ba_ba_arr[0];
				document.getElementById(baid).value = ba_ba_No;
				//alert(ba_ba_No);
			}
			
			
			
		}
		else{
			var ba_arr = buildup_area.split(' ');
			document.getElementById('txtbuilduparea').value = trim(ba_arr[0]);
			document.getElementById('selbuilduparea').value = trim(ba_arr[1]);
		}
			//alert("Success! \n\n" + response);
		},
		onFailure: function(){ alert('Something went wrong...') }
		});

		//new Ajax.Updater('divcat', 'ied.php?id='+id+'&msg='+type+'&edit='+edit, { method: 'get' });
	}





function fn_populatlocality(id,selval){
	fn_fillSelectBox(id,selval);
}
function showOther(selid, txtid,tv){
	var id = selid;
	
	var index = $(id).selectedIndex;
	//alert(index);
	var seltext = $(id).options[index].text;
	var selvalue = $(id).options[index].value;
	//alert(seltext);
	if(seltext === "Other"){
		$('divprtylocother').style.display='block';
		$('txtprtylocother').style.display='block';
		var toobj = $('txtprtylocother');
		toobj.disabled=false;
		setClass(toobj, "inputbox required");	
	}
	else{
		$('divprtylocother').style.display='none';
		$('txtprtylocother').style.display='none';
		var toobj = $('txtprtylocother');
		toobj.disabled=true;
		setClass(toobj, "inputbox not-required");	
	}
	setSTT(selid, txtid,tv)
}
function fn_populatlocality1(id,selval){
	var index = $(id).selectedIndex;
	var seltext = $(id).options[index].text;
	var selvalue = $(id).options[index].value;
	if(selvalue === 'Other'){
		$('divprtyloc_loc').style.display='none';
		$('divprtylocother').style.display='block';
		$('txtprtylocother').style.display='block';
		var toobj = $('txtprtylocother');
		toobj.disabled=false;
		setClass(toobj, "inputbox required");
		document.getElementById('sellocality').disabled = true;
	}
	else{
		$('divprtyloc_loc').style.display='block';
		$('divprtylocother').style.display='none';
		$('txtprtylocother').style.display='none';
		var toobj = $('txtprtylocother');
		toobj.disabled=true;
		setClass(toobj, "inputbox not-required");
		document.getElementById('sellocality').disabled = false;
		
		fn_fillSelectBox(id,selval);
	}
}
function fn_fillSelectBox(id,selval){
	//alert('Hello '+selval);
	var index = $(id).selectedIndex;
	var seltext = $(id).options[index].text;
	var selvalue = $(id).options[index].value;
	var wcolval = selvalue;
	
	if(wcolval >0){
		
		pid = 'sellocality';
		tblname ='area';
		wcol = 'cityid';
		dcol = 'areaname';
		$('hidcity').value = seltext
		var url ='ied.php?fillsel='+wcolval+'&tblname='+tblname+'&wcol='+wcol+'&dcol='+dcol;
		new Ajax.Request(url,
		{
			method:'get',
			onSuccess: function(transport){
			var response = transport.responseText || "no response text";
			var selid = $(pid);
			var selidbool = false;
			var selidtext = '';
			if(selval !== 'undefined' && selval !== ''){
				selidbool = true;
			}
			
			if(response.indexOf("~") !== -1)
			var str = response.split("~");
			//alert(str);
			selid.options.length=0;
			selid.options[selid.options.length] = new Option('Select Locality', 0);	
			for(var i=0; i< str.length; i++){
				var s_a = str[i];
				var s_a_arr = s_a.split("^");
				var s_a_v = s_a_arr[0];
				var s_a_t = s_a_arr[1];
				selid.options[selid.options.length] = new Option(s_a_t, s_a_v);	
				if(selidbool !== false){
					if(s_a_v === selval){
						selidtext = s_a_t;	
					}	
				}
			}
			if(selidbool !== false){
				selid.value=selval;
				$('hidlocality').value = selidtext;
			}
		},
		onFailure: function(){ alert('Something went wrong...') }
		});
	}
}








function fn_fillSelectBox123(id,selval){
	
	var index = $(id).selectedIndex;
	var seltext = $(id).options[index].text;
	var selvalue = $(id).options[index].value;
	var wcolval = selvalue;
	
	pid = 'sellocality';
	tblname ='area';
	wcol = 'cityid';
	dcol = 'areaname';
	$('hidcity').value = seltext
	var url ='ied.php?fillsel='+wcolval+'&tblname='+tblname+'&wcol='+wcol+'&dcol='+dcol;
	new Ajax.Request(url,
	{
		method:'get',
		onSuccess: function(transport){
		var response = transport.responseText || "no response text";
		var selid = $(pid);
		
		if(response.indexOf("~") !== -1)
		var str = response.split("~");
		
		selid.options.length=0;
		selid.options[selid.options.length] = new Option('Select Locality', 0);	
		for(var i=0; i< str.length; i++){
			var s_a = str[i];
			var s_a_arr = s_a.split(",");
			if(s_a_arr[0] !== ''){
				var s_a_v = s_a_arr[0];
				var s_a_t = s_a_arr[1];
				selid.options[selid.options.length] = new Option(s_a_t, s_a_v);	
			}
        }
		document.getElementById(pid).value=selval;
		
		var index1 = $(pid).selectedIndex;
		var seltext1 = $(pid).options[index1].text;
		$('hidlocality').value = seltext1
		//selid.value=selval;
	},
	onFailure: function(){ alert('Something went wrong...') }
	});
}
function chkdivshow(divid1,divid2,chkid){
	var chkobj = chkid;
	if(typeof chkobj != 'object'){
		if($(chkobj))
		chkobj = $(chkobj);
	}
	if(chkobj.checked !== false){
		if(chkobj.id === 'rdoyes'){
			mlbValidate(true);
		}
		else{
			mlbValidate(false);	
		}
		document.getElementById(divid1).style.display ='block';
		document.getElementById(divid2).style.display ='none';
	}
	else{
		document.getElementById(divid1).style.display ='none';
		document.getElementById(divid2).style.display ='none';	
	}
}
function resetText1(obj, oval){
	var tval = obj.value;
	//alert(tval);
	if(tval === oval){
		obj.value = '';
	}
	obj.focus();
}
function fillText1(obj, oval){
	var tval = obj.value;
	if(tval === ''){
		obj.value = oval;	
	}
}

/*************validation for myListBox Control********************************
********************sof********************************************************/
function chkMLB(){
	var conname = 'myListBox[]';
	var objlists = document.getElementsByName(conname);
	var objlistlen = objlists.length;
	var chky = false;
	var mylbDiv = document.getElementById('divmyListBox');
	
	for(var i=1; i <= objlistlen; i++){
		var chkid = 'chkopt'+i;	
		var chkobj = document.getElementById(chkid);
		if(chkobj.checked !== false){
			chky = true;
			break;	
		}
	}
	if(chky !== false){
		removeElement('div'+mylbDiv.id);
		removeErrorBorder(mylbDiv.id);
		return true;	
	}
	else{
		alert("Please select one bank atleast");
		mylbDiv.style.border='1px solid #F49A9A';
		errorBorder(mylbDiv.id);
		addElement(mylbDiv.id, ' Required');
	}
	return false;
}

/*************eof*************************************************************
**************validation for myListBox Control********************************/





function propertyVal(obj){
	var vldate = false;
	vldate = validate(obj);
	var rdoyes = $('rdoyes');
	var mlbvldate = true;
	if(rdoyes.checked !== false){
		mlbvldate = chkMLB();
	}
	if(mlbvldate !== false && vldate !== false){
		return true;	
	}
	return false;
}

function showprtyloc(obj,h){
	var obj = obj;
	if(typeof obj != 'object'){
		if($(obj))
		obj = $(obj);
	}
	var pfid = obj.id;
	var selobj = $(pfid);
	var index = selobj.selectedIndex;
	var selvalue = selobj.options[index].value;
	
	var citysel = $('selcity');
	if($('sellocality')){
		var locsel = $('sellocality');
	}
	
	if(selvalue === "Business Loan" || selvalue === "Personal Loan" || selvalue === "Property not selected - Need loan Eligibility"){
		
		citysel.disabled=true;
		setClass(citysel,"selectbox not-required");
		if($('sellocality')){
			locsel.disabled=true;
			setClass(locsel,"selectbox not-required");
		}
		
		if($('divprtyloc')){
			$('divprtyloc').style.display='none';
		}
		if($('divprtylocf')){
			$('divprtylocf').style.display='none';
		}
		if($('divprtylocc')){
			$('divprtylocc').style.display='none';
		}
	}
	else{
		
		citysel.disabled=false;
		setClass(citysel,"selectbox");
		if(h === "home"){
			setClass(citysel,"text-drop-box");
		}
		
		if($('sellocality')){
			locsel.disabled=false;
			setClass(locsel,"selectbox");
		}
		if($('divprtyloc')){
			$('divprtyloc').style.display='block';
		}
		if($('divprtylocf')){
			$('divprtylocf').style.display='block';
		}
		if($('divprtylocc')){
			$('divprtylocc').style.display='block';
		}
	}
}


function showprtyimg(obj,imgval){
	var obj = obj;
	//alert(imgval);
	if(typeof obj != 'object'){
		if($(obj))
		obj = $(obj);
	}
	obj.src='../images/img/'+imgval;
}

function clearSel(){
	var args = arguments;
	var argslen = args.length;
	for(var i=0; i < argslen;  i++){
		var selid = args[i];
		if(selid !== " " && selid.length > 0){
			if(typeof selid !== 'object'){
				if($(selid)){
					selid = $(selid); 		
				}	
			}
			if(selid.tagName.toLowerCase()==="select"){
				selid.options.length = 0;
				selid.options[0] = new  Option('Select One', 0);
			}
		}
	}
}

function scrollbar(){
	var divovflo = document.getElementsByClassName('overflow');
	var divovflolen = divovflo.length;
	for(var i=0; i < divovflolen; i++){
		var doflobj = divovflo[i];	
		var divheight = doflobj.offsetHeight;
		var dofloheight = 320;// after this height scroll bar is comming.
		
		var divoflStyle = document.getCssValue('.overflow');
		if(divoflStyle){if(divoflStyle.height){dofloheight = divoflStyle.height;}}
		
		
		
		dofloheight = parseInt(dofloheight);
		
		if(divheight > dofloheight){
			doflobj.style.height = dofloheight+'px';	
		}
	}
}

function a_clickfalse(){
	var acf = $ECN('camnuy');
	var acf_len = acf.length;
	//alert(acf_len);
	for(var i=0; i < acf_len; i++){
		var a = acf[i];
		a.onclick = function(){return false;};
		
	}
	return false;
}

function formSubmitA(){
	var sb_btn = $ECN('sb');
	var sb_len = sb_btn.length;
	
	var clr_btn = $ECN('clr');
	var clr_len = clr_btn.length;
	for(var i=0; i < sb_len; i++){
		var sbbtn = sb_btn[i];
		sbbtn.onmouseover = function(){
			this.href = window.location;	
		}
		sbbtn.onclick =	function(){
			this.href ="javascript: void(0);";
			
			var rev = true;
			var elemobj = this;
			var frmobj;
			while(rev !== false){
				var pobj = elemobj.parentNode;
				elemobj = pobj;
				var tagname = pobj.tagName.toLowerCase();
				if(tagname === "form"){
					rev = false;
					frmobj = pobj;
				}	
			}
			if(typeof frmobj == 'object'){
				if(validate(frmobj)){
					frmobj.submit();
				}
			}
		}
	}
	for(var i=0; i < clr_len; i++){
		var clrbtn = clr_btn[i];
		clrbtn.onmouseover = function(){
			this.href = window.location;	
		}
		clrbtn.onclick =	function(){
			this.href ="javascript: void(0);";
			
			var rev = true;
			var elemobj = this;
			var frmobj;
			while(rev !== false){
				var pobj = elemobj.parentNode;
				elemobj = pobj;
				var tagname = pobj.tagName.toLowerCase();
				if(tagname === "form"){
					rev = false;
					frmobj = pobj;
				}	
			}
			if(typeof frmobj == 'object'){
				frmobj.reset(); 
			}
		}
	}		
}

function getHref(obj){
	//var obj = document.getElementById('mntm');
	//alert(obj.innerHTML);
	var shref = obj.getAttribute('href');
	var souterhtml = outerHTML(obj);
	//alert(shref);
	//alert(souterhtml);
	souterhtml = souterhtml.toLowerCase()
	souterhtml = trim(souterhtml);
	//alert(souterhtml);
	var hf = "href="
	var ind_href = souterhtml.indexOf(hf);
	
	//alert(ind_href);
	var s_a_h_ind = ind_href+hf.length;
	var s_a_h ="";
	var ea = "<a href=></a>"
	
	var cl = souterhtml.length - ea.length;
	
	//alert(souterhtml.length+ ' :len: '+cl);
	for(var i=0; i < cl; i++){
		var s='';
		s = souterhtml.substr(s_a_h_ind+i, 1);
		
		s_a_h += s;
		//alert('position '+i+' : '+s_a_h);
		if(i >0 && s === '"'){break;}
	}
	//alert('href value: '+s_a_h);
	var s_o_href = str_replace1('"','',s_a_h);
	//alert('original href value: '+s_o_href+' its len: '+s_o_href.length);
	s_o_href = trim(s_o_href);
	if(s_o_href.length === 0){s_o_href = null;}
	return s_o_href;
}

function chngHashTojavascriptNull(){
	var atag_arr = document.getElementsByTagName('a');
	var ataglen = atag_arr.length;
	//alert(ataglen);
	
	for(var i=0; i < ataglen; i++){
		var ataghref = '';
		//ataghref = atag_arr[i].getAttribute('href');
		ataghref = getHref(atag_arr[i]);
		//alert(ataghref);
		//if(!ataghref){alert('Hello');}
			if (ataghref === "#" || ataghref === "" || ataghref === null) {
			//	alert(i+':hello only #: '+ataghref);
				var reltop = atag_arr[i].getAttribute('rel');
				atag_arr[i].href="javascript: void(0);";
				if(reltop === 'top'){atag_arr[i].href="#";}
			}
			atag_arr[i].onmousedown = function() { 
				
				this.blur();                 // most browsers 
				this.hideFocus = true;       // internet explorer
				if(brs.Browser.IE === false){
					this.style.outline = 'none'; // mozilla
				}
				return false;
			}   
			atag_arr[i].onmouseout = atag_arr[i].onmouseup = function() { 
				this.blur();                 // most browsers 
				this.hideFocus = false;      // internet explorer    
				if(brs.Browser.IE === false){
					this.style.outline = null;   // mozilla 
				}
			}

	}
}
function chkObject(inParent,theVal) {
	if(inParent){
		if (window.opener.document.getElementById(theVal) != null) {
			return true;
		} else {
			return false;
		}
	}else{
		if (document.getElementById(theVal) != null) {
			return true;
		} else {
			return false;
		}
	}
}

function findElem(parent, elem){
	var parent = parent;
	var elem = elem;
	var elem_y = false;
	var elemObj = null;
	var elemarr = '';
	if(typeof parent !== 'object'){
		if($(parent)){
			parent = $(parent);	
		}
	}
	if(typeof parent !== 'object'){return null;}
	if(typeof elem !== 'object' && typeof elem !== 'undefined'){
		if($(elem)){
			elem = $(elem);	
		}	
	}
	
	var childs = parent.childNodes;
	var childsLen = childs.length;
	if(typeof elem !== 'object' && typeof elem !== 'undefined'){
		
		
		for(var i=0; i < childsLen; i++){
			var ch = childs[i];
			if(ch.nodeType !== 3){
				var chnodename = ch.nodeName.toLowerCase();
				if(chnodename === elem){
					elem_y = true;
					elemObj = ch;
					break;	
				}
				else if(ch.hasChildNodes()){
					elemObj = findElem(ch, elem);
				}	
			}	
		}
		
	}
	else{
		for(var i=0; i < childsLen; i++){
			var ch = childs[i];
			if(ch === elem){
				elem_y = true;
				elemObj = ch;
				break;	
			}
			else if(ch.hasChildNodes()){
				elemObj = findElem(ch, elem);
			}
		}
	}
	return elemObj;
}

function outerHTML(node){
  return node.outerHTML || (
      function(n){
          var div = document.createElement('div'), h;
          div.appendChild( n.cloneNode(true) );
          h = div.innerHTML;
          div = null;
          return h;
      })(node);
  }

function logo(){
	if($('logo')){
		if(typeof SITEPATH === 'undefined'){SITEPATH = '#';}
		var logo = document.getElementById('logo');
		logo.style.cssText='cursor:pointer';
		var logonodename = logo.nodeName;
		logonodename = logonodename.toLowerCase();
		if(logonodename === 'div'){
			
			var elemObj = findElem(logo, 'logoimg');
			if(elemObj !== null){
				var elempnn = elemObj.parentNode.nodeName+'';
				elempnn = elempnn.toLowerCase();
				if(elempnn !== 'a'){
					var imghtml = outerHTML(elemObj);
					var astr = '<a href="'+SITEPATH+'">'+imghtml+'</a>';
					var logohtml = logo.innerHTML;
					var imgreplace = logohtml.replace(imghtml, astr);
					logo.innerHTML = imgreplace; 
					//alert('Replace img: '+imgreplace);
				}
			}
		}
		//alert(logonodename);
		logo.onclick = function(){
			window.location=SITEPATH;	
		}
	}	
}

function rmvpgLnk(){
	var atag_arr = document.getElementsByTagName('a');
	var ataglen = atag_arr.length;
	for(var i=0; i < ataglen; i++){
		var ataghref = '';
		//ataghref = atag_arr[i].getAttribute('href');
		ataghref = getHref(atag_arr[i]);
		if(ataghref==='services.html' || ataghref==='products.html'){
			atag_arr[i].href="javascript: void(0);";
		}
	}
}

/***************************Load the addFunToElement function to the window event load.*********************************/
addLoadEvent(function() {
		//addFunToElement();
		scrollbar();
		//formSubmitA();
		chngHashTojavascriptNull();
		rmvpgLnk()
		logo();
		
		//alert(brsVersion());
});
/**************************************eof load event******************************************************************/
