/*!
 *	Defines Global pattern, the patterns are used by other objects
 */

var Pattern = new Object();
Pattern.intPattern = /^\d+$/;
////////////// END OF PATTERN DEFINITION ///////////////////////////

/*
 *	Dependent JS files
 *		js/common/utils/data_validator.js
 * */

var LoadingSign = new Function();
LoadingSign.img_src = "/data/images/common/site/loading_sign.gif";
LoadingSign.width=32;
LoadingSign.height=32;
LoadingSign.text = "Loading data...";

/*!
 *	Displays the loading sign as innerHTML of the given id
 */
LoadingSign.show = function(id,data,left_shift) {
	width = this.width;
	height = this.height;
	text = this.text;

	var position = "relative";
	if(isdefined(data) && (data instanceof Array)){
		if(isdefined(data['width'])) width = data['width'];
		if(isdefined(data['height'])) height = data['height'];
		if(isdefined(data['text'])) text = data['text'];
		if(isdefined(data['position'])) position = data['position'];
	}

	if(left_shift == undefined) left_shift = "0%";
	document.getElementById(id).innerHTML = "<div style='position:" + position + "; top:1%; left:" + left_shift + "' > " + 
														"<img src='" + this.img_src + "' width='" + width + "px' height='" + height + "px' style='vertical-align:middle;' > &nbsp;"
														+ text
														+ "</div>";
}

/*!
 *	\param id id from which loading sign needs to be removed
 */
LoadingSign.remove = function(id) {	
	if(document.getElementById(id)) { document.getElementById(id).innerHTML = ''; }
}

/////////////////////////////////////////////////////////////////////////
var DateFormat = new Function();

DateFormat.month_mapping = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
/*!
 *	Only supported format is yyyy-mm-dd hh:mm:ss
 */
DateFormat.format = function(date_value) {	
	date_value = DateFormat.getFirstPart(date_value);
	//split the date on '-'
	var date_array = date_value.split('-');
	if(date_array[0] == undefined) return '';

	//Get the month value
	if((date_array[1] == undefined) || (date_array[1] == "00") || (date_array[1] == "0")) return date_array[0];

	//convert date_array[1] to number
	date_array[1] *= 1;

	var day_str = "";
	//Get the date value
	if((date_array.length > 2) && date_array[2] != undefined) {
		var day_value = date_array[2] * 1;
		if(day_value > 0) {
			day_str = DateFormat.getDayStr(day_value) + " ";
		}
	}

	//convert the month to name
	return day_str + this.month_mapping[date_array[1]-1] + "," + date_array[0];
}

DateFormat.getFirstPart = function(date_value) {
	var date_array = date_value.split(" ");
	if(date_array[0] == undefined) return '';

	return date_array[0];
}

DateFormat.getDayStr = function(day_value) {
	if(day_value == 1 || day_value == 21 || day_value == 31) return day_value + "st";
	else if (day_value == 2 || day_value == 22) return day_value + "nd";
	else if (day_value == 3 || day_value == 23) return day_value + "rd";
	else return day_value + "th";
}

//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
///////		Time formatting functions /////////////////////////////////////
var TimeFormat = new Object();

TimeFormat.inMinsAndSecs = function(time_value) {
	//make sure time_value is set & defined
	if(time_value == undefined || time_value == null) return "";

	//check if time_value is not a numeric value. Convert value to str
	var str_time_value = time_value + "";
	if(!Pattern.intPattern.test(str_time_value)) return "";
	
	//get the secs part
	var secs = time_value % 60;
	var mins = parseInt( (time_value / 60) + "" );

	var hours = '';
	//convert to hours if mins more than > 120
	if(mins > 120) {
		hours = parseInt(mins/60 + "");
		mins = mins % 60;

		hours = hours + " hrs ";
	}

	var return_value = hours + mins + " mins";
	if(secs > 0) return_value += " " + secs + " secs";

	return return_value;
}

///////	End of Time formatting functions ////////////////////////////////

//////////////////////////////////////////////////////////////////////////
/*!
 *	Dependent JS files:
 *
 */
/*!
 *	Dependent css files:
 *		css/common/portal-features/portal-layout.css
 */
