	//var LIVE_SITE = 'http://www.converter.pk/';
	var globalcheck = true;
	var check = true;
	var count=0;
	var isFirst = true;
	
function actb(obj,ca){ 
	/* ---- Public Variables ---- */
	this.actb_timeOut = -1; // Autocomplete Timeout in ms (-1: autocomplete never time out)
	this.actb_lim = 6;    // Number of elements autocomplete can show (-1: no limit)
	this.actb_firstText = true; // should the auto complete be limited to the beginning of keyword?
	this.actb_mouse = true; // Enable Mouse Support
	this.actb_delimiter = new Array(';',',');  // Delimiter for multiple autocomplete. Set it to empty array for single autocomplete
	this.actb_startcheck = 1; // Show widget only after this number of characters is typed in.
	/* ---- Public Variables ---- */

	/* --- Styles --- */
	this.actb_bgColor = '#FFFFFF';
	this.actb_textColor = '#666666';
	this.actb_hColor = '#f7f0e8';
	this.actb_fFamily = 'tahoma';
	this.actb_fSize = '11px';
	this.actb_hStyle = 'text-decoration:underline;font-weight:bold';
	/* --- Styles --- */

	/* ---- Private Variables ---- */
	var actb_delimwords = new Array();
	var actb_cdelimword = 0;
	var actb_delimchar = new Array();
	var actb_display = false;
	var actb_pos = 0;
	var actb_total = 0;
	var actb_curr = null;
	var actb_rangeu = 0;
	var actb_ranged = 0;
	var actb_bool = new Array();
	var actb_pre = 0;
	var actb_toid;
	var actb_tomake = false;
	var actb_getpre = "";
	var actb_mouse_on_list = 0;
	var actb_kwcount = 0;
	var actb_caretmove = false;
	this.actb_keywords = new Array();
	
	/* ---- Private Variables---- */
	if(obj.id == 'autosearch')
	{
		this.actb_keywords = customarray;
	}else {
		this.actb_keywords = unitsarray;
	}
	
	var actb_self = this;

	actb_curr = obj;

	addEvent(actb_curr,"focus",actb_setup);

	function actb_setup(){ 
		addEvent(document,"keydown",actb_checkkey);
		addEvent(actb_curr,"blur",actb_clear);
		addEvent(document,"keypress",actb_keypress);
	}

	function actb_clear(evt){  
		if (!evt) evt = event;
		removeEvent(document,"keydown",actb_checkkey);
		removeEvent(document,"keypress",actb_keypress);
		removeEvent(actb_curr,"blur",actb_clear);
		actb_removedisp();
	}
	function actb_parse(n){ 
		if (actb_self.actb_delimiter.length > 0){
			var t = actb_delimwords[actb_cdelimword].trim().addslashes();
			var plen = actb_delimwords[actb_cdelimword].trim().length;
		}else{
			var t = actb_curr.value.addslashes();
			var plen = actb_curr.value.length;
		}
		var tobuild = '';
		var i;

		if (actb_self.actb_firstText){
			var re = new RegExp("^" + t, "i");
		}else{
			var re = new RegExp(t, "i");
		}
		var p = n.search(re);
				
		for (i=0;i<p;i++){
			tobuild += n.substr(i,1);
		}
		tobuild += "<font style='"+(actb_self.actb_hStyle)+"'>"
		for (i=p;i<plen+p;i++){
			tobuild += n.substr(i,1);
		}
		tobuild += "</font>";
			for (i=plen+p;i<n.length;i++){
			tobuild += n.substr(i,1);
		}
		return tobuild;
	}
	function actb_generate(){
		if (document.getElementById('tat_table')){ actb_display = false;document.body.removeChild(document.getElementById('tat_table')); } 
		if (actb_kwcount == 0)
		{
			actb_display = false;
			objlen=document.getElementById(obj.id).value.length;
			if(obj.id !=='autosearch')
			{
			   document.getElementById(obj.id).style.background="#D54E21";
			}
		return;
		}
		else
		{
			if(obj.id !=='autosearch')
			{
			document.getElementById(obj.id).style.background="white";
			}
		}
		
		a = document.createElement('table');
		a.cellSpacing='1px';
		a.cellPadding='2px';
		a.style.position='absolute';
		var mymargin = 0;
		if(obj.id=='autosearch') { mymargin=0 }else {mymargin=0}
		a.style.top = eval(curTop(actb_curr) + actb_curr.offsetHeight+mymargin) + "px";
		a.style.left = curLeft(actb_curr) + "px";
		a.style.backgroundColor=actb_self.actb_bgColor;
		a.id = 'tat_table';

		document.body.appendChild(a);
		var i;
		var first = true;
		var j = 1;
		if (actb_self.actb_mouse){
			a.onmouseout = actb_table_unfocus;
			a.onmouseover = actb_table_focus;
		}
		var counter = 0;
		if(obj.id=='autosearch') {actb_self.actb_keywords=customarray;}else{actb_self.actb_keywords=unitsarray;}
		for (i=0;i<actb_self.actb_keywords.length;i++){
			if (actb_bool[i]){ 
				counter++;
				r = a.insertRow(-1);
				if (first && !actb_tomake){
					//r.style.backgroundColor = actb_self.actb_hColor;
					first = false;
					actb_pos = counter;
				}else if(actb_pre == i){
					//r.style.backgroundColor = actb_self.actb_hColor;
					first = false;
					actb_pos = counter;
				}else{
					r.style.backgroundColor = actb_self.actb_bgColor;
				}
				r.id = 'tat_tr'+(j);
				c = r.insertCell(-1);
				c.style.color = actb_self.actb_textColor;
				c.style.fontFamily = actb_self.actb_fFamily;
				c.style.fontSize = actb_self.actb_fSize;
				c.innerHTML = actb_parse(actb_self.actb_keywords[i]);
				c.id = 'tat_td'+(j);
				c.setAttribute('pos',j);
				if (actb_self.actb_mouse){
					c.style.cursor = 'pointer';
					c.onclick=actb_mouseclick;
					c.onmouseover = actb_table_highlight;
				}
				j++;
			}
			if (j - 1 == actb_self.actb_lim && j < actb_total){
				r = a.insertRow(-1);
				r.style.backgroundColor = actb_self.actb_bgColor;
				c = r.insertCell(-1);
				c.style.color = actb_self.actb_textColor;
				c.style.fontFamily = 'arial narrow';
				c.style.fontSize = actb_self.actb_fSize;
				c.align='center';
				replaceHTML(c,'down.gif');
				if (actb_self.actb_mouse){
					c.style.cursor = 'pointer';
					c.onclick = actb_mouse_down;
				}
				break;
			}
		}
		actb_rangeu = 1;
		actb_ranged = j-1;
		actb_display = true;
		if (actb_pos <= 0) actb_pos = 1;
	}
	function actb_remake(){
		document.body.removeChild(document.getElementById('tat_table'));
		a = document.createElement('table');
		a.cellSpacing='1px';
		a.cellPadding='2px';
		a.style.position='absolute';
		a.style.top = eval(curTop(actb_curr) + actb_curr.offsetHeight) + "px";
		a.style.left = curLeft(actb_curr) + "px";
		a.style.backgroundColor=actb_self.actb_bgColor;
		a.id = 'tat_table';
		if (actb_self.actb_mouse){
			a.onmouseout= actb_table_unfocus;
			a.onmouseover=actb_table_focus;
		}
		document.body.appendChild(a);
		var i;
		var first = true;
		var j = 1;
		if (actb_rangeu > 1){
			r = a.insertRow(-1);
			r.style.backgroundColor = actb_self.actb_bgColor;
			c = r.insertCell(-1);
			c.style.color = actb_self.actb_textColor;
			c.style.fontFamily = 'arial narrow';
			c.style.fontSize = actb_self.actb_fSize;
			c.align='center';
			replaceHTML(c,'up.gif');
			if (actb_self.actb_mouse){
				c.style.cursor = 'pointer';
				c.onclick = actb_mouse_up;
			}
		}
		if(obj.id=='autosearch') {actb_self.actb_keywords=customarray;}else{actb_self.actb_keywords=unitsarray;}
		for (i=0;i<actb_self.actb_keywords.length;i++){
			if (actb_bool[i]){
				if (j >= actb_rangeu && j <= actb_ranged){
					r = a.insertRow(-1);
					r.style.backgroundColor = actb_self.actb_bgColor;
					r.id = 'tat_tr'+(j);
					c = r.insertCell(-1);
					c.style.color = actb_self.actb_textColor;
					c.style.fontFamily = actb_self.actb_fFamily;
					c.style.fontSize = actb_self.actb_fSize;
					c.innerHTML = actb_parse(actb_self.actb_keywords[i]);
					c.id = 'tat_td'+(j);
					c.setAttribute('pos',j);
					if (actb_self.actb_mouse){
						c.style.cursor = 'pointer';
						c.onclick=actb_mouseclick;
						c.onmouseover = actb_table_highlight;
					}
					j++;
				}else{
					j++;
				}
			}
			if (j > actb_ranged) break;
		}
		if (j-1 < actb_total){
			r = a.insertRow(-1);
			r.style.backgroundColor = actb_self.actb_bgColor;
			c = r.insertCell(-1);
			c.style.color = actb_self.actb_textColor;
			c.style.fontFamily = 'arial narrow';
			c.style.fontSize = actb_self.actb_fSize;
			c.align='center';
			replaceHTML(c,'down.gif');
			if (actb_self.actb_mouse){
				c.style.cursor = 'pointer';
				c.onclick = actb_mouse_down;
			}
		}
	}
	function actb_goup(){
		if (!actb_display) return;
		if (actb_pos == 1) { return;}
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
		actb_pos--;
		document.getElementById(obj.id).value = actb_currentvalueUP();
		//var myCount = actb_currentvalue();
		//document.getElementById(obj.id).value = actb_currentvalue();
		if(obj.id=='unitsfrom') {funUpdateHiddenValues(actb_curr.value,'from');}
		else if(obj.id=='unitsto') {funUpdateHiddenValues(actb_curr.value,'to');}
		
		if (actb_pos < actb_rangeu) actb_moveup();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_godown()
	{ 
		if (!actb_display) return;
		if (actb_pos == actb_total && actb_total==1)
		{	document.getElementById(obj.id).value = actb_currentvalueFirst();
			document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
			return;}
		if (actb_pos == actb_total) return;
		if(actb_pos==1 && isFirst){ 
		
			isFirst=false;
			document.getElementById(obj.id).value = actb_currentvalueFirst();
			document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
			return;
		}
		document.getElementById(obj.id).value = actb_currentvalue();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
		actb_pos++;
		if(obj.id=='unitsfrom') {funUpdateHiddenValues(actb_curr.value,'from');}
		else if(obj.id=='unitsto') {funUpdateHiddenValues(actb_curr.value,'to');}

		if (actb_pos > actb_ranged) actb_movedown();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
		
	}
	function actb_movedown(){
		actb_rangeu++;
		actb_ranged++;
		actb_remake();
	}
	function actb_moveup(){
		actb_rangeu--;
		actb_ranged--;
		actb_remake();
	}

	/* Mouse */
	function actb_mouse_down(){
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
		actb_pos++;
		actb_movedown();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
		actb_curr.focus();
		actb_mouse_on_list = 0;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_mouse_up(evt){
		if (!evt) evt = event;
		if (evt.stopPropagation){
			evt.stopPropagation();
		}else{
			evt.cancelBubble = true;
		}
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
		actb_pos--;
		actb_moveup();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
		actb_curr.focus();
		actb_mouse_on_list = 0;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_mouseclick(evt){
		if (!evt) evt = event;
		if (!actb_display) return;
		actb_mouse_on_list = 0;
		actb_pos = this.getAttribute('pos');
		actb_penter();
	}
	function actb_table_focus(){
		actb_mouse_on_list = 1;
	}
	function actb_table_unfocus(){
		actb_mouse_on_list = 0;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
	}
	function actb_table_highlight(){
		actb_mouse_on_list = 1;
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
		actb_pos = this.getAttribute('pos');
		while (actb_pos < actb_rangeu) actb_moveup();
		while (actb_pos > actb_ranged) actb_movedown();
		document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
	}
	/* ---- */

	function actb_insertword(a){
		if (actb_self.actb_delimiter.length > 0){
			str = '';
			l=0;
			for (i=0;i<actb_delimwords.length;i++){
				if (actb_cdelimword == i){
					prespace = postspace = '';
					gotbreak = false;
					for (j=0;j<actb_delimwords[i].length;++j){
						if (actb_delimwords[i].charAt(j) != ' '){
							gotbreak = true;
							break;
						}
						prespace += ' ';
					}
					for (j=actb_delimwords[i].length-1;j>=0;--j){
						if (actb_delimwords[i].charAt(j) != ' ') break;
						postspace += ' ';
					}
					str += prespace;
					str += a;
					l = str.length;
					if (gotbreak) str += postspace;
				}else{
					str += actb_delimwords[i];
				}
				if (i != actb_delimwords.length - 1){
					str += actb_delimchar[i];
				}
			}
			if(obj.id=='autosearch' && actb_pos==1){
				document.frm_search.submit();
				
				}else {
			actb_curr.value = str; 
			setCaret(actb_curr,l);

			if(obj.id=='autosearch') {
				document.getElementById('search_type').value=1;
				document.frm_search.submit();
			}else if(obj.id=='unitsfrom') {funUpdateHiddenValues(actb_curr.value,'from');}
			else if(obj.id=='unitsto') {funUpdateHiddenValues(actb_curr.value,'to');}
			}
		}else{
			actb_curr.value = a;
		}
		actb_mouse_on_list = 0;
		actb_removedisp();
	}
	function actb_currentvalue()
	{
		var word = '';
		var c = 0;
		var counter =0;
		if(obj.id=='autosearch') {actb_self.actb_keywords=customarray;}else{actb_self.actb_keywords=unitsarray;}
		for (var i=0;i<=actb_self.actb_keywords.length;i++){
			if (actb_bool[i]) c++;
			if (c == actb_pos+1){
				word = actb_self.actb_keywords[i];
				break;
			}
		}
		return word;
	}
	function actb_currentvalueUP()
	{
		var word = '';
		var c = 0;
		var counter =0;
		if(obj.id=='autosearch') {actb_self.actb_keywords=customarray;}else{actb_self.actb_keywords=unitsarray;}
		for (var i=0;i<=actb_self.actb_keywords.length;i++){
			if (actb_bool[i]) c++;
			if (c == actb_pos){
				word = actb_self.actb_keywords[i];
				break;
			}
		}
		return word;
	}
	function actb_currentvalueFirst()
	{
		var word = '';
		var c = 0;
		var counter =0;
		if(obj.id=='autosearch') {actb_self.actb_keywords=customarray;}else{actb_self.actb_keywords=unitsarray;}
		for (var i=0;i<=actb_self.actb_keywords.length;i++){
			if (actb_bool[i]) c++;
			if (c == 1){
				word = actb_self.actb_keywords[i];
				break;
			}
		}
		return word;
	}
	function actb_penter(){
		if(actb_pos==1 && isFirst){
			if(obj.id=="autocomplete")
			{
				document.frm_search.submit();
				}
		}
		if (!actb_display) return;
		actb_display = false;
		var word = '';
		var c = 0;
		if(obj.id=='autosearch') {actb_self.actb_keywords=customarray;}else{actb_self.actb_keywords=unitsarray;}
		for (var i=0;i<=actb_self.actb_keywords.length;i++){
			if (actb_bool[i]) c++;
			if (c == actb_pos){
				word = actb_self.actb_keywords[i];
				break;
			}
		}
		
		actb_insertword(word);
		l = getCaretStart(actb_curr);
	}
	function actb_removedisp(){
		isFirst=true;
		if (actb_mouse_on_list==0){
			actb_display = 0;
			if (document.getElementById('tat_table')){ document.body.removeChild(document.getElementById('tat_table')); }
			if (actb_toid) clearTimeout(actb_toid);
		}
	}
	function actb_keypress(e){
		if (actb_caretmove) stopEvent(e);
		return !actb_caretmove;
	}
	function actb_checkkey(evt){ 
		if (!evt) evt = event;
		a = evt.keyCode; 
		caret_pos_start = getCaretStart(actb_curr);
		actb_caretmove = 0;
		switch (a){
			case 38:
				actb_goup();
				actb_caretmove = 1;
				return false;
				break;
			case 40:
			if(globalcheck==false) {
				actb_tocomplete(39);
				globalcheck=true;
				return true;
			}else {
				actb_godown(); 
				actb_caretmove = 1;
				globalcheck=true;
				return false;
			}
				break;
			case 13: case 9:
				if (actb_display){
					actb_caretmove = 1;
					actb_penter();
					return false;
				}else{
					return true;
				}
				break;
			default:
				setTimeout(function(){actb_tocomplete(a)},50);
				break;
		}
	}

	function actb_tocomplete(kc){
		if (kc == 38 || kc == 40 || kc == 13) return;
		var i;
		if (actb_display){ 
			var word = 0;
			var c = 0;
			if(obj.id=='autosearch') {actb_self.actb_keywords=customarray;}else{actb_self.actb_keywords=unitsarray;}
			for (var i=0;i<=actb_self.actb_keywords.length;i++){
				if (actb_bool[i]) c++;
				if (c == actb_pos){
					word = i;
					break;
				}
			}
			actb_pre = word;
		}else{ actb_pre = -1};
		
		if (actb_curr.value == ''){
			actb_mouse_on_list = 0;
			actb_removedisp();
			return;
		}
		if (actb_self.actb_delimiter.length > 0){
			caret_pos_start = getCaretStart(actb_curr);
			caret_pos_end = getCaretEnd(actb_curr);
			
			delim_split = '';
			for (i=0;i<actb_self.actb_delimiter.length;i++){
				delim_split += actb_self.actb_delimiter[i];
			}
			delim_split = delim_split.addslashes();
			delim_split_rx = new RegExp("(["+delim_split+"])");
			c = 0;
			actb_delimwords = new Array();
			actb_delimwords[0] = '';
			for (i=0,j=actb_curr.value.length;i<actb_curr.value.length;i++,j--){
				if (actb_curr.value.substr(i,j).search(delim_split_rx) == 0){
					ma = actb_curr.value.substr(i,j).match(delim_split_rx);
					actb_delimchar[c] = ma[1];
					c++;
					actb_delimwords[c] = '';
				}else{
					actb_delimwords[c] += actb_curr.value.charAt(i);
				}
			}

			var l = 0;
			actb_cdelimword = -1;
			for (i=0;i<actb_delimwords.length;i++){
				if (caret_pos_end >= l && caret_pos_end <= l + actb_delimwords[i].length){
					actb_cdelimword = i;
				}
				l+=actb_delimwords[i].length + 1;
			}
			var ot = actb_delimwords[actb_cdelimword].trim(); 
			var t = actb_delimwords[actb_cdelimword].addslashes().trim();
		}else{
			var ot = actb_curr.value;
			var t = actb_curr.value.addslashes();
		}
		if (ot.length == 0){
			actb_mouse_on_list = 0;
			actb_removedisp();
		}
		if (ot.length < actb_self.actb_startcheck) return this;
		if (actb_self.actb_firstText){
			var re = new RegExp("^" + t, "i");
		}else{
			var re = new RegExp(t, "i");
		}

		actb_total = 0;
		actb_tomake = false;
		actb_kwcount = 0;
		if(obj.id=='autosearch') {actb_self.actb_keywords=customarray;}else{actb_self.actb_keywords=unitsarray;}
		for (i=0;i<actb_self.actb_keywords.length;i++){
			actb_bool[i] = false;
			if (re.test(actb_self.actb_keywords[i])){
				actb_total++;
				actb_bool[i] = true;
				actb_kwcount++;
				if (actb_pre == i) actb_tomake = true;
			}
		}

		if (actb_toid) clearTimeout(actb_toid);
		if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
		actb_generate();
	}
	return this;
}


function searchFocus(obj)
{
	if(document.getElementById('autosearch').value=='Search')
	{
		document.getElementById('autosearch').value='';
	}
	
	if(document.getElementById('autosearch').value != 'Search')
	{
		document.getElementById('autosearch').style.color="#666666";
	}
}
function searchText()
{
	if(document.getElementById('autosearch').value =='')
	{
		document.getElementById('autosearch').value='Search';
		document.getElementById('autosearch').style.color="#E8E4F8";
	}
	/*var obj2 =  actb(document.getElementById('autosearch'),customarray);
	removeEvent(obj2,"blur",obj2.actb_clear);*/
}
function searchSubmit(obj)
{
	//alert(document.getElementById('autosearch').value);
	document.location ='index.php?option=search&keywords='+document.getElementById('autosearch').value;
	
}

function collapse(show)
{ 
	$(document).ready(function() {
	var count = $('div[title=open][id!='+show+']').size();  
	if(count>0){
		$('div[title=open][id!='+show+']').attr('title','close').slideUp(500,function(){
		$('div#'+show+'[title=close]').attr('title','open').slideDown(500)
		});
	}else { 
		$('div#'+show+'[title=close]').attr('title','open').slideDown(500);
		}
		}); 
}

function funUpdateHiddenValues(value,str)
{
	ajaxArticles(value,str);
	for(var found in completeArray)
	{ 
		if(found==value)
		{
			if(str=='from') {
			document.getElementById('from').value = completeArray[found];
			document.getElementById('fromName').value = found;
			myCon();
			} else {
			document.getElementById('to').value = completeArray[found];
			document.getElementById('toName').value = found;
			myCon();
			}
			return
		}
	}
	
}


function search_forum_text_focus()
{
	if(document.getElementById('blog_search_tb').value=='Search on this forum')
	{
		document.getElementById('blog_search_tb').value='';
	}
	
	if(document.getElementById('blog_search_tb').value != 'Search on this forum')
	{
		document.getElementById('blog_search_tb').style.color="#666666";
	}	
}
function searchText_forum_tb()
{
	if(document.getElementById('blog_search_tb').value =='')
	{
		document.getElementById('blog_search_tb').value='Search on this forum';
		document.getElementById('blog_search_tb').style.color="#E8E4F8";
	}
	/*var obj2 =  actb(document.getElementById('autosearch'),customarray);
	removeEvent(obj2,"blur",obj2.actb_clear);*/
}

///for number conversion
function getUnits(value,str)
{ 
	ajaxArticles(value,str);
	for(var found in completeArray)
	{ 
		if(found==value)
		{
			if(str=='from') {
			document.getElementById('from').value = completeArray[found];
			document.getElementById('fromName').value = found;
			document.getElementById('unitsfrom').value = found;
			document.getElementById('unitsfrom').focus();
			//myCon();
			// ajax
			} else {
			document.getElementById('to').value = completeArray[found];
			document.getElementById('toName').value = found;
			document.getElementById('unitsto').value = found;
			document.getElementById('unitsto').focus();
			//myCon();
			//ajax
			}
			return
		}
	}
}
/////

function setUnit(value,str)
{ 
	ajaxArticles(value,str);
	for(var found in completeArray)
	{ 
		if(found==value)
		{	if(str=='from') 
			{

			document.getElementById('from').value = completeArray[found];
			document.getElementById('fromName').value = found;
			document.getElementById('unitsfrom').value = found;
			document.getElementById('unitsfrom').style.background="white";
			document.getElementById('unitsfrom').focus();		
			setCookie("unit1",completeArray[found],null);
			setCookie("txt1",document.getElementById('unitsfrom').value,null);
			myCon();
			// ajax
			} else {
			document.getElementById('to').value = completeArray[found];
			document.getElementById('toName').value = found;
			document.getElementById('unitsto').value = found;
			document.getElementById('unitsto').style.background="white";
			document.getElementById('unitsto').focus();
			setCookie("unit2",completeArray[found],null);
			setCookie("txt2",document.getElementById('unitsto').value,null);
			myCon();
			//ajax
			}
			return
		}
	}
	
}


function setUnit_TZ(value,str)
{ 
	//ajaxArticles(value,str);
	for(var found in completeArray)
	{ 
		if(found==value)
		{	if(str=='from') 
			{

			document.getElementById('from').value = completeArray[found];
			document.getElementById('fromName').value = found;
			document.getElementById('unitsfrom').value = found;
			document.getElementById('unitsfrom').style.background="white";
			document.getElementById('unitsfrom').focus();		
			setCookie("unit1",completeArray[found],null);
			setCookie("txt1",document.getElementById('unitsfrom').value,null);
			myCon(str);
			// ajax
			} else {
			document.getElementById('to').value = completeArray[found];
			document.getElementById('toName').value = found;
			document.getElementById('unitsto').value = found;
			document.getElementById('unitsto').style.background="white";
			document.getElementById('unitsto').focus();
			setCookie("unit2",completeArray[found],null);
			setCookie("txt2",document.getElementById('unitsto').value,null);
			myCon(str);
			//ajax
			}
			return
		}
	}
	
}


function checkCookie(cok)
{
username=getCookie(cok);
if (username!=null && username!="")
  {
	  return true;
  }
 return false;
}
/////////////////////////cookie section///////////////////
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+ expiredays);
document.cookie=c_name + "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
//////////////////////// end cookie section ///////////
////////////number con
function setUnitN(value,str)
{ 
	ajaxArticles(value,str);
	for(var found in completeArray)
	{ 
		if(found==value)
		{
			if(str=='from') {
			document.getElementById('from').value = completeArray[found];
			document.getElementById('fromName').value = found;
			document.getElementById('unitsfrom').value = found;
			document.getElementById('unitsfrom').focus();
			
			//EvalAnyNew(str);
			//myCon();
			// ajax
			} else {
			document.getElementById('to').value = completeArray[found];
			document.getElementById('toName').value = found;
			document.getElementById('unitsto').value = found;
			document.getElementById('unitsto').focus();
			//EvalAnyNew(str);
			//myCon();
			//ajax
			}
			return
		}
	}
}


////------------end-----------

function onFocus(evt)
{
  /*if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
  {
	//return;
  }*/
  evt.select();
}
	
function onBlurName(evt)
{ 
	if(evt.value=="")
	{
		if(evt.id=='unitsfrom')
		{
			evt.value = document.getElementById('fromName').value;
			}else {
				evt.value = document.getElementById('toName').value;
			}
		}
		
	}

function onBlurValue(evt)
{ 
	if(evt.value=="")
	{ evt.value=1; }
}

function ajaxArticles(value,str)
{ 
	if(str=='from')
	{
		document.getElementById('larticle').value=value;
		}else {
		document.getElementById('rarticle').value=value;
	}
	var larticle = document.getElementById('larticle').value;
	var rarticle = document.getElementById('rarticle').value;

if(larticle!=rarticle) {
	var xmlhttp=false;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if(xmlhttp) {
		xmlhttp.onreadystatechange=function()
		{
			if(xmlhttp.readyState==4)
			  {	
			  	 if(str=='from') {
				 	document.getElementById('left_articles').innerHTML=xmlhttp.responseText;
				 }else {
					document.getElementById('right_articles').innerHTML=xmlhttp.responseText;
				}
			  }
			}
		xmlhttp.open("GET",'../admin/ajax_articles.php?unit_name='+value,true);
		xmlhttp.send(null);
	}
	}
}

function uitInitialization(id,url)
{
	document.getElementById('unit').value=id;
	document.frm_inital.action = url;
	document.frm_inital.submit();
}
function AutoCompleteReinitialize(event)
{ 
	var code = event.keyCode;
	if(code=='undefined'){code=event.which;}
	if(code==40) {
		var newObj =  actb(document.getElementById('autosearch'),customarray);
		addEvent(obj2,"keypress",newObj.actb_keypress());
	}
}

function showFirst()
{
	var _url="<a href='"+ $("#test1").attr("href") +"'>sh</a>";
	//_url.click();
}
function expirCookie()
{
    var new_date = new Date();
    new_date = new_date.toGMTString();
    var thecookie = document.cookie.split(";");
    for (var i = 0;i < thecookie.length;i++) 

    {
        document.cookie = thecookie[i] + "; expires ="+ new_date;
	}

}

function onClickSelect(src)
{
 if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
  {
	src.select(); 
  }	
} 

function check_character(obj){
		///
		var myString = obj.value;
	    var len=myString.length-1;
		var myStringT = "";
		var dot_count=0;
		var plus_count=0;
		var e_count=0;
		for(var i=0; i<=len;i++){
			if(myString[i]=='e')
			   e_count++;
			if(myString[i]=='+')
			   plus_count++;
			if(myString[i]=='.')
			  dot_count++;			 
			if(myString[i]>=0 && myString[i]<=9 && myString[i]!=" " || (myString[i]=='.' && dot_count <=1) || (myString[i]=='e' && e_count <=1) || (myString[i]=='+' && plus_count <=1))// alow numbers and dot (allow only one dot)

			{	
			myStringT=myStringT+myString[i];
			}
		}
		myStringT = myStringT.substring(0,100);	
		obj.value = myStringT;

}

function AlertMe(str)
{
	if(document.getElementById(str) !=="autosearch")
	{
		if (str=="from")
 		 document.getElementById('what').style.visibility="hidden";
	}
}
////date formatiing//
var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x) {return(x<0||x>9?"":"0")+x}

// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function isDate(val,format) {
	var date=getDateFromFormat(val,format);
	if (date==0) { return false; }
	return true;
	}

