//-- lib.js: Core JS library for www.oracle.com
//pukken: add  this variable whenever lib.js changes You need to change it to production before you push out this file on production
//var EBIZ_ENV = "prd";
//var EBIZ_ENV = "stg";
var EBIZ_ENV = "dev";

var orainfo_exists = false, otnnm_exists = false
var langjsLoad  = false, confirm_is_redirect  = false, survey_is_passthru = false
var dash 		= '<img src="/admin/images/dash.gif" border=0 width=150 height=5>'
var r_arrow 	= '<img src="/admin/images/r_arrow.gif" border=0 width=10 height=10>'
var d_arrow 	= '<img src="/admin/images/d_arrow.gif" border=0 width=10 height=10>'
var tl_img		= '<img src="/admin/images/tl_img.gif" border=0 width=4 height=18>'
var bl_img		= '<img src="/admin/images/bl_img.gif" border=0 width=4 height=6>'
var tr_img		= '<img src="/admin/images/tr_img.gif" border=0 width=4 height=18>'
var br_img		= '<img src="/admin/images/br_img.gif" border=0 width=4 height=6>'
var l_crnr 		= '<img src="/admin/images/rc_lft.gif" width=4 height=20>'
var r_crnr 		= '<img src="/admin/images/rc_rt.gif" width=4 height=20>'
var see_image 	= '<img src="/admin/images/see.gif" width=100 height=25 border=0>'
var try_image 	= '<img src="/admin/images/try.gif" width=100 height=25 border=0>'
var buy_image 	= '<img src="/admin/images/buy.gif" width=93 height=35 border=0>'
var block 		= ''

//-- Determine Frame status
var isFramed = false
if (parent.frames.length != 0) var isFramed = true

//-- Cookie Objects
var ORA_UCM_VER;
var ORA_UCM_INFO;
var ORA_UCM_SRVC;
var ORA_UCM_CMP;
var user_info = new Array()
var otn_info  = new Array()
var FNAME=0, LNAME=1, TITLE=2, EMAIL=3, UID=4
var ROLE=5, Q2=6, Q3=7, Q4=8, Q5=9, OWNER=10
var OTN_UID=0, OTN_IP=1, OTN_LVL=2
var OPP_LVL=3, OPP_PIN=4

//-- Utility function defs
var min = (60 * 1000)
var hour = (60 * min)
var day = (24 * hour)
var year = (365 * day)

//-- Portlet Style defs
var PLAIN = 3, WWW = 2
var portlet_title1 = "", portlet_title2 = ""

// Campaign Style Defs
var INLINE = 2, WRAPPED = 4

//-- Internal/external Adjustments
if (location.hostname.indexOf("us.oracle.com") != -1) {
	var ora_host 	= "http://www-stage.us.oracle.com"
	var otn_host 	= "http://larva.us.oracle.com:88"
	var odp_host 	= "http://profile-mktas.oracle.com"
	var auth_host 	= "http://profile-mktas.oracle.com"
	var apps_host 	= "http://www-stage.oracle.com/appsnet"
	var bol_host 	= "http://businessonline-stage.us.oracle.com"
	var oln_host 	= "http://www-stage.us.oracle.com/education/oln"
	var iln_host 	= "http://ilearning.oracle.com"
	var moc_host	= "http://my.oracle.com"
	var opn_host	= "http://partner-java-stage.us.oracle.com"
	var search_dad  = "/pls/use/";
	var emkt_host  = "http://emarketing.oraclecorp.com/pls/cms/";
} else {
	var ora_host 	= "http://www.oracle.com"
	var otn_host 	= "http://technet.oracle.com"
	var odp_host 	= "https://profile.oracle.com"
	var auth_host 	= "https://profile.oracle.com"
	var apps_host 	= "http://appsnet.oracle.com"
	var bol_host 	= "http://www.businessonline.com"
	var oln_host 	= "http://www.oracle.com/education/oln"
	var iln_host 	= "http://ilearning.oracle.com"
        var moc_host	= "http://my.oracle.com"
	var opn_host	= "http://partner.oracle.com"
	var search_dad  = "/pls/use/";
	var emkt_host  = "http://www.oracle.com";
}

//-- Function Library
function stretch(w, h) {
	return '<img src="' + ora_host + '/admin/images/stretch.gif" width=' + w + ' height=' + h + ' BORDER=0>';
}

//-- Window Types
var TOP = 0, NEWS = 1, OTHER = 2, FULL = 3
var warnMsg = "The channel you have selected is available to registered users only.\n\nPlease register or sign in."
var warnSrvc = "Service Required Message."
var warnURL = "/ebusinessnetwork/register.html"
var warnSrvcURL = "/admin/account/index.html"
function promptUser(msgID) {
	if (!msgID) msg = warnMsg;
	else if (msgID = 1){
		msg = warnMsg;
		wurl = warnURL;
	}
	else if (msgID = 2){
		msg = warnSrvc;
		wurl = warnSrvcURL;
	}
	if (confirm (msg))top.location = wurl;
	else return;
}

function goCheck(url, type, srvc) {
	if (!type || type == "") type = TOP;	
	if (!orainfo_exists) promptUser(1);
	else {
		if (srvc){
			if (ORA_UCM_SRVC.services.indexOf("/" + srvc + "/") == -1) promptUser(2);
		}
		else {
			if (type == TOP) top.location = "./" + url
			else if (type == NEWS) window.open(url, "newsWin",  "resizable,scrollbars,width=460,height=575,top=0,screenY=0,left=0,screenX=0");
			else if (type == OTHER) window.open(url, "otherWin", "resizable,scrollbars,width=350,height=525,top=0,screenY=0,left=0,screenX=0");
			else if (type == FULL) window.open(url, "fullWin");
		}
	}
}

