/**
* Function to emulate document.getElementById
*
* @param	string	Object ID
*
* @return	mixed	null if not found, object if found
*/
function fetch_object(idname)
{
	if (document.getElementById)
	{
		return document.getElementById(idname);
	}
	else if (document.all)
	{
		return document.all[idname];
	}
	else if (document.layers)
	{
		return document.layers[idname];
	}
	else
	{
		return null;
	}
}
/**
* Function to emulate document.getElementsByTagName
*
* @param	object	Parent tag (eg: document)
* @param	string	Tag type (eg: 'td')
*
* @return	array
*/
function fetch_tags(parentobj, tag)
{
	if (typeof parentobj.getElementsByTagName != 'undefined')
	{
		return parentobj.getElementsByTagName(tag);
	}
	else if (parentobj.all && parentobj.all.tags)
	{
		return parentobj.all.tags(tag);
	}
	else
	{
		return null;
	}
}

/**
* Opens a generic browser window
*
* @param	string	URL
* @param	integer	Width
* @param	integer	Height
* @param	string	Optional Window ID
*/
function openWindow(url, width, height, windowid)
{
	return window.open(
		url,
		(typeof windowid == 'undefined' ? 'Popup' : windowid),
		'statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=no'
		+ (typeof width != 'undefined' ? (',width=' + width) : '') + (typeof height != 'undefined' ? (',height=' + height) : '')
	);
}


function modi_font_color(arg_strColorCode,arg_strSourceString)
{
	return  '<font color=\''+arg_strColorCode+'\'><b>'+arg_strSourceString+'</b></font>'
}

/**
* ASP Function Emulator Class
**/

function azure_ASP_Emulator()
{
}

/**
* Trims leading whitespace
*
* @param	string	String to trim
*
* @return	string
*/
azure_ASP_Emulator.prototype.ltrim = function(str)
{
	return str.replace(/^\s+/g, '');
}

/**
* Trims trailing whitespace
*
* @param	string	String to trim
*
* @return	string
*/
azure_ASP_Emulator.prototype.rtrim = function(str)
{
	return str.replace(/(\s+)$/g, '');
}

/**
* Trims leading and trailing whitespace
*
* @param	string	String to trim
*
* @return	string
*/
azure_ASP_Emulator.prototype.trim = function(str)
{
	return this.ltrim(this.rtrim(str));
}
azure_ASP_Emulator.prototype.urlencode = function(text)
{
	text = text.toString();
	var matches = text.match(/[\x90-\xFF]/g);
	if (matches)
	{
		for (var matchid = 0; matchid < matches.length; matchid++)
		{
			var char_code = matches[matchid].charCodeAt(0);
			text = text.replace(matches[matchid], '%u00' + (char_code & 0xFF).toString(16).toUpperCase());
		}
	}
	return escape(text).replace(/\+/g, "%2B");
}
//object of ASP init
var ASP = new azure_ASP_Emulator();

function azure_Hidden_Form(arg_blnIsCreateNewForm,arg_strTargetScript)
{
	if (arg_blnIsCreateNewForm)
	{
		this.form = document.createElement('form');
		this.form.method = 'post';
		this.form.action = arg_strTargetScript;		
	}
}
azure_Hidden_Form.prototype.add_input = function(arg_objForm,arg_strName,arg_strvalue)
{
	var inputobj = document.createElement('input');
	inputobj.type = 'hidden';
	inputobj.name = arg_strName;
	inputobj.value = arg_strvalue;
	arg_objForm.appendChild(inputobj);
}

function getbrowser()
{
	var browser = "" ;
	window.env = new function()
	{
		this.Opera	= (window.opera && navigator.userAgent.match(/opera/gi)) ? true : false;
		this.IE		= (!this.Opera && document.all&&navigator.userAgent.match(/msie/gi)) ? true : false;
		this.Safari	= (!this.IE&&navigator.userAgent.match(/safari/gi)) ? true : false;
		this.Gecko	= (!this.IE&&navigator.userAgent.match(/gecko/gi)) ? true : false;
		this.Firefox= (!this.IE&&navigator.userAgent.match(/firefox/gi)) ? true : false;			
	};
	for (var i in env) {
		if (env[i])
		{
			browser = i;
		}
	}
	if (browser == "")
	{
		browser = "IE";
	}
	return browser;
}