/*
 *	This block contructs next & previous links. You can use those to contruct the next & previous navigation
 *	How does it work:
 *		1. NextPrevious.init(max_value,elems_per_page,num_pages_to_show,img_urls)
 *		max_value = count of element present
 *		elems_per_page = number of elements per page
 *		num_pages_to_show = number of pages to show
 *		img_urls:
 *			=> next_active
 *			=> next_inactive
 *			=> last_active
 *			=> last_inactive
 *			=> prev_active
 *			=> prev_inactive
 *			=> first_active
 *			=> first_inactive
 *	
 *	 2. NextPrevious.load(div_id,callback_function,params_list)
 *	 		div_id : id of the div under which the content will be loaded
 *	 		callback_function: function to call when next, prev is clicked
 *	 		params_list: list of the params to be passed to function. This is an array
 */
function NextPrevious(name) {
	if(undefined != name) this.obj_name = name;
} 

var global_next_previous = new NextPrevious();
global_next_previous.objs_list = new Array();
global_next_previous.next_name = 1;

NextPrevious.prototype.init = function(max_value,elems_per_page,num_pages_to_show,img_urls) {
	if(max_value == undefined) {
		alert("max_value is mandatory field");
		return false;
	}

	this.max_value = max_value;
	this.elems_per_page = 5;
	if(elems_per_page != undefined) this.elems_per_page = elems_per_page * 1;

	this.num_pages_to_show = 5;
	if(num_pages_to_show != undefined) this.num_pages_to_show = num_pages_to_show * 1;

	//set the default valur of img_urls
	this.img_urls = new Array();
	this.img_urls['next_active'] = "/data/images/common/site/all/next_active.gif";
	this.img_urls['next_inactive'] = "/data/images/common/site/all/next_inactive.gif";
	this.img_urls['prev_active'] = "/data/images/common/site/all/prev_active.gif";
	this.img_urls['prev_inactive'] = "/data/images/common/site/all/prev_inactive.gif";
	this.img_urls['first_active'] = "/data/images/common/site/all/first_active.gif";
	this.img_urls['first_inactive'] = "/data/images/common/site/all/first_inactive.gif";
	this.img_urls['last_active'] = "/data/images/common/site/all/last_active.gif";
	this.img_urls['last_inactive'] = "/data/images/common/site/all/last_inactive.gif";

	//we are not allowing the functionality of settting the img_urls by user
	
	//find max_pages to show
	this.max_pages_to_show = Math.ceil(this.max_value / this.elems_per_page);

	this.left_pages_to_show = 0;
	this.right_pages_to_show = 0;
	//Find left, right & current pages to show
	var half_value = Math.floor(this.num_pages_to_show / 2);
	this.current_page = 1;
	if(this.num_pages_to_show % 2 != 0) {
		this.left_pages_to_show = this.right_pages_to_show = half_value;
	} else {
		this.left_pages_to_show = half_value-1;
		this.right_pages_to_show = half_value;
	}
	
	//validate the values
	if(this.left_pages_to_show < 0) this.left_pages_to_show = 0;
	if(this.right_pages_to_show < 0) this.right_pages_to_show = 0;

	if(this.current_page > this.max_pages_to_show ) this.current_page = this.max_pages_to_show;

	var name ;
	if(this.obj_name != undefined) name = this.obj_name;
	else {
		name = global_next_previous.next_name;
		global_next_previous.next_name++;
		this.obj_name = name;
	}
	global_next_previous.objs_list[name] = this;

	return true;
}

