//////////////////////////////////////////////////////////////////////////////
// loader.js
// This is single include file for 'Co-browsing Client' for Agent.

// Avaya Inc. – Proprietary (Restricted)
// Solely for authorized persons having a need to know
// pursuant to Company instructions.
//
// Copyright © 2013 Avaya Inc. All rights reserved.
// THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Avaya Inc.
// The copyright notice above does not evidence any actual
// or intended publication of such source code.
//////////////////////////////////////////////////////////////////////////////
(function(g,b,d){
    //flag
    var useMinified = false;
    // NOTE: Change the path here to suit your deployment
    var path = 	window.location.protocol + "//" + window.location.hostname + ":"+ window.location.port + "/test_app/AgentController/";
    var jsSDKPath = window.location.protocol + "//" + window.location.hostname + ":"+ window.location.port + "/test_app/AgentController/libs/sdk/";

    //var path = 	window.location.protocol+ "//" + "/test_app/AgentController/";
    //var jsSDKPath = window.location.protocol+ "//" + "/test_app/AgentController/libs/sdk/";

    //LabJS code
    var c=b.head||b.getElementsByTagName("head"),D="readyState",E="onreadystatechange",F="DOMContentLoaded",G="addEventListener",H=setTimeout;
    function f(){
        if(useMinified){
			$LAB.script(jsSDKPath + "sock.min.js")
                .script(jsSDKPath + "Base64.min.js")
				.script(jsSDKPath + "md5.min.js")
				.script(jsSDKPath + "jquery_path.min.js")
                .script(jsSDKPath + "AvayaCustomerInteractionUtilitiesClient.min.js")
                .script(path + "js/app.min.js")
                .wait(function(){AgentControllerInit()});


        }else{
            $LAB.script(jsSDKPath + "sock.js")
                .script(jsSDKPath + "Base64.js")
				.script(jsSDKPath + "md5.js")
				.script(jsSDKPath + "jquery_path.js")
                .script(jsSDKPath + "AvayaCustomerInteractionUtilitiesClient.min.js")
                .script(path + "js/app.js")
                .wait(function(){AgentControllerInit()});
        }
    };

    H(function(){
		if("item"in c){
			if(!c[0]){
				H(arguments.callee,25);
				return
			}
			c=c[0]
		}

		var a=b.createElement("script"),e=false;
		a.onload=a[E]=function(){
			if((a[D]&&a[D]!=="complete"&&a[D]!=="loaded")||e){
				return false
			}
			a.onload=a[E]=null;
			e=true;
			f()
		};

		a.src=path+ "libs/ext/LAB.min.js";
		c.insertBefore(a,c.firstChild)
		f();

	},0);

	if(b[D]==null&&b[G]){
		b[D]="loading";
		b[G](F,d=function(){
			b.removeEventListener(F,d,false);
			b[D]="complete"
		},false)
	}

})(this,document);
