﻿function RemoveLastChildNavigationBackground()
{
    $("document").ready(function () {
        $(".navigation UL li:last-child").css("background-image", "none")
    });
}

function ApplyPngFix() {
    $("document").ready(function () {
         $("body").supersleight();
    });
}

function CSSearchSubmit() {
    
    var query = document.getElementById('CSTextInput').value;
    var protocol = window.location.protocol;
    var host = window.location.host;
    var allSiteAppend = "/_layouts/searchresults.aspx?k="; //change string to search results page
    var peopleAppend = "/Search/Pages/peopleresults.aspx?k="; //change string to people search results page
    var doubleSlash = '//';


    if (query != "Search Connected Systems") {

        var allSite = "&s=All%20Sites"; //change to scope result
        var url = protocol + doubleSlash + host + allSiteAppend + query // + allSite;
        //alert(url);
        window.location = url;
    }
    // else if (query == "Search Connected Systems"){
	
		// CSSearchAlert();
	// }
	else{
	
		CSSearchAlert();
    }

}

function CSSearchAlert(){
	alert("Please enter one or more search words.");
}

//Handle the DialogCallback callback
function DialogCallback(dialogResult, returnValue) {
    window.location = window.location;
}

function CSOpenDialog(pageUrl, winTitle, winWidth, winHeight) {

    CSOpenDialogResizable(pageUrl, winTitle, winWidth, winHeight, false);
}


function CSOpenDialogResizable(pageUrl, winTitle, winWidth, winHeight, resize) {
    var options = {
        url: pageUrl,
        width: winWidth,
        height: winHeight,
        title: winTitle,
        resizable: resize
    };
    SP.UI.ModalDialog.showModalDialog(options);
}

//refresh the source page after dialog is closed
function CSOpenDialogRefreshSource(pageUrl, winTitle, winWidth, winHeight, resize) {
    var options = {
        url: pageUrl,
        width: winWidth,
        height: winHeight,
        title: winTitle,
        resizable: resize,
        dialogReturnValueCallback: DialogCallback

    };

    SP.UI.ModalDialog.showModalDialog(options);
}

//Bing Maps used for Contact Page
// Add The following to a page
//*****START*****
//<script type="text/javascript"/>
//	$("document").ready(function()	{
//	CSGetMap();
//	});
//</script>
//
//<div id='CSMyMap' style="position:relative; width:400px; height:400px;"></div> 
//*****END*****
 function CSGetMap()
         {
		 var map = null;  
            // Initialize the map
            map = new Microsoft.Maps.Map(document.getElementById("CSMyMap"),
                         {credentials:"AvRN9qVJHI_-H99j6JXbK-70Q6LoKP6_D4ITDnBOoFJqIbDalkVwQvNBN6bqNakh"}); 

            // Define the pushpin location
            var loc = new Microsoft.Maps.Location( -31.94785, 115.86957);
            
            // Add a pin to the map
            var pin = new Microsoft.Maps.Pushpin(loc); 
            map.entities.push(pin);

            // Center the map on the location
            map.setView({center: loc, zoom: 18});
              
         }
       
function CSRedirectToContactPage(page, product) {
                if(page)
{
                                window.location = page + "?productName=" + product;
}              
        }
 