function goWin(url, type, w, h, scroll) {
	if (!type || type == "") type = 1;
	if (type == 1) top.location = "./" + url;
	else if (type == 2) window.open(url, "smallWin", "toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=" + scroll + ",width=" + w + ",height=" + h + ",top=0,screenY=0,left=0,screenX=0");
	else if (type == 3) window.open(url, "fullWin");
}

function goOLN() {
              	ORA_UCM_VER   = top.ORA_UCM_VER;
	ORA_UCM_INFO  = top.ORA_UCM_INFO;
	ORA_UCM_SRVC  = top.ORA_UCM_SRVC;
	if (!isUCMRegistered()) {
		location = "/admin/account/oln/oln_login.html";
	}
               else if (top.ORA_UCM_SRVC.services.indexOf("/OLN/") == -1)  
                {
                      if(top.ORA_UCM_SRVC.services.indexOf("/EMP/") == -1)  
                     {
                               location = "/admin/account/oln/oln_msg.html";
                      }  else
                      {
                                 var ilnwin = window.open(iln_host, "iln", "toolbar=1,location=1,directories=1,status=1,menubar=1,resizable=1,scrollbars=1,width=800,height=600");		
                                top.location = "/education/oln/index.html";
		ilnwin.focus();
                      }
                      
	}
                else
                {
                               var ilnwin = window.open(iln_host, "iln", "toolbar=1,location=1,directories=1,status=1,menubar=1,resizable=1,scrollbars=1,width=800,height=600");		
                                top.location = "/education/oln/index.html";
		ilnwin.focus();
	}
}

function taf() {
	var taf_URL = "http://www.oracle.com/admin/account/promo/mail.html";
	var mailwin = window.open(taf_URL, "Mail", "HEIGHT=500,WIDTH=500,status,resizable");
}

function fix_action(host, form, action){
	form.action = host + action;
	return true;
}

function getName(){
	if (isUCMRegistered()) return ORA_UCM_INFO.firstname + " " + ORA_UCM_INFO.lastname;
	else return "";
}

function getUID(){
	if (isUCMRegistered()) return ORA_UCM_INFO.username;
	else return "";
}

function getArg(arg_name, str) {
	var value = "", tmpstr = "";
	if (!str) str = location.search.substring(1);
	if (!str) return value;
	else {
		var tmparray = str.split("&");
		for (i=0; i<tmparray.length; i++) {
			tmpstr = tmparray[i].toUpperCase();
			if (tmpstr.indexOf(arg_name.toUpperCase() + "=") != -1) {
				var tmp2array = tmparray[i].split("=");
				value = tmp2array[1];
			}
		}
	}
	return value;
}

function signout(url) {
	var exp = new Date();
	exp.setYear(70);
	var exp_str = "expires=" + exp.toGMTString() + "; domain=.oracle.com; path=/;";
	document.cookie = "ORA_UCM_VER=;" + exp_str;
	document.cookie = "ORA_UCM_INFO=;" + exp_str;
	document.cookie = "ORA_UCM_SRVC=;" + exp_str;
	top.location = url;
}

//-- Get and Set Language based information
//-- This can be moved to lang.js file when ready
var language_root  	= "";
var print_label    	= "Printer View";
var mail_label     	= "Tell a Friend";
var mail_URL		= "/admin/account/mail.html";
var rate_label     	= "Rate this Page";
var rate_URL		= "/admin/account/rate.html";
var salesrep_label  = "Contact a Sales rep";
var salesrep_URL	= "/admin/account/sales.html";
var subscribe_label	= "Subscribe"
var subscribe_URL	= "/subscribe/subscribe_smallwindow.html";
var glossary_label	= "Glossary"
var glossary_URL	= "/admin/glossary.html";

// UCM Cookie Libraries ----------------------------------------------------- //
function existsUCMCookie(s) {
	if (s == "ORA_UCM_VER") {
		if ((ORA_UCM_VER.value != null) &&
			(ORA_UCM_VER.version != null) &&
			(ORA_UCM_VER.username != null) &&
			(ORA_UCM_VER.username_enc != null) &&
			(ORA_UCM_VER.ipaddress != null) &&
			(ORA_UCM_VER.ipaddress_enc != null) ) {
		return true;
		}
	}
	else if (s == "ORA_UCM_INFO") {
		if ((ORA_UCM_INFO.version != null) &&
			(ORA_UCM_INFO.guid != null) &&
			(ORA_UCM_INFO.username != null)) {
		return true;
		}
	}
	else if (s == "ORA_UCM_SRVC") {
		if ((ORA_UCM_SRVC.value != null) &&
			(ORA_UCM_SRVC.version != null)) {
		}
		return true;
	}
	// Added by cyappert
	else if (s == "ORA_UCM_CMP") {
		if ((ORA_UCM_CMP.value != null) &&
			(ORA_UCM_CMP.version != null)) {
		}
		return true;
	}

	return false;
}
// ------------------------------------------------------------------------- //
function isUCMRegistered() {

	if ((existsUCMCookie("ORA_UCM_VER") == true) &&
		(existsUCMCookie("ORA_UCM_INFO") == true) &&
		(existsUCMCookie("ORA_UCM_SRVC") == true) ) {
		orainfo_exists = true;
		otnnm_exists = true;
		return true;
	}
	return false;
}
// ------------------------------------------------------------------------- //
function isUCMAnonymous() {

	if ( (ORA_UCM_INFO.version != null) &&
		(ORA_UCM_INFO.guid != null) && 
		(isUCMRegistered() == false) ) {
	return true;
	}
	return false;
}
// ------------------------------------------------------------------------- //
function getUCMCookies() {
	ORA_UCM_VER   = new private_ORA_UCM_VER();
	ORA_UCM_INFO  = new private_ORA_UCM_INFO();
	ORA_UCM_SRVC  = new private_ORA_UCM_SRVC();
	ORA_UCM_CMP   = new private_ORA_UCM_CMP();
}
// ------------------------------------------------------------------------- //
function private_ORA_UCM_VER () {

	this.value_enc = getCookieData("ORA_UCM_VER");
	this.value     = private_UCMCookieDecode(this.value_enc);
	this.array     = this.value.split("OR1:");

	this.version       = this.array[0];
	this.username      = this.array[1];
	this.username_enc  = this.array[2];
	this.ipaddress     = this.array[3];
	this.ipaddress_enc = this.array[4];
}
// ------------------------------------------------------------------------- //
//-- Cookie Functions
//added by cyappert
function checkCMP(cmpID){
	getUCMCookies();
	if (existsUCMCookie("ORA_UCM_CMP")) {
		if (ORA_UCM_CMP.campaigns.indexOf("/" + cmpID + "/") != -1) return true;
	}
	else return false;
}

