/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getPrevious() {
  	var id = document.getElementById("currentID").value;
	var maxid = document.getElementById("MaxmunB").value;
	
	if(parseInt(id) > 1){
		getBanner("previous");	
	}
	else{
		var c = document.getElementById("banner"+(parseInt(id))).style;
		c.display = "none";
		var ct = document.getElementById("banner"+(parseInt(maxid))).style;
		ct.display = "block";
		document.getElementById("currentID").value = maxid;
	}
	
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getNext() {
  	var id = document.getElementById("currentID").value;
	var maxid = document.getElementById("MaxmunB").value;

	if(parseInt(id) < parseInt(maxid)){
		getBanner("next");	
	}
	else{
		var c = document.getElementById("banner"+(parseInt(id))).style;
		c.display = "none";
		var ct = document.getElementById("banner1").style;
		ct.display = "block";
		document.getElementById("currentID").value = 1;
		var ele = document.getElementById("bannerDesc"+id).style;
		ele.display = "none";
	}
	
}

function rotate(){
	var id = document.getElementById("currentID").value;
	var maxid = document.getElementById("MaxmunB").value;
	var dir = document.getElementById("rotateDir").value;
	var stopRotation = document.getElementById("stopRotation").value;
	
	if(dir == "F" && stopRotation == "false"){
		if(parseInt(id) < parseInt(maxid)){
			getBanner("next");	
		}
		else if(parseInt(id) == parseInt(maxid)){
			var c = document.getElementById("banner"+(parseInt(id))).style;
			c.display = "none";
			var ct = document.getElementById("banner1").style;
			ct.display = "block";
			document.getElementById("currentID").value = 1;
			/*document.getElementById("rotateDir").value = "B";
			getBanner("previous");*/
		}	
	}
	/*else if(dir == "B" && stopRotation == "false"){
		if(parseInt(id) > 1){
			getBanner("previous");	
		}
		else if(parseInt(id) == 1){
			document.getElementById("rotateDir").value = "F";
			getBanner("next");
		}
	}*/
	
	setTimeout(rotate, 6000);
	
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getInfo(id) {
	var id = document.getElementById("currentID").value;
  	var ele = document.getElementById("bannerDesc"+id).style;
	
	
	
	ele.background = 'url("/deecd/app_templates/coretemplates/images/bg_banner_info.png") no-repeat scroll 0 0 transparent';
	if (ele.display == "block") {
		ele.display = "none";
		document.getElementById("stopRotation").value = "false";
	}
	else {
		ele.display = "block";
		document.getElementById("stopRotation").value = "true";
	}
}


function getBanner(flag){
	var id = document.getElementById("currentID").value;
	var maxid = document.getElementById("MaxmunB").value;
	var eleStyle = document.getElementById("banner"+id).style;
	
	var newEle = "";
	var ele = "";
	
	if(flag == "previous" && parseInt(id) > 1){
		eleStyle.display = "none";
		
		newEle = document.getElementById("banner"+(parseInt(id)-1)).style;
		newEle.display = "block";
			
		ele = document.getElementById("bannerDesc"+id).style;
		ele.display = "none";
		
		document.getElementById("currentID").value = parseInt(id) - 1; 
	}
	else if(flag == "next" && parseInt(id) < parseInt(maxid)){
		eleStyle.display = "none";
		
		newEle = document.getElementById("banner"+(parseInt(id)+1)).style;
		newEle.display = "block";
		
		ele = document.getElementById("bannerDesc"+id).style;
		ele.display = "none";
		
		document.getElementById("currentID").value = parseInt(id) + 1;
	}
	
}

////////////////////////////////////////////////////////////////////////////////////
/// Ajax call to dynamically previous or next page banner                       ///
/// Called component: "/unitecintranet/app_templates/objects/sapi/banner.cfc"  ///
/// Called function: "getBanner"                                              ///
////////////////////////////////////////////////////////////////////////////////
/*function getBanner(uuid,flag,bHome) {
    //1. Prepare URL for XHR request:
    var callingMethod = "/deecd/app_templates/objects/sapi/banner.cfc?method=getBanner";
    var postData      = "uuid="  + uuid +
                        "&flag=" + flag +
						"&bHome=" + bHome +
                        "&returnformat=json";
                        
    //2. remember the current setting, in case the click is invalid 
	ele = document.getElementById("bannerDesc");
	bSrc  = document.getElementById('banner').src;
	sUUID = document.getElementById('currentBanner').value;
	sDesc = ele.innerHTML;
	
	//2.1 Show loading icon
	ele.style.display = "block";
	ele.style.backgroundImage = "none";	
   	ele.innerHTML = "<img src='/shadomx/ui/icons/progress.gif' style='margin-right:150px' />";
	

    //ele.style.backgroundImage = 'url("/deecd/app_templates/coretemplates/images/bg_banner_info.png") no-repeat scroll 0 0 transparent'
	
    //3. Prepare our callBack object
   var callBack  = {
        //a. If our XHR call is successful, we want to make use of the returned data and add children nodes
        success: function(oResponse) {
            // Trim server's response
            var jsonResponse = oResponse.responseText.replace(/^\s+|\s+$/g,"");
			
            var oStResponse;
            // Create an object with the JsonResponse
            try {
                var oStResponse = YAHOO.lang.JSON.parse(jsonResponse);
            }
            catch (e) {
                alert(e);
				document.getElementById('banner').src = bSrc;
				ele.innerHTML = sDesc;
				ele.style.backgroundImage = 'url("/deecd/app_templates/coretemplates/images/bg_banner_info.png") no-repeat scroll 0 0 transparent';
				ele.style.display = "none";
            }
            // Start logic for the response
            if (oStResponse.STATUS == true) {
				if (oStResponse.PATH == ""){
					document.getElementById('banner').src = bSrc;
				}
				else{
					document.getElementById('banner').src = "/deecd/fms" + oStResponse.PATH;
				}
				
				if (oStResponse.OBJ_UUID == "") {
 					document.getElementById('currentBanner').value = sUUID;
				}
				else {
					document.getElementById('currentBanner').value = oStResponse.OBJ_UUID;
				}
				
				if(oStResponse.DESC == ""){
					ele.innerHTML = sDesc;
				}
				else{
					ele.innerHTML = oStResponse.DESC;
				}
				
				//ele.style.background = 'url("/deecd/app_templates/coretemplates/images/bg_banner_info.png") no-repeat scroll 0 0 transparent';
				ele.style.display = "none";
            }
            else {
                alert('Exception: ' + oStResponse.MESSAGE);
                //window.location.reload();
            }
        },
        //b. If our XHR call is not successful, set the banner to the default one
        failure: function(oResponse) {
            document.getElementById('banner').src = bSrc;
			ele.innerHTML = sDesc;
			//ele.style.backgroundImage = 'url("/deecd/app_templates/coretemplates/images/bg_banner_info.png") no-repeat scroll 0 0 transparent';
			ele.style.display = "none";
        },
        //c. Our handlers for the XHR response will need the same argument information we got to addChildrenOnLabelClick, so we'll pass those along
        argument: {
            "uuid": uuid,
            "flag": flag,
			"bHome":bHome
        }//,
        //d. Timeout -- if more than 7 seconds go by, we'll abort the transaction and assume there are no children
        //timeout: 7000;
    };//end callback
    

    //4. Do the ajaxcall:
    YAHOO.util.Connect.asyncRequest('POST', callingMethod, callBack, postData);
}
*/
