﻿
$(document).ready(function() {
    $('a.menu').click(function () { //get all link with class menu
        current = $(this); //grab the current item, to be used in resize function
		$('#bck-wrapper').scrollTo($(this).attr('href'), 400);  //scroll it to the destination	
        if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ var ieversion=new Number(RegExp.$1); if (ieversion>=8) { return false; } else if (ieversion>=7) {}} else { return false; }
        //return false; //cancel the link default behavior  
	});
    
    $(window).resize(function () { resizePanel(); });//resize all the items according to the new browser size

	var backgroundSrcs = new Array("home.jpg","home1.jpg","home2.jpg","home3.jpg","home4.jpg") 
    var bgimage=backgroundSrcs[(Math.round(Math.random()*(backgroundSrcs.length-1)))]  
    document.getElementById('home').style.backgroundImage = "url('images/core/" + bgimage + "')"; 
    
    $(window).load(function() { 
    
        document.getElementById('web').style.backgroundImage = "url('images/core/web.jpg')"; 
        document.getElementById('itsupport').style.backgroundImage = "url('images/core/itsupport.jpg')"; 
        document.getElementById('telephone').style.backgroundImage = "url('images/core/telephone.jpg')"; 
        document.getElementById('partners').style.backgroundImage = "url('images/core/partners.jpg')";
        document.getElementById('contact').style.backgroundImage = "url('images/core/contact.jpg')"; 
        document.getElementById('online').style.backgroundImage = "url('images/core/onlinesupport.jpg')"; 
        document.getElementById('sitemap').style.backgroundImage = "url('images/core/sitemap.jpg')"; 
    
        $('#Page-contact').load("contact.ashx");
    }); 
});  

//$(window).load(function() { $('#Page-contact').load("contact.ashx"); }); //$('#Page-web').load("web.ashx");   //document.getElementById('body').style.backgroundImage = "url('images/core/body-bkd.jpg')";

function pageat(page) { 

    var menu, colour, left, width, ashx; //bkgd
    left = 0;

    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ var ieversion=new Number(RegExp.$1)
        if (ieversion>=8) { } else if (ieversion>=7) {
            left = left - 40;
            $('#Page-web').html(""); $('#Page-support').html(""); 
            $('#Page-telephone').html(""); $('#Page-partners').html(""); 
            $('#Page-contact').html(""); $('#Page-online').html(""); 
            $('#Page-sitemap').html("");
        }
    } 

    if (page == "web") {
        menu = "menu-web"; colour = "#61a5cf"; left = left + 58; width = "87px"; ashx = "web.ashx"; //bkgd = "web";
    } else if (page == "support") {
        menu = "menu-support"; colour = "#9fcb3a"; left = left + 145; width = "150px"; ashx = "support.ashx"; //bkgd = "itsupport";
    } else if (page == "telephone") {
        menu = "menu-telephone"; colour = "#e7df02"; left = left + 295; width = "150px"; ashx = "telephones.ashx"; //bkgd = "telephone"; 
    } else if (page == "partners") {
        menu = "menu-partners"; colour = "#f98f29"; left = left + 445; width = "145px"; ashx = "partners.ashx"; //bkgd = "partners"; 
    } else if (page == "contact") {
        menu = "menu-contact"; colour = "#b7270c"; left = left + 590; width = "145px"; ashx = "contact.ashx"; //bkgd = "contact"; 
    } else {
        document.getElementById('active-bg').style.display = "none";
        if (page == "home") {
            $('#Page-'+page).html(""); //bkgd = "home";         
        } else if (page == "online") {
            $('#Page-'+page).load("onlinesupport.ashx"); //bkgd = "onlinesupport";  
        } else if (page == "sitemap") {
            $('#Page-'+page).load("sitemap.ashx"); //bkgd = "sitemap";  
        }
    }

    if (page != "home" && page != "online" && page != "sitemap") {

        document.getElementById(menu).style.color = "#ffffff";
        document.getElementById('active-bg').style.backgroundColor = colour;
        document.getElementById('active-bg').style.left = left+"px";
        document.getElementById('active-bg').style.width = width;
        document.getElementById('active-bg').style.display = "block";
        
        var div = 'Page-' + page  
        if (trim(document.getElementById(div).innerHTML) == "") { $('#Page-'+page).load(ashx); }  
    }
    
    //document.getElementById('content').style.backgroundImage = "url('images/core/"+bkgd+".jpg')";
} 

function trim(instring) {	instring = instring.replace(/^\s+/,"");	return instring.replace(/\s+$/,"");}