function readInfoCookie() {
	getUCMCookies();
	if (isUCMRegistered() == true) {
		orainfo_exists = true;
		user_info[FNAME] = ORA_UCM_INFO.firstname;
		user_info[LNAME] = ORA_UCM_INFO.lastname;
		user_info[TITLE] = ORA_UCM_INFO.title;
		user_info[EMAIL] = ORA_UCM_INFO.email;
		user_info[UID]   = ORA_UCM_INFO.username;
		user_info[ROLE]  = ORA_UCM_INFO.interest1;
		user_info[Q2]    = ORA_UCM_INFO.interest2;
		user_info[Q3]    = ORA_UCM_INFO.interest3;
		user_info[Q4]    = ORA_UCM_INFO.interest4;
		user_info[Q5]    = ORA_UCM_INFO.interest5;
	}
	return true;
}

function private_ORA_UCM_INFO() {
  this.value_enc   = getCookieData("ORA_UCM_INFO");

  // check for new or old cookie format
  if (this.value_enc.substr(0,4) == "/MP/") { // this is version 1

    this.value		= private_UCMCookieDecode(this.value_enc);
    this.array		= this.value.split("OR1:");

    this.version	= this.array[0];
    this.guid		= this.array[1];
    this.firstname    = this.array[2];
    this.lastname	= this.array[3];
    this.username	= this.array[4];
    this.email		= this.array[5];
    this.companyname  = this.array[6];
    this.title		= this.array[7];
    this.country	= this.array[8];
    this.language	= this.array[9];
    this.characterset = this.array[10];
    this.interest1    = this.array[11];
    this.interest2    = this.array[12];
    this.interest3    = this.array[13];
    this.interest4    = this.array[14];
    this.interest5    = this.array[15];
    // MW: old cookies only support ascii first and last name
    this.ascii		  = 1;


  } else { // this is version 2 or 3

    this.array		= this.value_enc.split("~");

    this.version	= this.array[0];
    this.guid		= this.array[1];
    this.firstname    = this.array[2];
    this.lastname	= this.array[3];
    this.username	= this.array[4];
    this.country	= this.array[5];
    this.language	= this.array[6];
    this.interest1    = this.array[7];
    this.interest2    = this.array[8];
    this.interest3    = this.array[9];
    this.interest4    = this.array[10];
    this.ascii		= this.array[11];
    this.email		= this.username;
    this.companyname  = null;
    this.title		= null;
    this.characterset = null;
    this.interest5    = null;
  }
  // upgrade from v2 to v3
  if (this.version == 2) {

    // interest 1
    var Jobs = new Array();
    Jobs["2"]  = "";
    Jobs["3"]  = "";
    Jobs["-1"] = "";
    Jobs["5"]  = "";
    Jobs["8"]  = "";
    Jobs["0"]  = "";
    Jobs["23"] = 33;
    Jobs["31"] = 22;
    Jobs["4"]  = 33;
    Jobs["1"]  = 33;
    if (Jobs[this.interest1]!=null)
	this.interest1 = Jobs[this.interest1];

    // interest 2
    if (this.interest2!=null) {
	var OldIndustries = this.interest2.split("/");
	for (i=1; i<OldIndustries.length; i++) {
	if (OldIndustries[i]!=null) {
	  this.interest2 = OldIndustries[i];
	  i = OldIndustries.length;
	}
      }
    }

    var Industries = new Array();
    Industries["1"]  = 40;
    Industries["3"]  = 41;
    Industries["5"]  = 41;
    Industries["7"]  = 40;
    Industries["9"]  = 10;
    Industries["12"] = 34;
    Industries["14"] = 13;
    Industries["15"] = 33;
    Industries["16"] = 34;
    Industries["18"] = 22;
    Industries["19"] = 19;
    Industries["22"] = 41;
    Industries["26"] = 27;
    Industries["28"] = 27;
    Industries["29"] = 10;
    Industries["30"] = 8;
    Industries["32"] = 34;
    if (Industries[this.interest2]!=null)
	this.interest2 = Industries[this.interest2];

    // interest 3
    var Relationships = new Array();
    Relationships["0"] = 6;
    Relationships["2"] = "";
    Relationships["3"] = "";
    Relationships["4"] = "";
    if (Relationships[this.interest3]!=null)
	this.interest3 = Relationships[this.interest3];

    var newCookie = [
	"3", this.guid, this.firstname,
	this.lastname, this.username, this.country,
	this.language, this.interest1, this.interest2,
	this.interest3, this.interest4, this.ascii,
	this.email, this.companyname, this.title,
	this.characterset, this.interest5
    ];

    var cookieData = newCookie.join("~");
    setCookie("ORA_UCM_INFO", cookieData, 1, "year");
  }
}

