function loadLaunch(){if(window.location.search.substring(1) ==  'credits'){window.location='files/credits.html';};getVersion("0"); window.onclick = function(e) {if (e.target == m){m.style.display = "none"; document.getElementById("aboutVersion").innerHTML = "";}}
	var m = document.getElementById('myModal');var s = document.getElementsByClassName("close")[0];s.onclick = function() {m.style.display = "none";document.getElementById("aboutVersion").innerHTML = "";}
	jQuery.ajax({type: 'GET',url: "LSI/Storage/MR/API/1.0/",async: true,contentType: "application/json",dataType: 'json',success: function(json) {var user = getCookie("username");if (user != "") {window.location=ifgetcredentails();} else { }	},error: function(e) {}});	
	jQuery.ajax({type: "GET", url: "files/LaunchPageCheck.xml", async: true, contentType: "text/xml", dataType: "xml", success: function(xml) { if(xml.getElementsByTagName("value")[0].childNodes[0].nodeValue == 1){ window.location=ifgetcredentails(); } },error: function(e) {}});
}
function ifgetcredentails(){
	var user1=getAllUrlParams().username;
	var pwd=getAllUrlParams().password; 
	var url='./ui/remoteserver/index.html';
		
	if((user1!=undefined) && (pwd!=undefined))
		{	
		url='./ui/remoteserver/index.html?username='+user1+'&password='+pwd;
			
		}
		else
		{ 
	     url='./ui/remoteserver/index.html';
		
		}
		return url;
}	
function getCookie(cname) {var name = cname + "=";var ca = document.cookie.split(';');for(var i=0; i<ca.length; i++) {var c = ca[i];while (c.charAt(0)==' ') {c = c.substring(1);}if (c.indexOf(name) == 0) {return c.substring(name.length, c.length);}}return "";}			
function launch(){var ck = document.getElementById("check");if(ck.checked){document.cookie = "username=skipPage";}window.location=ifgetcredentails();}			
function getVersion(ck){
	var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200)	{
					var x, i, xmlDoc;
					xmlDoc = this.responseXML;
					var myNodelist = xmlDoc.getElementsByTagName("version");
					var count = myNodelist.length;
					if(ck.indexOf('about') == 0){
						document.getElementById("footerVersion").innerHTML = "version: "+xmlDoc.getElementsByTagName("value")[0].childNodes[0].nodeValue;
						if(count > 0){
							document.getElementById("aboutVersion").innerHTML = xmlDoc.getElementsByTagName("value")[0].childNodes[0].nodeValue;
							document.getElementById('myModal').style.display = "block";
						}else{
							document.getElementById("aboutVersion").innerHTML = "000.000.000.000";
							document.getElementById('myModal').style.display = "block";
						}
						ck = "0";
					}
					document.getElementById("footerVersion").innerHTML = "version: "+xmlDoc.getElementsByTagName("value")[0].childNodes[0].nodeValue;
					var i,check = 0, temp = 0;
					if(ck.indexOf('0') == 0){
						document.getElementById("footerVersion").innerHTML = "version: "+xmlDoc.getElementsByTagName("value")[0].childNodes[0].nodeValue;
						if(myNodelist.length > 6){
							check = 6;
							temp = 6;							
							document.getElementById("viewmorelabel").innerHTML = "View More";
						}else{
							check = myNodelist.length;
						}
					}else{
						document.getElementById("footerVersion").innerHTML = "version: "+xmlDoc.getElementsByTagName("value")[0].childNodes[0].nodeValue;
						check = myNodelist.length;
					}
					var output="";
					for(var i=0; i< check; i++){
							output += "<div class='versionListli'><p class='versionstring'>LSI Storage Authority Version: "+
										xmlDoc.getElementsByTagName("value")[i].childNodes[0].nodeValue
										+" Released On "+xmlDoc.getElementsByTagName("date")[i].childNodes[0].nodeValue+" .</p></div>";
					}
					if(count > temp){
						document.getElementById("viewmorelabel").style.display = 'block';
					}else{
						document.getElementById("viewmorelabel").style.display = 'none';
					}
					document.getElementById("versionList").innerHTML = output;
				
		
	}
  };
   xmlhttp.open("GET", "version.xml?t=" + Math.random(), true);
    xmlhttp.send();
}
			
function viewMoreVersions(){if(document.getElementById("viewmorelabel").innerText.indexOf('View Less') == 0){getVersion("0");}else{document.getElementById("viewmorelabel").innerHTML = "View Less";getVersion("1");}}
function openabout(){getVersion("about");}
function launchpopudDisplay(flag){if(flag){document.getElementById("launchpopup").style.display = "block";}else{document.getElementById("launchpopup").style.display = "none";}}
function check(){var check = document.getElementById("check");if(check.checked){check.checked =  false;}else{check.checked =  true;}}
function stopVideo(){ var video = document.getElementById("myVideo");video.pause();try {video.currentTime = 0;}catch(err) { }}function playVideo(path){var video = document.getElementById('myVideo');video.src = path;video.play();}
function getAllUrlParams(url) {

  // get query string from url (optional) or window
  var queryString = url ? url.split('?')[1] : window.location.search.slice(1);

  // we'll store the parameters here
  var obj = {};

  // if query string exists
  if (queryString) {

    // stuff after # is not part of query string, so get rid of it
    queryString = queryString.split('#')[0];

    // split our query string into its component parts
    var arr = queryString.split(';');

    for (var i=0; i<arr.length; i++) {
      // separate the keys and the values
      var a = arr[i].split('=');

      // in case params look like: list[]=thing1&list[]=thing2
      var paramNum = undefined;
      var paramName = a[0].replace(/\[\d*\]/, function(v) {
        paramNum = v.slice(1,-1);
        return '';
      });

      // set parameter value (use 'true' if empty)
      var paramValue = typeof(a[1])==='undefined' ? true : a[1];

      // (optional) keep case consistent
      paramName = paramName.toLowerCase();
      paramValue = paramValue.toLowerCase();

      // if parameter name already exists
      if (obj[paramName]) {
        // convert value to array (if still string)
        if (typeof obj[paramName] === 'string') {
          obj[paramName] = [obj[paramName]];
        }
        // if no array index number specified...
        if (typeof paramNum === 'undefined') {
          // put the value on the end of the array
          obj[paramName].push(paramValue);
        }
        // if array index number specified...
        else {
          // put the value at that index number
          obj[paramName][paramNum] = paramValue;
        }
      }
      // if param name doesn't exist yet, set it
      else {
        obj[paramName] = paramValue;
      }
    }
  }

  return obj;
}                              
		