/*************************************************************************
	Desc  : Common Function/Variable definitions for public session
	Author: cengmezo (Mezahir Efendiyev)
	E-Mail: cengmezo@yahoo.com

**************************************************************************/

function j_public_common_alertContent ( divID ) {

	var obj = j_common_getElement (divID);

	if ( obj ) {
		obj = obj.innerHTML;
		obj = obj.replace ("[[NEWLINE]]" , "\n" );
		if ( obj ) {
			alert (obj);
		}
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function j_public_common_addToBookmark(bLink, bTitle) {
	if (document.all) {
		window.external.AddFavorite(bLink,bTitle);
	} else if (window.sidebar) {
		window.sidebar.addPanel(bTitle, bLink, "");
	}
}

function j_public_common_setAsHomePage(obj, hLink) {
	if (document.all) {
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(hLink);
	} else {
		// non IE
	}
}


// TAB SWITCH
var public_tabSwitch_prevTabObjs = new Array();
var public_tabSwitch_loadedLinks = new Array();

function j_public_tabSwitch (tObj, tGroup, tID, tLink, tClassNormal, tClassActive ) {

	if (tObj) {

		if (public_tabSwitch_prevTabObjs[tGroup]) {
			public_tabSwitch_prevTabObjs[tGroup].className = tClassNormal;
		}

		tObj.className = tClassActive;
	}


	if (public_tabSwitch_loadedLinks[tLink]) {

		obj = j_common_getElement(tID);
		if (obj) {
			obj.innerHTML = public_tabSwitch_loadedLinks[tLink];
		} else {
			alert ('Content div not found! ['+tID+']');
		}

	} else {

		// Show loading div

		var obj = j_common_getElement(tID+'_loading');
		if (obj) {
			obj.style.visibility = 'visible';
		}

		// Load ajax
		var xmlHttp = f_ajaxInit();

		xmlHttp.onreadystatechange=function() {

			if ( xmlHttp.readyState == 4 ) {

				if (tID) {

					var obj;
					obj = j_common_getElement(tID);
					if (obj) {
						obj.innerHTML = xmlHttp.responseText;
						public_tabSwitch_loadedLinks[tLink] = xmlHttp.responseText;
					} else {
						alert ('Content div not found! ['+tID+']');
					}

					obj = j_common_getElement(tID+'_loading');
					if (obj) {
						obj.style.visibility = 'hidden';
					}
				}
	        }
		}

		// Get link content
		xmlHttp.open("GET",tLink,true);
	    xmlHttp.send(null);
	}


	// Set current tab as prev tab
	if (tObj) {
		public_tabSwitch_prevTabObjs[tGroup] = tObj;
	}
}



function flashGetHref() { return location.href; }
function flashPutHref(href) {}
function flashGetTitle() { return document.title; }
function flashPutTitle(title) { document.title = title; }