// ------------------------------------------------------------------------- //
function readOTN_NMCookie() {
	getUCMCookies();
	if (isUCMRegistered() == true) {
		otnnm_exists = true;
		//-- get level info by pulling CLB service
		if (ORA_UCM_SRVC.services.indexOf('/CLB/') != -1) {
			if (ORA_UCM_SRVC.CLB.role.indexOf('/14/') != -1) {
				otn_info[OTN_LVL] = 4;
			}
			else if (ORA_UCM_SRVC.CLB.role.indexOf('/13/') != -1) {
				otn_info[OTN_LVL] = 3;
			}
		}
		else otn_info[OTN_LVL] = 1;
		//-- get partner info - fudged, not in cookie
		if (ORA_UCM_SRVC.services.indexOf('/OPN/') != -1) {
			otn_info[OPP_PIN] = ORA_UCM_SRVC.OPN.extra[1];
			var opp_lvl = ORA_UCM_SRVC.OPN.extra[2];
			if (opp_lvl == 7) otn_info[OPP_LVL] = 'M';		
			else if (opp_lvl == 10) otn_info[OPP_LVL] = 'C';					
			else if (opp_lvl == 18) otn_info[OPP_LVL] = 'A';					
			else if (opp_lvl == 19) otn_info[OPP_LVL] = 'G';
			else otn_info[OPP_LVL] = 'O';
		}
		//-- get UID and IP info
		otn_info[OTN_UID] = ORA_UCM_VER.username;
		otn_info[OTN_IP] = ORA_UCM_VER.ipaddress;	
	}
	return true
}

function private_ORA_UCM_SRVC () {
  this.value_enc = getCookieData("ORA_UCM_SRVC");
  var delimiter; // used to do the second split

  // check for encoded version
  if (this.value_enc.substr(0,4) == "/QT/") { // version 1
    this.value     = private_UCMCookieDecode(this.value_enc);
    this.array     = this.value.split("SV1:");
    delimiter = "OR1:";
  } else { // version 2
    this.array     = this.value_enc.split("*");
    delimiter = "~";
  }
  
  this.version    = this.array[0];
  this.services   = '/';

  for (i=1; i<this.array.length; i++) {
    this.srvc_pieces = this.array[i].split(delimiter);

    eval ('this.' + this.srvc_pieces[0] + ' = new Array();');
    eval ('this.' + this.srvc_pieces[0] + '.code   = this.srvc_pieces[0];');
    eval ('this.' + this.srvc_pieces[0] + '.member = this.srvc_pieces[1];');
    eval ('this.' + this.srvc_pieces[0] + '.admin  = this.srvc_pieces[2];');
    eval ('this.' + this.srvc_pieces[0] + '.role   = this.srvc_pieces[3];');
    
    if (this.srvc_pieces[4] != null || this.srvc_pieces[4] != "") {
      eval ('this.' + this.srvc_pieces[0] + '.extra  = this.srvc_pieces[4].split("SE1:");');
    }
    this.services += this.srvc_pieces[0];
    this.services += '/';
  }
}

function private_ORA_UCM_CMP () {
	this.value = getCookieData("ORA_UCM_CMP");
	//this.value     = private_UCMCookieDecode(this.value_enc);
	this.array     = this.value.split("CMP1:");
	this.version    = this.array[0];

	this.campaigns   = '/';
	if (this.array.length >= 2) {	
		for (i=1; i<this.array.length; i++) {
			this.cmp_pieces = this.array[i].split("~");
			this.campaigns += this.cmp_pieces[0];
			this.campaigns += '/';
		}
	}
}


//Added by cyappert
/*function private_ORA_UCM_CMP () {
	this.value = getCookieData("ORA_UCM_CMP");
	//this.value     = private_UCMCookieDecode(this.value_enc);
	this.array     = this.value.split("CMP1:");
	
	this.version    = this.array[0];
	this.campaigns   = '/';

	for (i=1; i<this.array.length; i++) {
		this.cmp_pieces = this.array[i].split("OR1:");
		// c_ added because objects cannot be numbers
		eval ('this.c_' + this.cmp_pieces[0] + ' = new Array();');
		eval ('this.c_' + this.cmp_pieces[0] + '.data   = this.cmp_pieces[0];');
		eval ('this.c_' + this.cmp_pieces[0] + '.expire = this.cmp_pieces[1];');
		this.campaigns += this.cmp_pieces[0];
		this.campaigns += '/';
	}
}
*/
// ------------------------------------------------------------------------- //
function private_UCMCookieDecode(value) {
	var asciiArray = " !\"#$&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~.";
	var urldecodevalue = unescape(value);
	var ucmdecodevalue = '';
	var ch = '';

	for (i=0; i<urldecodevalue.length; i++) {

		ch = urldecodevalue.charAt(i)
		j = asciiArray.indexOf(ch);
		if (j != -1) {

			j +=2;
			if( j > ( asciiArray.length - 1 ) ) { 
				j -= asciiArray.length; 
			}
			ucmdecodevalue += asciiArray.charAt( j );
		}
		else {
			ucmdecodevalue += ch;
		}
	}
	return ucmdecodevalue;
}

