﻿// JScript File
// used to get URL parameter
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];
}

// rollover images (ProductUC)
function OnMouseOnFn(Source, Destination)
{
    Source.src = Destination;
}

// Open Save As Dialog Window
function OpenSaveAsDialog(FilePath)
{
    win = window.open(FilePath,'Win');
}

// General Function
function GetInfo()
{
    var MyPageID = gup('PageID');
    if (MyPageID!="")
    {
        if(MyPageID == "Profile" || MyPageID == "Vision")
        {
            clsiCOLAjax.GetStaticPageInfo(MyPageID, GetStaticPageInfo_CallBack);
        }
        else if (MyPageID == "iTrack21" || MyPageID == "iTracker" || MyPageID == "iPark" || MyPageID == "iFace" || MyPageID == "iLed" || MyPageID == "iSecure" || MyPageID=="Network" || MyPageID=="iSecureCCTV")
        {
            clsiCOLAjax.GetProductInfo(MyPageID, GetProductInfo_CallBack);
        }
        else if (MyPageID == "Careers")
        {
            clsiCOLAjax.GetCareersInfo(MyPageID, GetCareersInfo_CallBack);
        }          
    }
}

// Static pages call back
function GetStaticPageInfo_CallBack(res)
{
    var MyText = res.value.split(";");
    document.getElementById ('MyTitle').innerHTML = MyText[0];
    document.getElementById ('MyText').innerHTML = MyText[1];
    document.getElementById ('MyMainPic').src = MyText[2];
}

// Product pages call back
function GetProductInfo_CallBack(res)
{
    var MyText = res.value.split("+");
    document.getElementById ('MyTitle').innerHTML = MyText[1];
    document.getElementById ('MyText').innerHTML = MyText[0];
    document.getElementById ('MyLogo').innerHTML = MyText[2];
    clsiCOLAjax.GetHotNews(MyText[3], GetHotNews_CallBack);
}

function GetHotNews_CallBack(res)
{
    var MyText = res.value; 
    
    if (MyText != "" )
    {
        var MyNews = MyText.split("+");
        for (i=0; i<MyNews.length; i++)
        {
            if (i==0)
            {
                tickercontent2[0]=MyNews[i];
            }
            else
            {
                tickercontent2.push(MyNews[i]);
            }
        }
    }
}


function GetSubProductInfo(MyPageID)
{
    clsiCOLAjax.GetSubProductInfo(MyPageID, GetSubProductInfo_CallBack);
}

function GetSubProductInfo_CallBack(res)
{
    var MyText = res.value.split("+");
    document.getElementById ('MyTitle').innerHTML = MyText[1];
    document.getElementById ('MyText').innerHTML = MyText[0];
}

function GetCareersInfo_CallBack(res)
{
        var MyText = res.value.split("+");
        document.getElementById ('MyText').innerHTML = MyText[0];
        AddDynamicDiv(MyText[1]);
}

