/*!
 * CKBE Common Functions
 * http://www.ckbe.com/
 *
 * Copyright 2011, CKBE
 * All Rights Reserved.
 *
 * Requires jQuery JavaScript Library v1.4.2
 * Copyright 2010, John Resig
 * http://www.jquery.com/
 * Released under the MIT or GPL Version 2 licenses.
 *
 * Date: Sun Jun 06 18:57:26 2010
 */

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Value Functions.

function ckbeCommon_getValue_browser() {
	
	var _browser = null;
	
	if ($.browser.webkit) {
		_browser = "webkit";
	}
	
	if ($.browser.msie) {
		_browser = "msie";
	}
	
	if ($.browser.opera) {
		_browser = "opera";
	}
	
	if ($.browser.mozilla) {
		_browser = "mozilla";
	}
	
	var _version = parseFloat($.browser.version);
	
	return { browser: _browser, version: _version };
	
}

function ckbeCommon_getValue_position(obj) {
	
	var _x = 0;
	var _y = 0;
	
	while(obj) {
	
		_x += obj.offsetLeft;
		_y += obj.offsetTop;
		obj = obj.offsetParent;
	
	}
	
	return { x: _x, y: _y };
	
}

function ckbeCommon_getValue_dimension(obj) {
	
	var _w = 0;
	var _h = 0;
	
	_w = obj.offsetWidth;
	_h = obj.offsetHeight;
	
	return { w: _w, h: _h };
	
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Text Functions.

function ckbeCommon_text_stringReplace(str, txt, rpl) {
	
	var t = new RegExp(txt, 'g');
	var text = str.replace(t, rpl);
	
	return text;
	
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Create Functions.

function ckbeCommon_create_ID() {
	
	var now = new Date();
	var year = now.getFullYear();
	var month = now.getMonth();
	var day = now.getDate();
	var hour = now.getHours();
	var minute = now.getMinutes();
	var second = now.getSeconds();
	var millisecond = now.getMilliseconds();
	
	var id = "JS" + year + "" + month + "" + day + "" + hour + "" + minute + "" + second + "" + millisecond;
	
	return id;
	
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Prompt Functions.

function ckbeCommon_promptConfirm(message, url) {
	
	var ask = confirm(message);
	
	if (ask == true) {
		window.location.href = url;
	}
	
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Window Functions.

function ckbeCommon_windowModal(address, width, height) {
	
	var left = (screen.width / 2) - (width / 2);
	var top = (screen.height / 2) - (height / 2);
	
	if (window.showModalDialog) {
		
		var arguments = {opener:self, name:'mWindow'};
		
		window.showModalDialog(address, arguments, 'dialogWidth:' + width + 'px; dialogHeight:' + height + 'px; dialogLeft:' + left + 'px; dialogTop:' + top + 'px; scroll:no; help:no; status:no;');
		
	} else {
		
		window.open(address, 'mWindow', 'width=' + width + ', height=' + height + ', left='  + left + ', top=' + top + ', toolbar=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, modal=yes');
		
	}
	
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Frame Functions.

function ckbeCommon_frameSet(frm, url) {
	
	frm = document.getElementById(frm);
	frm.contentWindow.location.replace(url);
	
}