// -------------------------------------------------------------------
// compareDates(date1,date1format,date2,date2format)
//   Compare two date strings to see which is greater.
//   Returns:
//   1 if date1 is greater than date2
//   0 if date2 is greater than date1 of if they are the same
//  -1 if either of the dates is in an invalid format
// -------------------------------------------------------------------
function compareDates(date1,dateformat1,date2,dateformat2) {
	var d1=getDateFromFormat(date1,dateformat1);
	var d2=getDateFromFormat(date2,dateformat2);
	if (d1==0 || d2==0) {
		return -1;
		}
	else if (d1 > d2) {
		return 1;
		}
	return 0;
	}

// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate(date,format) {
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
	}
	
// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger(val) {
	var digits="1234567890";
	for (var i=0; i < val.length; i++) {
		if (digits.indexOf(val.charAt(i))==-1) { return false; }
		}
	return true;
	}
function _getInt(str,i,minlength,maxlength) {
	for (var x=maxlength; x>=minlength; x--) {
		var token=str.substring(i,i+x);
		if (token.length < minlength) { return null; }
		if (_isInteger(token)) { return token; }
		}
	return null;
	}
	
// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the 
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat(val,format) {
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var now=new Date();
	var year=now.getYear();
	var month=now.getMonth()+1;
	var date=1;
	var hh=now.getHours();
	var mm=now.getMinutes();
	var ss=now.getSeconds();
	var ampm="";
	
	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y") {
			if (token=="yyyy") { x=4;y=4; }
			if (token=="yy")   { x=2;y=2; }
			if (token=="y")    { x=2;y=4; }
			year=_getInt(val,i_val,x,y);
			if (year==null) { return 0; }
			i_val += year.length;
			if (year.length==2) {
				if (year > 70) { year=1900+(year-0); }
				else { year=2000+(year-0); }
				}
			}
		else if (token=="MMM"||token=="NNN"){
			month=0;
			for (var i=0; i<MONTH_NAMES.length; i++) {
				var month_name=MONTH_NAMES[i];
				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
					if (token=="MMM"||(token=="NNN"&&i>11)) {
						month=i+1;
						if (month>12) { month -= 12; }
						i_val += month_name.length;
						break;
						}
					}
				}
			if ((month < 1)||(month>12)){return 0;}
			}
		else if (token=="EE"||token=="E"){
			for (var i=0; i<DAY_NAMES.length; i++) {
				var day_name=DAY_NAMES[i];
				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
					i_val += day_name.length;
					break;
					}
				}
			}
		else if (token=="MM"||token=="M") {
			month=_getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){return 0;}
			i_val+=month.length;}
		else if (token=="dd"||token=="d") {
			date=_getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){return 0;}
			i_val+=date.length;}
		else if (token=="hh"||token=="h") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>12)){return 0;}
			i_val+=hh.length;}
		else if (token=="HH"||token=="H") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>23)){return 0;}
			i_val+=hh.length;}
		else if (token=="KK"||token=="K") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>11)){return 0;}
			i_val+=hh.length;}
		else if (token=="kk"||token=="k") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>24)){return 0;}
			i_val+=hh.length;hh--;}
		else if (token=="mm"||token=="m") {
			mm=_getInt(val,i_val,token.length,2);
			if(mm==null||(mm<0)||(mm>59)){return 0;}
			i_val+=mm.length;}
		else if (token=="ss"||token=="s") {
			ss=_getInt(val,i_val,token.length,2);
			if(ss==null||(ss<0)||(ss>59)){return 0;}
			i_val+=ss.length;}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
			else {return 0;}
			i_val+=2;}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
			else {i_val+=token.length;}
			}
		}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { return 0; }
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ return 0; }
			}
		else { if (date > 28) { return 0; } }
		}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { return 0; }

		}
	// Correct hours value
	if (hh<12 && ampm=="PM") { hh=hh-0+12; }
	else if (hh>11 && ampm=="AM") { hh-=12; }
	var newdate=new Date(year,month-1,date,hh,mm,ss);
	return newdate.getTime();
	}

// ------------------------------------------------------------------
// parseDate( date_string [, prefer_euro_format] )
//
// This function takes a date string and tries to match it to a
// number of possible date formats to get the value. It will try to
// match against the following international formats, in this order:
// y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d
// M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d
// d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M
// A second argument may be passed to instruct the method to search
// for formats like d/M/y (european format) before M/d/y (American).
// Returns a Date object or null if no patterns match.
// ------------------------------------------------------------------
function parseDate(val) {
	var preferEuro=(arguments.length==2)?arguments[1]:false;
	generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
	dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
	var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
	var d=null;
	for (var i=0; i<checkList.length; i++) {
		var l=window[checkList[i]];
		for (var j=0; j<l.length; j++) {
			d=getDateFromFormat(val,l[j]);
			if (d!=0) { return new Date(d); }
			}
		}
	return null;
	}

///end dating/////