// ------------------------------------------------------------------------- //
function getCookieData(label) {
	var labelLen = label.length
	var cLen = document.cookie.length
	var i = 0
	var cEnd
	while (i < cLen) {
	var j = i + labelLen
	if (document.cookie.substring(i,j) == label) {
		cEnd = document.cookie.indexOf(";",j)
		if (cEnd == -1) {
			cEnd = document.cookie.length
		}
	j++;
	return unescape(document.cookie.substring(j,cEnd))
	}

	i++
	}

	return "";
}
// ------------------------------------------------------------------------- //

function setCookie(name, value, time, ttype) {
	var exp = new Date();
	var cookieval = name + "=" + value + "; ";
	var date = exp.getTime();
	if (time > 0) {
      	if (ttype == "year") exp.setTime(date + (time * year)); 
		else if (ttype == "day") exp.setTime(date + (time * day));
		else if (ttype == "hour") exp.setTime(date + (time * hour));
		
      	cookieval += "expires=" + exp.toGMTString();
	}
    cookieval += "; domain=.oracle.com; path=/";
	document.cookie = cookieval;
}

function getCookie(foo) {
	return getCookieData(foo);
}

//-- New HipBone functions , contact jburbrid to make changes
// stripped down Hipone
window.gIChannelID='0i2wzK12842';
window.gServer = 'router.conavigator.com';
var helpWindow = 'help';
var internalIChannel;

// backward compatibility
function startDynamicStartPage(iChannelID, attachedData) {
        startCallback(iChannelID, 'customer data');
}

function startCallback(iChannelID, attachedData) {
	window.startVarApp = _startCallbackVarApp;
	window.getWinProperties = getCallbackWinProperties;
	launchDynamicStartPage(iChannelID, attachedData);

}

function launchDynamicStartPage(iChannelID, attachedData) {
		
	if(typeof(iChannelID) == 'undefined') {
		iChannelID = window.gIChannelID;
	}

	if(typeof(isHipboneSharedWindow) != 'undefined') {
		launchRecursiveErrorMessage(iChannelID);
		return;
	}

	
	window.gAttachedData = attachedData;
	window.internalIChannel= iChannelID;
	window.open('/admin/livehelp/hipboneLauncher.html?iChannel='+escape(window.internalIChannel) + '&host='+escape(window.gServer ), helpWindow,getWinProperties());
}

function launchRecursiveErrorMessage(iChannelID) {
	window.open('http://' + window.gServer + '/CONAV/HTD/'+iChannelID+'/login/recursiveConav.thtml', helpWindow, getWinProperties());			
}

function _startCallbackVarApp(){
   	window.open('https://' + window.gServer+ '/CONAV/HTD/' + window.internalIChannel + '/login/oem/net2phone/n_to_p.thtml?TIME='+(new Date()).getTime(), helpWindow, getCallbackWinProperties());
}

function getCallbackWinProperties() {
	return 'scrollbars=yes,resizable=no,width=300,height=430,screenX=10,screenY=10,top=10,left=10'
}




// ------------------------------------------------------------------------- //
libjsLoad = true;
//alert ("Oracle lib File Loaded")



//-- elogger.js: JS library for the elogger
//-- last updated: 05.13.01
//-- if using goAURL, lib.js has to be loaded first.

var g_url = ora_host + "/elog/trackurl";
var base_url	= "http://" + location.hostname;

function escapeURL(p_text) {
  re1 = /\&/gi;
  re2 = / /gi;
  re3 = /\+/gi;
 var  p_str = p_text;
  p_str = p_str.replace(re1,"%26");
  p_str = p_str.replace(re2,"%2B");
  p_str = p_str.replace(re3,"%2B");
  return p_str;
}

function goAURL(p_url,  p_object_id, p_subobject_id)  {
       	getUCMCookies();
	ORA_UCM_VER   = top.ORA_UCM_VER;
	ORA_UCM_INFO  = top.ORA_UCM_INFO;
	ORA_UCM_SRVC  = top.ORA_UCM_SRVC;

	if (!isUCMRegistered()) {
		alert("You don't appear to be signed in." + " Please sign-in or register to the upper right.");
	} else
	{
		goURL(p_url,  p_object_id, p_subobject_id);
	}

}

function trackURL(p_url,  p_object_id, p_subobject_id)  {

 var from_url = escapeURL(document.URL);
 var to_url = escapeURL(p_url);
 var dest_url = "";
 var src_url = "";
 var trackable_url = "";

   if ( to_url.indexOf("http") == -1)  dest_url = base_url + to_url;
   if ( from_url.indexOf("http") == -1)  src_url = base_url + from_url;

   trackable_url = g_url + "?d=" + dest_url + "&s=" + src_url +  "&di="  + p_object_id ;
   return trackable_url;
}

function goURL(p_url, p_object_id, p_subobject_id)  {

 var from_url = escapeURL(document.URL);
 var to_url = escapeURL(p_url);
 var dest_url = "";
 var src_url = "";
 var trackable_url = "";

   if ( to_url.indexOf("http") == -1)  dest_url = base_url + to_url;
   if ( from_url.indexOf("http") == -1)  src_url = base_url + from_url;

   trackable_url = g_url + "?d=" + dest_url + "&s=" + src_url +  "&di="  + p_object_id ;
   location = trackable_url;
}

