/*==================================================
  Cookie functions
  ==================================================*/
function setCookie(name, value, expires, path, domain, secure) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires_date.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


function converting (keyCode, key) {
  var asciiUmlauts = {
	" ": " ", //
	"!": "!", //
    "[": "[", //
	"]": "]", //
	"{": "‘", //
	"}": "’", //
	":": ":"  //
  };
  if (" ![]{}:".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: asciiUmlauts[key].charCodeAt(), newKey:
asciiUmlauts[key] };
  }
  if ("?".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1567).charCodeAt(), newKey:
String.fromCharCode(1567) };	  
  }
  if ("a".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1575).charCodeAt(), newKey:
String.fromCharCode(1575) };	  
  }
  if ("A".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1570).charCodeAt(), newKey:
String.fromCharCode(1570) };	  
  }
  if ("s".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1587).charCodeAt(), newKey:
String.fromCharCode(1587) };	  
  }
  if ("S".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1589).charCodeAt(), newKey:
String.fromCharCode(1589) };	  
  }
  if ("d".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1583).charCodeAt(), newKey:
String.fromCharCode(1583) };	  
  }
  if ("D".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1672).charCodeAt(), newKey:
String.fromCharCode(1672) };	  
  }
  if ("f".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1601).charCodeAt(), newKey:
String.fromCharCode(1601) };	  
  }
  if ("g".indexOf(key) != -1) {

    return { replaceKey: true, newKeyCode: String.fromCharCode(1711).charCodeAt(), newKey:
String.fromCharCode(1711) };	  
  }
  if ("G".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1594).charCodeAt(), newKey:
String.fromCharCode(1594) };	  
  }
  if ("h".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1726).charCodeAt(), newKey:
String.fromCharCode(1726) };	  
  }
  if ("H".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1581).charCodeAt(), newKey:
String.fromCharCode(1581) };	  
  }
  if ("j".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1580).charCodeAt(), newKey:
String.fromCharCode(1580) };	  
  }
  if ("J".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1590).charCodeAt(), newKey:
String.fromCharCode(1590) };	  
  }
  if ("k".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1705).charCodeAt(), newKey:
String.fromCharCode(1705) };	  
  }
  if ("K".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1582).charCodeAt(), newKey:
String.fromCharCode(1582) };	  
  }
  if ("l".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1604).charCodeAt(), newKey:
String.fromCharCode(1604) };	  
  }
  if ("z".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1586).charCodeAt(), newKey:
String.fromCharCode(1586) };	  
  }
  if ("Z".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1584).charCodeAt(), newKey:
String.fromCharCode(1584) };	  
  }
  if ("x".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1588).charCodeAt(), newKey:
String.fromCharCode(1588) };	  
  }
  if ("X".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1688).charCodeAt(), newKey:

String.fromCharCode(1688) };	  
  }
  if ("c".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1670).charCodeAt(), newKey:
String.fromCharCode(1670) };	  
  }
  if ("C".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1579).charCodeAt(), newKey:
String.fromCharCode(1579) };	  
  }
  if ("v".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1591).charCodeAt(), newKey:
String.fromCharCode(1591) };	  
  }
  if ("V".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1592).charCodeAt(), newKey:
String.fromCharCode(1592) };	  
  }
  if ("b".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1576).charCodeAt(), newKey:
String.fromCharCode(1576) };	  
  }
  if ("n".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1606).charCodeAt(), newKey:
String.fromCharCode(1606) };	  
  }
  if ("N".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1722).charCodeAt(), newKey:
String.fromCharCode(1722) };	  
  }
  if ("m".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1605).charCodeAt(), newKey:
String.fromCharCode(1605) };	  
  }
  if ("q".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1602).charCodeAt(), newKey:
String.fromCharCode(1602) };	  
  }
  if ("w".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1608).charCodeAt(), newKey:
String.fromCharCode(1608) };	  
  }
  if ("e".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1593).charCodeAt(), newKey:
String.fromCharCode(1593) };	  
  }
  if ("E".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1569).charCodeAt(), newKey:
String.fromCharCode(1569) };	  
  }
  if ("r".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1585).charCodeAt(), newKey:
String.fromCharCode(1585) };	  
  }
  if ("R".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1681).charCodeAt(), newKey:
String.fromCharCode(1681) };	  
  }
  if ("t".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1578).charCodeAt(), newKey:
String.fromCharCode(1578) };	  
  }
  if ("T".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1657).charCodeAt(), newKey:
String.fromCharCode(1657) };	  
  }
  if ("y".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1746).charCodeAt(), newKey:
String.fromCharCode(1746) };	  
  }
  if ("u".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1574).charCodeAt(), newKey:
String.fromCharCode(1574) };	  
  }
  if ("o".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1729).charCodeAt(), newKey:
