/**
 *
 * The purpose of creating this file was put all the commonly used scripts
 * in one common file.
 * 
 * The delevoper adding/editing the scripts on this file,
 * should mention the following:
 *
 * - Discription & Purpose of the script.
 * - Name of the files in which this file is called/included.
 * - developer name and date.
 *
 * fileName : r2i_common_scripts.js
*/

/**
 * This function resets the form.
 * The id 'resetFld' is given to img scr file.
 *
 * how to use : <img src="someimage" id="resetFld" /> will reset the form.
 *
 * Rakesh A :: 27-Jul-2009
*/
/**
$(document).ready(function () {
	$('img[id=resetFld]').click(function(){
		$(this).parent('form')[0]['reset']();
	});
});
*/
$(document).ready(function () {
	$('img#resetFld').click(function(){
			$('form').each(function(){
				this.reset();
		});
	});
});
/**
 * This function trims the string value passed to this function.
 *
 * While calling the ajax function, the 'responseText' contains
 * unnecessary spaces.
 *
 * how to use : trim(http.responseText).
 *
 * Rakesh A :: 30-Jul-2009
*/
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

/**
 * This function checks for ONLY numeric value.
 *
 * When we input any string value other than numeric value,
 * this function will remove it.
 *
 * how to use : onKeyUp="res(this,numb);".
 *
 * Rakesh A :: 30-Jul-2009
*/
var numb = "0123456789";
function res(t,v)
{
	var w = "";
	for(i=0; i < t.value.length; i++)
	{
		x = t.value.charAt(i);
		if(v.indexOf(x,0) != -1)
		w += x;
	}
	t.value = w;
}

/**
 * This function shows/hides content.
 *
 * This function will show/hide the content given inside the ID(rId),
 * depending on the arg passed.
 *
 * rId: id of the DIV/SPAN/TR/TD
 * arg: ON/OFF
 *
 * how to use : onClick="showHideC(rId,arg);".
 *
 * Rakesh A :: 02-Aug-2009
*/
function showHideC(rId,arg)
{
	if(arg == "OFF")
	{
		document.getElementById(rId).style.display = "none";
	}
	else
	{
		document.getElementById(rId).style.display = "block";
	}
}

/**
 * This function sets autocomplete to OFF in the form.
 *
 * how to use : include this js file in all the pages.
 *
 * Rakesh A :: 04-Aug-2009
*/
$(document).ready(function () {
	$('form').each(function(){
	$(this).attr("autocomplete","off");
	});
});

/**
 * This sets contextmenu(right-click), dragstart, selection of the page content to OFF in the form.
 *
 * how to use : include this js file in all the pages.
 *
 * Rakesh A :: 05-Aug-2009
*/
$(document).ready(function () {
	$(document).bind("contextmenu",function(e){
		return false;
	});
	$(document).bind("dragstart",function(e){
		return false;
	});
	$(document).bind("selectstart",function(e){
		return false;
	});
	// 24 May 2011 //
	$(".menu .offlast2, .menu #on2").hover(function(){
		$("#country_list").fadeIn()
		$(this).addClass('hover')
	}, function(){
		$("#country_list").hide();
		$(this).removeClass('hover')
		})
});