// for 1x1 images
function logURL(p_object_id, p_subobject_id ) {

 var from_url = escapeURL(document.referrer); 
 var  to_url = escape(document.URL);   
 var dest_url = "";
 var src_url = "";
 var trackable_url = "";
   if ( to_url.indexOf("http") == -1)   dest_url = base_url + to_url;
   if ( from_url.indexOf("http") == -1) src_url = base_url + from_url;

   trackable_url = g_url + "?d=" + dest_url + "&s=" + src_url +  "&di="  + p_object_id   + "&a=image" ;
   document.write("<img src=\"" + trackable_url + "\">");
}



//for ebn show the Ondemand window and show Quote window
function showOndemand(showid, cmsid, regsite) {
  var v_regsite;
  if (!regsite) v_regsite = ''; else v_regsite = regsite;
	mywin = SpecialWin("onDemandWin", "popup.on_demand", showid, cmsid, v_regsite, "Y", 405, 675);
}
function OndemandReg(showid, cmsid, regsite) {
  var v_regsite;
  if (!regsite) v_regsite = ''; else v_regsite = regsite;
	mywin = SpecialWin("onDemandWin", "popup.on_demand", showid, cmsid, v_regsite, "Y", 405, 675);
}
function showISeminar(showid, cmsid, regsite) {
  var v_regsite;
  if (!regsite) v_regsite = ''; else v_regsite = regsite;
	mywin = SpecialWin("ISeminarWin", "iseminar_viewer.ondemand", showid, cmsid, v_regsite, "Y", 635, 440);
}
function showISeminarOpen(showid, cmsid, regsite) {
  var v_regsite;
  if (!regsite) v_regsite = ''; else v_regsite = regsite;
	mywin = SpecialWin("ISeminarWin", "iseminar_viewer.ondemand", showid, cmsid, v_regsite, "Y", 635, 440);
}
function ISLive(showid, cmsid, regsite) {
  var v_regsite;
  if (!regsite) v_regsite = ''; else v_regsite = regsite;
	mywin = SpecialWin("ISLiveWin", "iseminar_viewer.live", showid, cmsid, v_regsite, "Y", 635, 600);
}
function ISOnDemand(showid, cmsid, regsite) {
  var v_regsite;
  if (!regsite) v_regsite = ''; else v_regsite = regsite;
	mywin = SpecialWin("ISOnDemandWin", "iseminar_viewer.ondemand", showid, cmsid, v_regsite,"Y", 635, 423);
}
function screenWatch(showid, cmsid, regsite) {
  var v_regsite;
  if (!regsite) v_regsite = ''; else v_regsite = regsite;
	mywin = SpecialWin("ScreenWatchWin", "screenwatch.video", showid, cmsid, v_regsite, "Y", 812, 637);
}
function screenWatchOpen(showid, cmsid, regsite) {
  var v_regsite;
  if (!regsite) v_regsite = ''; else v_regsite = regsite;
	mywin = SpecialWin("ScreenWatchWin", "screenwatch.video", showid, cmsid, v_regsite, "Y", 812, 637);
}
function SpecialWin(name, purl, showid, cmsid, regsite, reg, w, h) {
	mywin=window.open('http://www.oracle.com/pls/ebn/' + purl + '?p_shows_id='+ showid + '&p_regreq=' + reg  + '&p_referred=' + cmsid + '&p_regsite=' + regsite, name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=no,width=' + w + ',height=' + h );
	return mywin;
}


//CAMPAIGN SESSION COOKIE FUNCTIONS: USED
///set entry context variables
var entryPointSrc = getArg("src");
var entryPointact = getArg("act");
var entryPointAct = getArg("Act");
if (entryPointact ==""){ var entryPointActivity = entryPointAct} else { var entryPointActivity = entryPointact}
var entryPointkw =  getArg("kw");

///create entry context array
var entryContext = new Array(entryPointSrc,entryPointActivity,entryPointkw)

///get entry context session cookie array
var entryPointContextValues =  getCookie("ORA_EMB_COOKIE");
var entryPointContextArray  =  entryPointContextValues.split(',');

///set entry context session cookie if they source code in the cookie is different than the one in the url
if (entryPointContextArray[0] != entryPointSrc && entryPointSrc !=""){
setCookie("ORA_EMB_COOKIE", entryContext)
}

//prepare string for handoff

function connectString(url) { 
	var PassUrl    = ""
	var currentSrc = ""
	var currentAct = ""
	var currentkw  = ""
   	readInfoCookie() 
   	readOTN_NMCookie()
	var entryPointContextValues =  getCookie("ORA_EMB_COOKIE");
	var entryPointContextArray  =  entryPointContextValues.split(',');

if (entryPointSrc == ""){ var currentSrc = entryPointContextArray[0]} else {var currentSrc = entryPointSrc}
if (entryPointActivity == ""){ var currentAct = entryPointContextArray[1]} else {var currentAct = entryPointActivity}
if (entryPointkw == ""){ var currentkw = entryPointContextArray[2]} else {var currentkw = entryPointkw}

   if (orainfo_exists) { 
        PassUrl += 'firstname=' + escape(ORA_UCM_INFO.firstname) + '&' 
		PassUrl += 'lastname=' + escape(ORA_UCM_INFO.lastname) + '&' 
		PassUrl += 'email=' + escape(ORA_UCM_INFO.email) + '&' 
		PassUrl += 'title=' + escape(ORA_UCM_INFO.title) + '&'
		PassUrl += 'company=' + escape(ORA_UCM_INFO.companyname) + '&' 
		PassUrl += 'country=' + escape(ORA_UCM_INFO.country) + '&' 
		PassUrl += 'token=' + escape(ORA_UCM_INFO.username) + '&' 
   } 
if (otnnm_exists) { 
PassUrl += 'level=' + escape(otn_info[OTN_LVL]) + '&' 
   } 
   
PassUrl += "Src=" + currentSrc + "&Act=" + currentAct  + "&kw=" + currentkw 
   		top.location = url + PassUrl
		//alert(url + PassUrl)
  }


// EBN Functions

function goChat(chatName, newWin) {
              var chat_url	= "http://plnk.peoplelink.com/beta/oracle/chat/index.cfm?chat_room=";
	var username="", email = "";
	var plink_url = chat_url + escape(chatName);
	var win_str = 	'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=750,height=500';
	if (isUCMRegistered()) {
		if (!isEmail(ORA_UCM_INFO.email)) {
			if (confirm("You're e-mail address does not appear to be valid. Would you like to update your profile?")) {
				top.location("/ebusinessnetwork/admin/register.html?/admin/account/ebn/ebn_profile.html");
			}
		}
		else {
			username = ORA_UCM_INFO.username;
			email = ORA_UCM_INFO.email;
			plink_url += "&email=" + escape(username + '@ploracle.com') + "&password=OracleEBN&email_real=" + escape(email);
			//plink_url = trackURL(plink_url,"EBN_CE",  0, 0);
			if (!newWin) {
				var chat = window.open(plink_url, "EBNChat", win_str);
				chat.focus();
			}
			//Added fro frameset based override
			else {
				parent.chat.location = plink_url;
			}
		}
	}
	else {
		alert("You don't appear to be signed in. Please sign-in or register at the top.");
	}
	return;
}

function Shwing(login, page, name, popup_width, popup_height) {
	var test = login.indexOf('%');
	if (test < 0) login = escape(login);
	page = page + '&args=' + login;
	window.open(page, name, 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes,width=' + popup_width + ',height=' + popup_height);
}

function drawIdentBlock() {
	getUCMCookies();
	if (isUCMRegistered()) {
            var signouturl ="http://oraclepartnernetwork.oracle.com/servlet/page?_pageid=16145,26650&_dad=moc&_schema=MOC"; 
		var uname = ORA_UCM_INFO.firstname + " " + ORA_UCM_INFO.lastname
          
		//block = '<font class="WelcomeOption">&nbsp;Welcome ' + uname + ' (';
              block = '<font class="WelcomeOption">&nbsp;Welcome This is a test ' + uname + ' (';

		block += '<a class="WelcomeOption" href="javascript:signout(' + "'" + signouturl+ "'" + ')">Sign Out</A>)</font>\n'
	}
	else {
		block = '<font class="WelcomeOption">&nbsp;(<a class="WelcomeOption" href="https://profile.oracle.com/jsp/reg/register.jsp?act=4&src=1288745&language=en" target="_top">Click Here</a> to register for a free Oracle web account)</font>\n'
	}

	document.write(block)
	document.close()
}

function isEmail(s) {
	var atsign = s.indexOf("@")
	if (atsign == -1) return false
	
	var user = s.substring(0, atsign)
	var domain = s.substring(atsign+1, s.length) 

	if (user == "") return false
	if (domain == "") return false
	
	var dot = domain.indexOf(".")
	if (dot == -1) return false
	else return true
}

// pukken: add this function whenver lib.js changes
function loadURL(url, dest, window_attrs) {
  //
  // Loads a new url in dest[ination]
  //
  // Returns the window object that the URL was loaded into.
  //
  // Parameters:
  //   url (required)
  //     - the URL to load
  //   dest (optional)
  //     - dest may be a frame object, existing window object, or window name
  //       (new or existing window).
  //     - default is to load URL in the current document (relative to where
  //       this javascript file is loaded)
  //   window_attrs (optional)
  //     - if dest is a window name, window attributes may be specified here
  //
  // Example: loadURL(appURL("benefits"), parent.frames[1])

  var win;

  if (typeof dest != "undefined" && dest != null) {
    if (typeof dest == "string") {
      // Window name, with or w/o window attributes
      //
      if (typeof window_attrs != "undefined" && window_attrs != null) {
        win = window.open(url, dest, window_attrs);
      }
      else {
        win = window.open(url, dest);
      }
      return win;
    }
    else if (typeof dest.closed == "undefined") {
      // Not a Window or Frame, assume document
      //
      dest.location = url;
      return window;
    }
    else if (typeof dest.top == "unknown" || typeof dest.top == "undefined") {
      // An invalid Window or Frame
      //
      alert("loadURL:: Error: Destination Window or Frame not found");
      return null;
    }
    else if (dest.top == dest) {
      // Window object
      //
      dest.location = url;
      return dest;
    }
    else {
      // Frame object
      //
      dest.location = url;
      return window;
    }
  }
  else {
    // No destination, load "in place"
    //
    document.location = url;
    return window;
  }
}

// pukken: add this function whenver lib.js changes
function appURL(app, env) {
  //
  // Return Application prefix URL for given application.  Default environment
  // (EBIZ_ENV) can be overridden by specifying optional second parameter.
  // Valid environments are: dev (development), tst (test), stg (staging),
  // and prd (production)
  //
  // Note: specifying the optional second parameter should be a rare exception
  //       to the rule.
  //
  // Example: appURL("benefits") 
  //          appURL("benefits", "dev")
  //
  var app_env = EBIZ_ENV;
  var internal_src = true;
  var err_msg = "";
  var host_url = "";

  if (typeof env == "string") {
    app_env = env.toLowerCase();
  }
  
  if (location.hostname.indexOf("us.oracle.com") == -1) {     
        internal_src = false;
	app_env = "prd"  
  }
  
  if (location.hostname.indexOf("mktas.oracle.com") != -1) {
        internal_src = true;
        app_env = "stg"
  }

  switch (app_env) {
    case "dev":
      switch (app.toLowerCase()) {
		case "auth":
          host_url = "http://profile-mktad.us.oracle.com";
          break;
        case "benefits":
          host_url = "http://partner-mktad.us.oracle.com";
          break;
        case "member_admin":
          host_url = "http://profile-mktad.us.oracle.com/jsp/ebizadm/login.jsp";
          break;
        case "opn_content":
          host_url = "http://partner-mktad.us.oracle.com";
          break;
        case "opn_instruction":
          host_url = "http://partnercontent.oracle.com";
          break;          
        case "opn_enroll":
          host_url = "http://partner-mktad.us.oracle.com";
          break;
        case "opn_oia":
          host_url = "http://partner-mktad.us.oracle.com/jsp/opn/OpnProcessAdmin.jsp";
          break;
        case "opn_prn":
          host_url = "http://partner-mktad.us.oracle.com/jsp/prn";
          break;
        case "opn_reports":
          host_url = "http://california.us.oracle.com:7777/opn/html/opn_reports.htm";
          break;
        case "solutions_entry":
          host_url = "http://solutionsmarketplace.oracle.com";
          break;
        case "solutions_query":
          host_url = "http://partner-mktad.us.oracle.com";
          break;
        default:
          err_msg ="unknown application '"+app+"' in environment '"+app_env+"'";
      }
      break
    case "tst":
      switch (app.toLowerCase()) {
		case "auth":
          host_url = "http://profile-mktat.us.oracle.com";
          break;
        case "benefits":
          host_url = "http://partner-mktat.us.oracle.com";
          break;
        case "member_admin":
          host_url = "http://profile-mktat.us.oracle.com/jsp/ebizadm/login.jsp";
          break;
        case "opn_content":
          host_url = "http://partner-mktat.us.oracle.com";
          break;
        case "opn_instruction":
          host_url = "http://partnercontent.oracle.com";
          break;           
        case "opn_enroll":
          host_url = "http://partner-mktat.us.oracle.com";
          break;
        case "opn_oia":
          host_url = "http://partner-mktat.us.oracle.com/jsp/opn/OpnProcessAdmin.jsp";
          break;
        case "opn_prn":
          host_url = "http://partner-mktat.us.oracle.com/jsp/prn";
          break;
        case "opn_reports":
          host_url = "http://partner-mktat.us.oracle.com/opn/html/opn_reports.htm";
          break;
        case "solutions_entry":
          host_url = "http://solutionsmarketplace.oracle.com";
          break;
        case "solutions_query":
          host_url = "http://partner-mktat.us.oracle.com";
          break;
        default:
          err_msg ="unknown application '"+app+"' in environment '"+app_env+"'";
      }
      break;
    case "stg":
      switch (app.toLowerCase()) {
		case "auth":
          host_url = "http://profile-mktas.oracle.com";
          break;
        case "benefits":
          host_url = "http://partner-mktas.oracle.com";
          break;
        case "member_admin":
          host_url = "http://profile-mktas.oracle.com/jsp/ebizadm";
          break;
        case "opn_content":
          host_url = "http://partner-mktas.oracle.com";
          break;
        case "opn_instruction":
          host_url = "http://partnercontent.oracle.com";
          break;           
        case "opn_enroll":
          host_url = "http://partner-mktas.oracle.com";
          break;
        case "opn_oia":
          host_url = "http://partner-mktas.oracle.com/jsp/opn/OpnProcessAdmin.jsp";
          break;
        case "opn_prn":
          host_url = "http://partner-mktas.oracle.com/jsp/prn";
          break;
        case "opn_reports":
          err_msg ="unknown application '"+app+"' in environment '"+app_env+"'";
          break;
        case "solutions_entry":
          host_url = "http://solutionsmarketplace.oracle.com";
          break;
        case "solutions_query":
          err_msg ="unknown application '"+app+"' in environment '"+app_env+"'";
          break;
        default:
          err_msg ="unknown application '"+app+"' in environment '"+app_env+"'";
      }
      break;
    case "prd":
      switch (app.toLowerCase()) {
		case "auth":
          host_url = "https://profile.oracle.com";
          break;
        case "benefits":
          host_url = "http://partner.oracle.com";
          break;
        case "member_admin":
          host_url = "http://profile.oracle.com/jsp/ebizadm/login.jsp";
          break;
        case "opn_content":
          host_url = "http://partner.oracle.com";
          break;
        case "opn_instruction":
          host_url = "http://partnercontent.oracle.com";
          break;           
        case "opn_enroll":
          host_url = "https://partner.oracle.com";
          break;
        case "opn_oia":
          host_url = "https://partner.oracle.com/jsp/opn/OpnProcessAdmin.jsp";
          break;
        case "opn_prn":
          host_url = "http://partner.oracle.com/jsp/prn";
          break;
        case "opn_reports":
          err_msg ="unknown application '"+app+"' in environment '"+app_env+"'";
          break;
        case "solutions_entry":
          host_url = "http://solutionsmarketplace.oracle.com";
          break;
        case "solutions_query":
          err_msg ="unknown application '"+app+"' in environment '"+app_env+"'";
          break;
        default:
          err_msg = "unknown application '"+app+"' in environment '"+app_env+"'";
      }
      break;
    default:
      err_msg = "unknown environment '"+app_env+"'";
  }
  if (err_msg != "") {
    alert("appURL:: Error: "+err_msg);
  }
  return host_url;
}
function DrawEnrollRow()
	{
	return true;
	}