String.fromCharCode(1729) };	  
  }
  if ("p".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1662).charCodeAt(), newKey:
String.fromCharCode(1662) };	  
  }
  if ("i".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1740).charCodeAt(), newKey:
String.fromCharCode(1740) };	  
  }
  if ("O".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1731).charCodeAt(), newKey:
String.fromCharCode(1731) };
  }
  if ("I".indexOf(key) != -1) {
	  //document.formName.texturdu.value=document.formName.texturdu.value + String.fromCharCode(1648);
    return { replaceKey: true, newKeyCode: String.fromCharCode(1648).charCodeAt(), newKey:
String.fromCharCode(1648) };
	  //return { cancelKey: true };
  }
  if ("&".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1569).charCodeAt(), newKey:
String.fromCharCode(1569) };
  }

  if ("9".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1641).charCodeAt(), newKey:
String.fromCharCode(1641) };
  }
  if ("8".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1640).charCodeAt(), newKey:
String.fromCharCode(1640) };
  }
  if ("7".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1639).charCodeAt(), newKey:
String.fromCharCode(1639) };
  }
  if ("6".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1638).charCodeAt(), newKey:
String.fromCharCode(1638) };
  }
  if ("5".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1637).charCodeAt(), newKey:
String.fromCharCode(1637) };
  }
  if ("4".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1636).charCodeAt(), newKey:
String.fromCharCode(1636) };
  }
  if ("3".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1635).charCodeAt(), newKey:
String.fromCharCode(1635) };
  }
  if ("2".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1634).charCodeAt(), newKey:
String.fromCharCode(1634) };
  }
  if ("1".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1633).charCodeAt(), newKey:
String.fromCharCode(1633) };
  }
  if ("0".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1632).charCodeAt(), newKey:
String.fromCharCode(1632) };
  }

  if (".".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1748).charCodeAt(), newKey:
String.fromCharCode(1748) };
  }    
  
  if (";".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1563).charCodeAt(), newKey:
String.fromCharCode(1563) };
  } 
  if ("-".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1652).charCodeAt(), newKey:
String.fromCharCode(1652) };
  }      
  
  if ("P".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1615).charCodeAt(), newKey:
String.fromCharCode(1615) };
  }
  
  if ("<".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1616).charCodeAt(), newKey:
String.fromCharCode(1616) };
  }
  
  if (">".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1614).charCodeAt(), newKey:
String.fromCharCode(1614) };
  }
   
  if ("=".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1572).charCodeAt(), newKey:
String.fromCharCode(1572) };
  }   

  if ("*".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1612).charCodeAt(), newKey:
String.fromCharCode(1612) };
  }   
  if ("~".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1611).charCodeAt(), newKey:
String.fromCharCode(1611) };
  } 
  if ("`".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1613).charCodeAt(), newKey:
String.fromCharCode(1613) };
  }   
  if ("_".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1617).charCodeAt(), newKey:
String.fromCharCode(1617) };
  }    
  if ("/".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1618).charCodeAt(), newKey:
String.fromCharCode(1618) };
  }    
  if (",".indexOf(key) != -1) {
    return { replaceKey: true, newKeyCode: String.fromCharCode(1548).charCodeAt(), newKey:
String.fromCharCode(1548) };
  }      
  else {
    return { cancelKey: false };
  }
}


   function Urdu() {
	   if(document.getElementById('urdu').checked == true){
			var checked = true;
			setCookie('ur','0',365);
		} else {
			var checked = false;
			setCookie('ur','1',365);
		}
   		var el = getElementsByClass('urdu');
		for (var i=0; i < el.length; i++){
			el[i].style.display = checked ? "block" : "none";
		}

   }

   function English() {
	   if(document.getElementById('english').checked == true){
			var checked = true;
			setCookie('en','0',365);
		}else{
			var checked = false;
			setCookie('en','1',365);
		}

   		var el = getElementsByClass('english');
		for (var i=0; i < el.length; i++){
			el[i].style.display = checked ? "block" : "none";
		}

   }

function IndoPak() {
	setCookie('arabicscript','0',365);
	var el = getElementsByClass('uthmanic');
		for (var i=0; i < el.length; i++){
			el[i].style.display = "none";
		}
	
	var el = getElementsByClass('indopak');
		for (var i=0; i < el.length; i++){
			el[i].style.display = "block";
		}
	
}

function Uthmanic() {
	setCookie('arabicscript','1',365);
	var el = getElementsByClass('indopak');
		for (var i=0; i < el.length; i++){
			el[i].style.display = "none";
		}
	
	var el = getElementsByClass('uthmanic');
		for (var i=0; i < el.length; i++){
			el[i].style.display = "block";
		}
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