NextPrevious.prototype.load = function(div_id,callback_function,params_list) {
	if(this.div_id == undefined) this.div_id = div_id;
	if(this.callback_function == undefined) this.callback_function = callback_function;
	if(this.params_list == undefined) this.params_list = params_list;

	//Find available pages on left & right side
	var pages_on_left_side = this.current_page - 1;
	var pages_on_right_side = this.max_pages_to_show - this.current_page;

	//set left & right indicators
	var left_pos = 0;
	var right_pos = 0;
	var left_overflow_pages = 0;
	var left_overflow = false;
	if(this.left_pages_to_show > pages_on_left_side) {
		//enough pages are not there
		left_overflow = true;
		//Find the overflow value
		left_overflow_pages = this.left_pages_to_show - pages_on_left_side;
		left_pos = 1;
	} else {
		//there are enough pages on the left side
		left_pos = this.current_page - this.left_pages_to_show;
	}

	if(this.right_pages_to_show > pages_on_right_side) {
		//overflow on right side
		//check if the overflow didn't happen on left side
		if(!left_overflow) {
			left_pos -= (this.right_pages_to_show - pages_on_right_side);
		}
		right_pos = this.current_page + this.right_pages_to_show;
	} else {
		//no overflow on right side
		right_pos = this.current_page + this.right_pages_to_show;
		//check if there was an overflow on left side
		if(left_overflow) right_pos += left_overflow_pages
	}

	//validate left_pos & right_post
	if(left_pos < 1) left_pos = 1;
	if(right_pos > this.max_pages_to_show) right_pos = this.max_pages_to_show;

	var a_prefix = '';
	var a_suffix = '';
	var prev_onclick = '';
	var first_onclick = '';

	var html_content = "<table class='no_border' style='margin-left:auto;margin-right:auto;'><tr>";
	var prev_image = this.img_urls['prev_active'];
	var first_image = this.img_urls['first_active'];
	if(this.current_page == 1) {
		prev_image = this.img_urls['prev_inactive'];
		first_image = this.img_urls['first_inactive'];
	} else {	
		a_prefix = ""; a_suffix = "";
		var prev_value = this.current_page - 1;
		prev_onclick = "global_next_previous.setNewCurrent(\"" + this.obj_name + "\"," + prev_value + ")";
		first_onclick = "global_next_previous.setNewCurrent(\"" + this.obj_name + "\",1)";
	}

	html_content += "<td class='navigation_inactive_td' style='cursor:pointer;' onclick='" + first_onclick + "'>" + a_prefix + " <img src='" + first_image + "'>" + a_suffix + " </td>";
	html_content += "<td class='navigation_inactive_td'  style='cursor:pointer;' onclick='" + prev_onclick + "'>" + a_prefix + " <img src='" + prev_image + "'>" + a_suffix + " </td>";

	//display the html now
	for(var i= left_pos; i<=right_pos; i++) {
			var td_class = '';
			//set a class
			a_prefix = '';
			a_suffix = '';
			var onclick_method = '';
	
			if(i != this.current_page) {
				a_prefix = "<a href='' onclick='return false;'>";
				onclick_method = "global_next_previous.setNewCurrent(\"" + this.obj_name + "\"," + i + ")";
				td_class = "navigation_active_td";
				a_suffix = "</a>";
			}
			else td_class = "navigation_inactive_td";
	
			var extra_content = '';
			if(i == right_pos) extra_content = "...";
			html_content += "<td valign='top' class='" + td_class + "' onclick='" + onclick_method + "'>" + a_prefix + i + extra_content + a_suffix + "</a></td>";
	}

	var next_onclick = '';
	var last_onclick = '';

	var next_image = this.img_urls['next_active'];
	var last_image = this.img_urls['last_active'];
	if(this.current_page == this.max_pages_to_show) {
		next_image = this.img_urls['next_inactive'];
		last_image = this.img_urls['last_inactive'];
	} else {	
		a_prefix = "";
		a_suffix = "";
		var next_value = this.current_page + 1;
		next_onclick = "global_next_previous.setNewCurrent(\"" + this.obj_name + "\"," + next_value + ")";
		last_onclick = "global_next_previous.setNewCurrent(\"" + this.obj_name  + "\"," + this.max_pages_to_show + ")";
	}

	html_content += "<td class='navigation_inactive_td'  style='cursor:pointer;' onclick='" + next_onclick + "'>" + a_prefix + " <img src='" + next_image + "'>" + a_suffix + " </td>";
	html_content += "<td class='navigation_inactive_td'  style='cursor:pointer;' onclick='" + last_onclick + "'>" + a_prefix + " <img src='" + last_image + "'>" + a_suffix + " </td>";

	html_content += "</tr></table>";
	//display the html_content
	document.getElementById(this.div_id).innerHTML = html_content;

}

global_next_previous.setNewCurrent = function(name,current_page) {
	//get the object
	var obj = global_next_previous.objs_list[name];
	obj.current_page = current_page;
	obj.load();
	var index = (obj.current_page-1) * obj.elems_per_page + 1;
	obj.callback_function(index,obj.elems_per_page,obj.params_list);
}

