﻿// JScript File
// used to get URL parameter
var GlobalPageName; 

function GoTo(MyURL)
{
    window.location=MyURL;
}

// rollover images (ProductUC)
function OnMouseOnFn(Source, Destination)
{
    Source.src = Destination;
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

// General Function
function GetInfo()
{
    GlobalPageName = gup('PageID');
    if (GlobalPageName!="")
    {
        if(GlobalPageName == "mapping")
        {
            document.title = "iTrack21 - Mapping";
            return 1;
        }
        else if(GlobalPageName == "mgt")         
        {
            document.title = "iTrack21 - Management";
            return 2; 
        }
        else if(GlobalPageName == "tracking")         
        {
            document.title = "iTrack21 - Tracking";
            return 3; 
        }
        else if(GlobalPageName == "biz_rules")         
        {
            document.title = "iTrack21 - Business Rules";
            return 4; 
        }
        else if(GlobalPageName == "reports")         
        {
            document.title = "iTrack21 - Reports";
            return 5; 
        }
        else if(GlobalPageName == "sensor")         
        {
            document.title = "iTrack21 - Sensors";
            return 6; 
        }                                
    }
}

function SwapPics(ImgName)
{   
    var MyPic = new Array('mapping','mgt','tracking','biz_rules','reports','sensor');
    
    if (ImgName == "mapping" || ImgName == "mgt" || ImgName == "tracking" || ImgName == "biz_rules" || ImgName == "reports" || ImgName == "sensor")
    {
        for( var i=0; i<6; i++)
        {
            if(ImgName == "mapping")
            {
                document.title = "iTrack21 - Mapping";            
            }
            else if(ImgName == "mgt")         
            {
                document.title = "iTrack21 - Management";
            }
            else if(ImgName == "tracking")         
            {
                document.title = "iTrack21 - Tracking";
            }
            else if(ImgName == "biz_rules")         
            {
                document.title = "iTrack21 - Business Rules";
            }
            else if(ImgName == "reports")         
            {
                document.title = "iTrack21 - Reports";
            }
            else if(ImgName == "sensor")         
            {
                document.title = "iTrack21 - Sensors";
            }  
                    
            clsDesign.GetUCHTML(ImgName, GetData_CallBack);
            
            if(ImgName==MyPic[i])
            {
                document.getElementById (ImgName).src = "images/" + ImgName + "_hover.jpg";    
            }
            else 
            {
                
                if(MyPic[i] == "mapping")            
                    document.getElementById (MyPic[i]).src = "images/" + MyPic[i] + "2.jpg";
                else 
                    document.getElementById (MyPic[i]).src = "images/" + MyPic[i] + ".jpg";
            }
        }
     }    
}

function GetData(PageName)
{     
    if(PageName=="products")
    {
        document.title = "iTrack21 - Products";
    }
    else if(PageName == "support")         
    {
        document.title = "iTrack21 - Support";
    }
    else if(PageName == "aboutus")         
    {
        document.title = "iTrack21 - Aboutus";
    }
    else if(PageName == "awards")         
    {
        document.title = "iTrack21 - Awards";
    }
    else if(PageName == "news")         
    {
        document.title = "iTrack21 - Latest News";
    }
    else if(PageName == "devicespec")         
    {
        document.title = "iTrack21 - Device Specification";
    }         
    else if(PageName == "sitemap")         
    {
        document.title = "iTrack21 - Sitemap";
    }        
    else if(PageName == "privacy")         
    {
        document.title = "iTrack21 - Privacy Policy";
    }
    else if(PageName == "terms")         
    {
        document.title = "iTrack21 - Web Terms of Use";
    }            
    clsDesign.GetUCHTML(PageName, GetData_CallBack);
}

function GetData_CallBack(res)
{
    if(GlobalPageName == "mapping" || GlobalPageName == "mgt" || GlobalPageName == "tracking" || GlobalPageName == "biz_rules" || GlobalPageName == "devicespec" || GlobalPageName == "reports" || GlobalPageName == "sensor")
    {
                
        if(GlobalPageName == "devicespec")
        {
            var MyVal = res.value.split("+");
                    
            if(MyVal[0] != "")
            {
                document.getElementById ("MiddleStaticPages").innerHTML = MyVal[0];
            }
                    
            if(MyVal[1] != "")
            {
                document.getElementById ("StaticPageContent").innerHTML = MyVal[1];
            }        
        }
        else
        {
            document.getElementById ("StaticPageContent").innerHTML = res.value;
        } 
        
	    // for tabs
	    $j("a.tab").click(function () {	
			    // switch all tabs off
			    $j(".active").removeClass("active");
    			
			    // switch this tab on
			    $j(this).addClass("active");
    			
			    // slide all content up
			    $j(".content").slideUp();
    			
			    // slide this content up
			    var content_show = $j(this).attr("title");
			    $j("#"+content_show).slideDown();		  
	    });      
    }
    else
    {
        var MyVal = res.value.split("+");
        
        if(MyVal[0] != "")
        {
            document.getElementById ("MiddleStaticPages").innerHTML = MyVal[0];
        }
        
        if(MyVal[1] != "")
        {
            document.getElementById ("StaticPageContent").innerHTML = MyVal[1];
        }
        
	    if(GlobalPageName == "awards")
	    {	  
	          var M = jQuery.noConflict(); 
		      var galleries = M('.ad-gallery').adGallery({
              loader_image: 'NewStyle/AwardsGallery/loader.gif',
              width: 600, // Width of the image, set to false and it will read the CSS width
              height: 400, // Height of the image, set to false and it will read the CSS height
              thumb_opacity: 0.7, // Opacity that the thumbs fades to/from, (1 removes fade effect)
                                  // Note that this effect combined with other effects might be resource intensive
                                  // and make animations lag
              start_at_index: 0, // Which image should be displayed at first? 0 is the first image
              description_wrapper: M('#descriptions'), // Either false or a jQuery object, if you want the image descriptions
                                                       // to be placed somewhere else than on top of the image
              animate_first_image: false, // Should first image just be displayed, or animated in?
              animation_speed: 400, // Which ever effect is used to switch images, how long should it take?
              display_next_and_prev: true, // Can you navigate by clicking on the left/right on the image?
              display_back_and_forward: true, // Are you allowed to scroll the thumb list?
              scroll_jump: 0, // If 0, it jumps the width of the container
              slideshow: {
                enable: true,
                autostart: true,
                speed: 5000,
                start_label: '>>',
                stop_label: '"',
                stop_on_scroll: true, // Should the slideshow stop if the user scrolls the thumb list?
                countdown_prefix: '(', // Wrap around the countdown
                countdown_sufix: ')',
                onStart: function() {
                  // Do something wild when the slideshow starts
                },
                onStop: function() {
                  // Do something wild when the slideshow stops
                }
              },
              effect: 'slide-hori', // or 'slide-vert', 'resize', 'fade', 'none' or false
              enable_keyboard_move: true, // Move to next/previous image with keyboard arrows?
              cycle: true // If set to false, you can't go from the last image to the first, and vice versa
              // All callbacks has the AdGallery objects as 'this' reference
            });          
	    }                  
    }
}

// rollover images (ProductUC)
function OnMouseOnFn(Source, Destination)
{
    Source.src = Destination;
}