function resizePanel() {
    width = $(window).width(); //get the browser width 
	mask_width = width * $('.bck-item').length; //get the mask width: width * total of items
    $('#bck-wrapper, .bck-item').css({width: width}); //set the dimension	
	$('#mask').css({width: mask_width});	
}

function showweb(open) { 
    document.getElementById('Portfolio').style.display = 'none';
    document.getElementById('Applications').style.display = 'none';
    document.getElementById(open).style.display = 'block';
}

function showportfolio(open, site) { 
    document.getElementById('Portfolio-menu').style.display = 'none';
    document.getElementById('site-data').style.display = 'none';
    document.getElementById(open).style.display = 'block';
    if (site != "menu") { $('#the-site').load('site-'+site+'.ashx'); } else { $('#the-site').html(""); }
}

function showitsupport(open) { 
    document.getElementById('blurb').style.display = 'none';
    document.getElementById('Installation').style.display = 'none';
    document.getElementById('Networking').style.display = 'none';
    document.getElementById('Networking2').style.display = 'none';
    document.getElementById('Networking3').style.display = 'none';
    document.getElementById('Internet').style.display = 'none';
    document.getElementById('Support').style.display = 'none';
    document.getElementById('Support2').style.display = 'none';
    document.getElementById('Support3').style.display = 'none';
    document.getElementById(open).style.display = 'block';
}

function showtelephone(open) { 
    document.getElementById('telephoneinfo').style.display = 'none';
    document.getElementById('voip').style.display = 'none';
    document.getElementById('zulty').style.display = 'none';
    document.getElementById(open).style.display = 'block'; 
}

function showpartner(open, site) { 
    document.getElementById('partners-none').style.display = 'none';
    document.getElementById('partners-partner').style.display = 'none';
    document.getElementById(open).style.display = 'block';
    if (site != "none") { $('#partner-text').load('partner-'+site+'.ashx'); } else { $('#partner-text').html(""); }
}

function sendemail() { 
    var nm = document.getElementById('yrnm').value;
    nm = nm.replace(/ /g, "__");
    var em = document.getElementById('yrem').value;
    var mg = document.getElementById('yrmg').value;
    mg = mg.replace(/ /g, "__");
    $('#Result').html("");  
    
    if (nm == "") {
        $('#Result').html("*Please enter your name.");  
    } else if (em == "") {
        $('#Result').html("*Please enter your email.");
    } else if (mg == "") {
        $('#Result').html("*Please enter a message.");
    } else {    
        var send = "send.ashx?nm=" + nm + "&em=" + em + "&mg=" + mg;
       $('#Result').load(send);                        
    }
}

function restrictChars() { var keyCode = window.event.keyCode; if((keyCode > 57 || keyCode < 48) && (keyCode!=8 && keyCode!=9) && (keyCode > 105 || keyCode < 96)) { window.event.returnValue = false; } }

function onlinesupport() { 
    document.getElementById('error').style.display = 'none';
    var id = document.getElementById('TechID').value;
    
    if (id == "") { document.getElementById('error').style.display = 'block'; } else if (IsNumeric(id) == false) { document.getElementById('error').style.display = 'block'; } else {    
       //call online support code        
        if (id == "1") {
            location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5501.exe";
	    } else if (id == "2") {
		    location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5502.exe";
	    } else if (id == "3") {
		    location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5503.exe";
	    } else if (id == "4") {
	        location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5504.exe";
	    } else if (id == "5") {
		    location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5505.exe";
	    } else if (id == "6") {
		    location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5506.exe";
	    } else if (id == "7") {
		    location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5507.exe";
	    } else if (id == "8") {
		    location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5508.exe";
	    } else if (id == "9") {
		    location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5509.exe";
	    } else if (id == "10") {
		    location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5510.exe";
	    } else if (id == "11") {
		    location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5511.exe";
	    } else if (id == "12") {
		    location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5512.exe";
	    } else if (id == "13") {
		    location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5513.exe";
	    } else if (id == "14") {
		    location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5514.exe";
	    } else if (id == "15") {
		    location.href = "DualDesk/Customer_remotesupport.itmildura.com.au_5515.exe";
	    } else {
		    //do nothing
	    }                
    }
}

function run(file) { var ws = new ActiveXObject("WScript.Shell"); ws.run(file); }

function IsNumeric(strString) {
   var strValidChars = "0123456789"; 
   var strChar; 
   var blnResult = true;
   if (strString.length == 0) { return false; }
   for (i = 0; i < strString.length && blnResult == true; i++) { strChar = strString.charAt(i); if (strValidChars.indexOf(strChar) == -1) { blnResult = false; } }
   return blnResult;
}