////////////////////////////////////////////////////////////////////////////////
function JSONToObject(text) {
	return eval('('+ text + ')');
}

//////////////////////////////////////////////////////////
//	DataFormatting functions /////////////////////////////
//////////////////////////////////////////////////////////
DataFormat = new Object();

/**
 *	\brief format the input as integer
 *	
 *	\param input_data
 */
DataFormat.formatInt = function (input_data) {
	//check if input_data is set or not
	if(input_data == undefined || input_data == null) return 0;
	//check if input data is a valid integer
	var output_data = parseInt(input_data);
	if(isNaN(output_data)) return 0;
	return output_data;
}

/*!
 * Dependent JS
 *	js/common/utils/data_validator.js
 */

/*!
 * Dependent CSS
 * css/common/portal-features/portal-layout.css
 */

var generic_error = new Function();
generic_error.error_list = new Array();

generic_error.show = function(name) {
	return this.error_list[name];
}

generic_error.error_list['ajax_url-main_content'] = "We are facing some issues and are not able to proceed. Please check back later";
generic_error.error_list['ajax_url-unimportant'] = "We are facing some issues in this section. Please check back later";
generic_error.error_list['data_not_present'] = "We don't have any data for this request. Please check back later";
generic_error.error_list['no_quiz_taken'] = "You haven't taken any quiz";

generic_error.showErrorMsg = function(error_type,error_msg, selected_div) {
	if(!isdefined(error_type)) error_type = "ajax_url-unimportant";
	var msg = error_msg;
	if(!isset(msg))  msg = generic_error.show(error_type);
	if(!isdefined(msg)) msg = generic_error.show("ajax_url-unimportant");

	if(!isdefined(selected_div)) selected_div = global_selected_div;
	if(isdefined(selected_div)) document.getElementById(selected_div).innerHTML = "<font class='error_content'><br/>" + msg + "<br/><br/></font>";
}


///////////////////////////////////////////////////////////////////////
///	Function specific to Test Center functionality of portal //////////
///////////////////////////////////////////////////////////////////////

var TestCenter = new Object();

TestCenter.horizontalTabAdditionalLink = function(selection_key,function_name,element_id) {
	var html = "<a class='section_subject_toggle' href='' onclick='" + function_name + "(";

	//check the type of analysis
	var text='';
	var analysis_type = "";

	if(selection_key == "section") {
		text = "Show analysis by Subjects";
		analysis_type = "subject";
	} else {
		text = "Show analysis by Sections";
		analysis_type = "section";
	}

	html += "\"" + analysis_type + "\");return false;'>" + text;
	html += "</a>";

	document.getElementById(element_id).innerHTML = html;
}

//////////////////////////////////////////////////////////////////////
//////////	Auxillary functions //////////////////////////////////////
//////////////////////////////////////////////////////////////////////

var AuxillaryFunctions =new Object();
AuxillaryFunctions.classAppender = function(input_class) {
	if(navigator.appName == "Microsoft Internet Explorer") {
			var browser_version = parseInt(navigator.appVersion); 
			if(browser_version <= 6) return input_class + "_ie_hack";
	}

	return input_class;
}

AuxillaryFunctions.getMousePos = function(e) {
	var posx = 0;
	var posy = 0;
	if( window.event) e = window.event;

	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}

	alert(posx + "-" + posy);
	return Array(posx, posy);
}

AuxillaryFunctions.findElementPos = function(id) {
	var obj = document.getElementById(id);

	var left=obj.offsetLeft;
	var top=obj.offsetTop;
	while(obj.offsetParent) {
		obj = obj.offsetParent;
		left += obj.offsetLeft;
		top += obj.offsetTop;
	}

	return Array(left,top);
}

AuxillaryFunctions.roundToGivenDecimalPoints = function(value, decimal_points) {
	var num = 1;
	for(var i=0; i<decimal_points; i++) num *= 10;

	return (Math.round(value * num) / num);
}

AuxillaryFunctions.openURLInLimitedWindow = function(url) {
	window.open(url, "new_window", ',type=fullWindow,fullscreen,scrollbar=yes')
}