function RouteOpenPopup(WhatToOpen, Which)
{
    var MyBrowserName=navigator.appName;
    if(WhatToOpen=="Video")
    {
        if(Which=="iTrack21") 
        {
            OpenPopupWin("iTrack21 Demo Video", "VideoPlayer.aspx?PageID=iTrack21","600","400");
        }
        else if (Which=="iPark") 
        {
            OpenPopupWin("iPark Demo Video", "VideoPlayer.aspx?PageID=iPark","600","400");
        }
        else if (Which=="iFace") 
        {
            OpenPopupWin("iFace Demo Video", "VideoPlayer.aspx?PageID=iFace","600","400");
        }        
    }
    else if(WhatToOpen=="ContactUS")
    {
        if(Which=="iTrack21") 
        {
            OpenPopupWin("Contact iTrack21 Specialist", "ProductInquiry.aspx?PageID=iTrack21","630","450");
        }
        else if (Which=="iPark") 
        {
            OpenPopupWin("Contact iPark Specialist", "ProductInquiry.aspx?PageID=iPark","630","450");
        }
        else if (Which=="iFace") 
        {
            OpenPopupWin("Contact iFace Specialist", "ProductInquiry.aspx?PageID=iFace","630","450");
        }
        else if (Which=="iLed") 
        {
            OpenPopupWin("Contact iLed Specialist", "ProductInquiry.aspx?PageID=iLed","630","450");
        }
        else if (Which=="iTracker") 
        {
            OpenPopupWin("Contact iTracker Specialist", "ProductInquiry.aspx?PageID=iTracker","630","450");
        }
        else if (Which=="iSecure") 
        {
            OpenPopupWin("Contact Finger Print Specialist", "ProductInquiry.aspx?PageID=iSecure","630","450");
        }
        else if (Which=="Network") 
        {
            OpenPopupWin("Contact Network and Security Specialist", "ProductInquiry.aspx?PageID=Network","630","450");
        }
        else if (Which=="iSecureCCTV") 
        {
            OpenPopupWin("Contact iSecure Specialist", "ProductInquiry.aspx?PageID=iSecureCCTV","630","450");
        }                                                  
    }
    else if (WhatToOpen=="Snapshots")
    {
        if(Which=="iTrack21") 
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iTrack21 Starter Gallery", "PhotoGallery.aspx?PageID=iTrack21","635","460");
             }
             else
             {
                OpenPopupWin("iTrack21 Starter Gallery", "PhotoGallery.aspx?PageID=iTrack21","620","460");    
             }            
        }
        else if(Which=="iTrack21_Ent") 
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iTrack21 Enterprise Gallery", "PhotoGallery.aspx?PageID=iTrack21_Ent","635","460");
             }
             else
             {
                OpenPopupWin("iTrack21 Enterprise Gallery", "PhotoGallery.aspx?PageID=iTrack21_Ent","620","460");    
             }            
        }        
        else if (Which=="iPark") 
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iPark Gallery", "PhotoGallery.aspx?PageID=iPark","635","460");
             }
             else
             {
                OpenPopupWin("iPark Gallery", "PhotoGallery.aspx?PageID=iPark","620","460");    
             } 
        }
        else if (Which=="iFace") 
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iFace Gallery", "PhotoGallery.aspx?PageID=iFace","635","460");
             }
             else
             {
                OpenPopupWin("iFace Gallery", "PhotoGallery.aspx?PageID=iFace","620","460");    
             } 
        }
        else if (Which=="iLed") 
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iLed Gallery", "PhotoGallery.aspx?PageID=iLed","635","460");
             }
             else
             {
                OpenPopupWin("iLed Gallery", "PhotoGallery.aspx?PageID=iLed","620","460");    
             } 
        }
        else if (Which=="iTracker_Asset") 
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iTracker - Asset Management System Gallery", "PhotoGallery.aspx?PageID=iTracker_Asset","635","460");
             }
             else
             {
                OpenPopupWin("iTracker - Asset Management System Gallery", "PhotoGallery.aspx?PageID=iTracker_Asset","620","460");    
             } 
        }
        else if (Which=="iTracker_Inv") 
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iTracker - Inventory Management System Gallery", "PhotoGallery.aspx?PageID=iTracker_Inv","635","460");
             }
             else
             {
                OpenPopupWin("iTracker - Inventory Management System Gallery", "PhotoGallery.aspx?PageID=iTracker_Inv","620","460");    
             } 
        }
        else if (Which=="iTracker_Doc") 
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iTracker - Document Management System Gallery", "PhotoGallery.aspx?PageID=iTracker_Doc","635","460");
             }
             else
             {
                OpenPopupWin("iTracker - Document Management System Gallery", "PhotoGallery.aspx?PageID=iTracker_Doc","620","460");    
             } 
        }                
        else if (Which=="iSecure") 
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("Finger Print Gallery", "PhotoGallery.aspx?PageID=iSecure","635","460");
             }
             else
             {
                OpenPopupWin("iSecure Gallery", "PhotoGallery.aspx?PageID=iSecure","620","460");    
             } 
        }                                                    
    }
    else if(WhatToOpen=="Brochure")
    {
        if(Which=="iTrack21") 
        {      
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iTrack21 Brochure", "BrochureLanguage.aspx","300","190"); 
             }
             else
             {
                OpenPopupWin("iTrack21 Brochure", "BrochureLanguage.aspx","300","180"); 
             }             
        }
        else if (Which=="iPark" || Which=="iTracker") 
        {
            OpenSaveAsDialog("Images/Products/Brochures/RFID.pdf");
        }
        else if (Which=="iFace") 
        {
            OpenSaveAsDialog("Images/Products/Brochures/iFace.pdf");
        }
        else if (Which=="ControlCenter")    
        {
            OpenSaveAsDialog("Images/Products/Brochures/ControlCenter/ACC-Guide-Letter-ENG.pdf");
        }
        else if (Which=="HDIPDomeCameras")
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iSecure - HD IP Dome Cameras Brochure", "HDIPDomeCameras.aspx","300","330"); 
             }
             else
             {
                OpenPopupWin("iSecure - HD IP Dome Cameras Brochure", "HDIPDomeCameras.aspx","300","310"); 
             }        
        }
        else if (Which=="HDPanoramicIPDomeCameras")
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iSecure - HD Panoramic IP Dome Cameras Brochure", "HDPanoramicIPDomeCameras.aspx","300","190"); 
             }
             else
             {
                OpenPopupWin("iSecure - HD Panoramic IP Dome Cameras Brochure", "HDPanoramicIPDomeCameras.aspx","300","180"); 
             }         
        }
        else if (Which=="HDIPCameras")
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iSecure - HD IP Cameras Brochure", "HDIPCameras.aspx","300","330"); 
             }
             else
             {
                OpenPopupWin("iSecure - HD IP Cameras Brochure", "HDIPCameras.aspx","300","310"); 
             }          
        }
        else if (Which=="HDProfessionalCameras")
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iSecure - HD Pro. Cameras Brochure", "HDProfessionalCameras.aspx","300","190"); 
             }
             else
             {
                OpenPopupWin("iSecure - HD Pro. Cameras Brochure", "HDProfessionalCameras.aspx","300","180"); 
             }         
        }
        else if (Which=="HighDefinitionH264DomeCameras")
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("HD H.264 Dome Cameras Brochure", "HighDefinitionH264DomeCameras.aspx","300","330"); 
             }
             else
             {
                OpenPopupWin("HD H.264 Dome Cameras Brochure", "HighDefinitionH264DomeCameras.aspx","300","310"); 
             }           
        }
        else if(Which=="HighDefinitionH264IPCameras")
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("HD H.264 IP Cameras Brochure", "HighDefinitionH264IPCameras.aspx","300","190"); 
             }
             else
             {
                OpenPopupWin("HD H.264 IP Cameras Brochure", "HighDefinitionH264IPCameras.aspx","300","180"); 
             }          
        }
    }
    else if (WhatToOpen=="Photos")
    {
        if (Which=="iLed") 
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iLed Photos Gallery", "PhotoGallery.aspx?PageID=iLed","635","460");
             }
             else
             {
                OpenPopupWin("iLed Photos Gallery", "PhotoGallery.aspx?PageID=iLed","620","460");    
             } 
        }
        else if (Which=="iPark") 
        {
		     if (MyBrowserName=="Microsoft Internet Explorer")
             {
                OpenPopupWin("iPark Photos Gallery", "PhotoGallery.aspx?PageID=iPark_Photos","635","460");
             }
             else
             {
                OpenPopupWin("iPark Photos Gallery", "PhotoGallery.aspx?PageID=iPark_Photos","620","460");    
             } 
        }                    
    }
    else if (WhatToOpen=="NewsPic")
    {
        if (MyBrowserName=="Microsoft Internet Explorer")
        {
            OpenPopupWin("News and Events Photos Gallery", "PhotoGallery.aspx?PageID=NewsPic&NewsID=" + Which,"635","460");
        }
        else
        {
            OpenPopupWin("News and Events Photos Gallery", "PhotoGallery.aspx?PageID=NewsPic&NewsID=" + Which,"620","460");    
        }   
    }
    else if (WhatToOpen=="ApplyToJob")
    {
        OpenPopupWin("Apply to job", "ApplyToJob.aspx?JobID=" + Which,"630","415");   
    }                
}

function OpenPopupWin(WinTitle, PageURL, MyWidth, MyHieght)
{
    var MyWin = dhtmlwindow.open("WhatEver", "iframe", PageURL, WinTitle, "width="+MyWidth+"px,height="+MyHieght+"px,resize=0,scrolling=0,center=1", "recal")
}