AuxillaryFunctions.sendAjaxRequest = function (url) {
	try {
		xml_http = new XMLHttpRequest();
	} catch (e) {
		xml_http = new ActiveXObject("Msxml2.XMLHTTP");
	}

	var d1 = new Date();
	if(url.match(/\?.*\=.*$/)) url = url + "&time=" + d1.getTime();
	else if(url.match(/\?$/)) url = url + "time=" + d1.getTime();
	else url = url + "?time=" + d1.getTime();

	//send the request
	xml_http.open("GET",url,false);
	xml_http.send(null);
	var return_data = xml_http.responseText;
	if(!isset(return_data)) return null;
	return  eval('('+ return_data + ')'); 
}

/////////////////////////////////////////////////////////////
//				GET/SET HTML ELEMENTS
/////////////////////////////////////////////////////////////

var HtmlElement = {};
HtmlElement.getRadioButtonValue = function(name) {
	if(null == name || undefined == name) return "";
	var nodes_list = document.getElementsByName(name);
	if(nodes_list.length == 0) return "";

	for(var i=0; i<nodes_list.length; i++) {
		if(nodes_list[i].checked) return nodes_list[i].value;
	}

	return "";
}

HtmlElement.setRadioButtonValue = function(name, value) {
	if(null == name || undefined == name) return "";
	var nodes_list = document.getElementsByName(name);
	if(nodes_list.length == 0) return "";

	for(var i=0; i<nodes_list.length; i++) {
		if(nodes_list[i].value == value) nodes_list[i].checked=true;
	}

	return "";
}

/*!
 *	This function will go over all the radio button which share the passed name
 *	For each radio button, we will check if it is selected, if yes than we will clear it
 */
HtmlElement.clearRadioButton = function(name) {
	if(null == name || undefined == name) return "";
	var nodes_list = document.getElementsByName(name);
	if(nodes_list.length == 0) return "";

	for(var i=0; i<nodes_list.length; i++) {
		if(nodes_list[i].checked) {
			nodes_list[i].checked = false;
		}
	}

	return "";

}

HtmlElement.isEmpty = function(obj) {
	if(null == obj || undefined == obj) return true;
	
	//convert obj to string
	var str = obj + "";
	//apply regex on str
	if(str.match(/^\s*$/)) return true;

	return false;
}

/*!
 *	Check if the given key exist in the arr_ref
 */
HtmlElement.isKeyExist = function(key_name, arr_ref) {
	if(key_name in arr_ref) return true;
	return false;
}

/*!
 * \param combo_id ID of the combo element (select element)
 * \param combo_data ref to an associative array containing data.
 * 	If combo has two values as : <option value='1'>key1</option> <option value='2'>key2</option>
 * 	then combo_data = [
 * 		0 => {
 * 			'key'=>1,
 * 			'value'=>key1
 * 		}
 * 		1 => same as 0
 * 	]
 *  \param key_name Name of the key which contains the value='1' in it. For the above case, key_name = 'key'
 *  \param value_name Name of the key which contains value 'key1'. For the above case, value_name = 'value'
 */
HtmlElement.fillCombo = function (combo_name,combo_data,key_name,value_name) {
	//check if combo_data is set
	if(combo_data.length == 0) {
		//alert("No data received to set combo box: " + combo_name);
		return false;
	}

	//remove current elements from combo_name
	var combo = document.getElementById(combo_name);
	var len = combo.options.length;
	for(i=len-1;i>=0;i--) {
			combo.remove(i);
	}

	//add new options to combo
	len = combo_data.length;
	for(i=0;i<len;i++) {
		combo.options.add(new Option(combo_data[i][value_name],combo_data[i][key_name]));
	}

	return true;
}

/*!
 *	\param combo_name name of the combo box to be deleted
 */
HtmlElement.deleteCombo = function(combo_name) {
	//remove current elements from combo_name
	var combo = document.getElementById(combo_name);
	var len = combo.options.length;
	for(i=len-1;i>=0;i--) {
			combo.remove(i);
	}
}

HtmlElement.getComboSelectedValue = function(combo_id) {
	//get the combo object
	var combo_obj = document.getElementById(combo_id);
	var sel_index = combo_obj.selectedIndex;
	if(sel_index > -1) {
		return combo_obj.options[sel_index].text;
	}

	return "";
}

HtmlElement.getComboSelectedKey = function(combo_id) {
	//get the combo object
	var combo_obj = document.getElementById(combo_id);
	var sel_index = combo_obj.selectedIndex;
	if(sel_index > -1) {
		return combo_obj.options[sel_index].value;
	}

	return "";
}

HtmlElement.setComboSelectedKey = function(combo_id,key) {
	//get the combo object
	var combo_obj = document.getElementById(combo_id);
	var len = combo_obj.options.length;
	for(i=0;i<len;i++) {
		if(combo_obj[i].value == key) combo_obj.selectedIndex = i;
	}
}
/*!
 *	A very generic function 
 *	It makes a call to given ajax and then fill the combo_name with the results
 *	Ajax call response: 
 *	In case of success, format => {'data'=> [{key1=>val1}, {key2=>val2}, {key3=>val3}]}
 *	In case of error, format => {'error'=>'error_str'}
 */
HtmlElement.fillComboAfterAjax = function(combo_name, ajax_call, two_key) {
	//make ajax call
	var response = AuxillaryFunctions.sendAjaxRequest(ajax_call);
	if(null == response) {
		alert("Not able to get data for " + combo_name);
		return;
	}

	//validate response
	if(HtmlElement.isKeyExist('error', response) || !HtmlElement.isKeyExist('data', response)) {
		alert("Not able to get data for " + combo_name);
		return;
	}
	
	//get the data
	var data = response['data'];
	if(data.length == 0) return;

	if(null == two_key) two_key = true;

	//construct the combo fields
	var combo_data = new Array();
	for(var i=0;i<data.length;i++) {
			combo_data[i] = new Array();
			combo_data[i]["key"] = data[i][0];

			if(two_key) combo_data[i]["value"] = data[i][1];
			else combo_data[i]["value"] = combo_data[i]["key"];
	}

	HtmlElement.fillCombo(combo_name,combo_data,"key","value");
}

HtmlElement.createDayArrayForCombo = function() {
	var day_arr = new Array();

	day_arr[0] = new Array();
	day_arr[0]["key"] = "DD";
	day_arr[0]["value"] = "DD";

	for(var i=1; i<=31; i++) {
		day_arr[i] = new Array();
		day_arr[i]["key"] = i;
		day_arr[i]["value"] = i;
	}

	//return day_arr
	return day_arr;
}

HtmlElement.createMonthArrayForCombo = function() {
	var month_arr = new Array();

	month_arr[0] = new Array();
	month_arr[0]["key"] = "MM";
	month_arr[0]["value"] = "MM";

	for(var i=1; i<=12; i++) {
		month_arr[i] = new Array();
		month_arr[i]["key"] = i;
		month_arr[i]["value"] = i;
	}

	return month_arr;
}

HtmlElement.createYearArrayForCombo = function() {
	var year_arr = new Array();

	//we should take last 30 years
	var d = new Date();
	var current_year = d.getFullYear() + 0;

	var count=0;
	year_arr[count] = new Array();
	year_arr[count]["key"] = "YYYY";
	year_arr[count]["value"] = "YYYY";
	count++;

	for(var i=current_year-40; i<=current_year; i++) {
		year_arr[count] = new Array();
		year_arr[count]["key"] = i;
		year_arr[count]["value"] = i;
		count++;
	}

	return year_arr;
}

HtmlElement.isset = function(input_val) {
	if(input_val == false || (input_val == undefined) || (input_val == null)) return false;

	return true;
}

HtmlElement.newWindow  = function(url) {
	if(HtmlElement.isEmpty(url)) return;
        if(navigator.appName=="Netscape")window.open(url);
	else window.open(url,'_blank','fullscreen=yes,resizable=1');
}

HtmlElement.parseRequest = function(text) {
	//parse the req
	if(text == undefined || text == null || text.match('/^\s*$/')) return false;
	return eval('('+ text + ')');
}
/*
 * Functions related to flash component
 * */
var FlashComponent = {};
FlashComponent.getSWFName = function(div_id) {
	if (navigator.appName.indexOf("Microsoft")!= -1) {
		return window[div_id];
	} else {
		return document[div_id];
	}
}


