﻿window.onload = function () {
    //If currently displaying learn section

    var currloc = window.location.pathname;
    if(currloc!= null)
    {

        //If on the Learn More page
        if(currloc.indexOf("Learn") > -1 || currloc.indexOf("learn") > -1)
        {
            ShowLearnSubsection();
        }
        
        //If on the case study page
        if(currloc.indexOf("Case") > -1 || currloc.indexOf("Studies") > -1)
        {
            
                //Get Industry Category
                var mystr = "";
                var ind = document.getElementById('ctl00_QXContentLeft_QXBannerTop_SelectedCase');
                if(ind !=null)
                {
                    var mystr = "";
                    if(ind.value == null || ind.value == "")
                    {
                        mystr = getCookie('industry');
                    }
                    else
                    {
                        mystr = ind.value;
                    }
                }
                var obj = document.getElementById('ctl00_QXContentLeft_QXBannerTop_Case');
                CL_CaseCallback.PerformCallback(obj.value); 
                selectSubGroup(mystr);

        }
    
        //If currently displaying Support Policy section
        if(currloc.indexOf("SupportPolicy") > -1)
        {
            ShowPolicySubsection();
        }
        
        //If currently displaying the Suggestion Box section
        if(currloc.indexOf("Suggestion") > -1)
        {
            ShowSuggestionSubsection();
        }
        
        if(currloc.indexOf("3rd") > -1)
        {
            ShowThirdPartySubsection();
        }
        
        if(currloc.indexOf("Features") > -1)
        {
            ShowFeaturesSubsection();
        }
        
        //If on productpage, begin fading
        fadeObj = document.getElementById('ctl00_QXContentLeft_QXBannerTop_BannerWrapper');
        if(fadeObj!=null)
        {
            //make sure an industry has been selected
            objind = document.getElementById('ctl00_QXContentLeft_L_indprod');
            if(objind != null)
            {
                if(objind.innerText != "" && objind.innerText != "No industry selected")
                {
                    BeginFading();
                }
            }
        }
    }
}
///////////////////////////////////////////
// PRELOADING IMAGES and header IMG swap
///////////////////////////////////////////
if (document.images) {

 img1_on =new Image(); img1_on.src ="Images/products2.jpg"; 
 img1_off=new Image(); img1_off.src="Images/products1.jpg"; 

 img2_on =new Image(); img2_on.src ="Images/newsEvents2.jpg"; 
 img2_off=new Image(); img2_off.src="Images/newsEvents1.jpg"; 

 img3_on =new Image(); img3_on.src ="Images/support2.jpg";
 img3_off=new Image(); img3_off.src="Images/support1.jpg";

 img4_on =new Image(); img4_on.src ="Images/company2.jpg"; 
 img4_off=new Image(); img4_off.src="Images/company1.jpg"; 

 img5_on =new Image(); img5_on.src ="Images/contact2.jpg"; 
 img5_off=new Image(); img5_off.src="Images/contact1.jpg"; 

 img6_on =new Image(); img6_on.src ="Images/3rdParty2.jpg";
 img6_off=new Image(); img6_off.src="Images/3rdParty1.jpg";
 

}

function movr(k) {
 if (document.images) 
  eval('document.img'+k+'.src=img'+k+'_on.src');
}

function mout(k) {
 if (document.images) 
  eval('document.img'+k+'.src=img'+k+'_off.src');
}

////////////////////////
// Order Page Process
/////////////////////////

function OrderOnlinePurchase(product)
{
    obj = document.getElementById('ctl00_QXContentLeft_ASPxPageControl1_OrderOnline');
    if(obj != null)
    {
        //hide regular form
        obj2 = document.getElementById('ctl00_QXContentLeft_ASPxPageControl1_ProSelect');
        if(obj2!= null)
        {
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }

        obj3 = document.getElementById('ctl00_QXContentLeft_ASPxPageControl1_OrderFrameWrap')
        if(obj3 != null)
        {
            obj3.style.visibility = "hidden";
            obj3.style.display = "none";
        }
        
        changeframe('ctl00_QXContentLeft_ASPxPageControl1_OrderOnline','900px');
        if(product == "standard")
        {
            obj.src = "ColdFusion/index.cfm/fuseaction/MAIN.Display/id/559/index.cfm?fuseaction=ProductsPurchase.Select%20QX%20Product&d=QX&V=Standard";
        }
        else if(product == "gold")
        {
            obj.src = "ColdFusion/index.cfm/fuseaction/MAIN.Display/id/559/index.cfm?fuseaction=ProductsPurchase.Select%20QX%20Product&d=QX&V=Gold";
        }
        else if(product == "platinum")
        {
            obj.src = "ColdFusion/index.cfm/fuseaction/MAIN.Display/id/559/index.cfm?fuseaction=ProductsPurchase.Select%20QX%20Product&d=QX&V=Platinum";
        }
        else
        {
            obj.src = "ColdFusion/index.cfm/fuseaction/MAIN.Display/id/559/index.cfm?fuseaction=ProductsPurchase.Select%20QX%20Product&d=QX&V=Enterprise";
        }
        
        obj3.style.display = "block";
        obj3.style.visibility = "visible";
    }

}

function OrderOnlinePurchaseBack()
{
        //Hide iframe
        obj3 = document.getElementById('ctl00_QXContentLeft_ASPxPageControl1_OrderFrameWrap')
        if(obj3 != null)
        {
            obj3.style.visibility = "hidden";
            obj3.style.display = "none";
        }
        
        //Show regular form
        obj2 = document.getElementById('ctl00_QXContentLeft_ASPxPageControl1_ProSelect');
        if(obj2!= null)
        {
            obj2.style.visibility = "visible";
            obj2.style.display = "block";
        }
}

////////////////////////////////////
//  News Page Javascript
///////////////////////////////////

function NewsPage(ind){
    //Cannot use when autopostback is set to true on devexpress pagecontrol
    var obj2 = CL_NewsPageControl.GetTabByName(ind);
    CL_NewsPageControl.SetActiveTab(obj2);
}


////////////////////////////////////
//  Detailed Features Page 
///////////////////////////////////
function ShowFeaturesSubsection()
{                                      
    var obj = document.getElementById('ctl00_QXContentLeft_ShowSection');
    if(obj != null)
    {
        if(obj.value == "QX9")
        {
            obj = document.getElementById("QX9");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
        else if(obj.value == "QX8")
        {
            obj = document.getElementById("QX8");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
        else if(obj.value == "QX7")
        {
            obj = document.getElementById("QX7");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
        else if(obj.value == "QX6")
        {
            obj = document.getElementById("QX6");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
        else if(obj.value == "QX5")
        {
            obj = document.getElementById("QX5");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
        else if(obj.value == "QX4")
        {
            obj = document.getElementById("QX4");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
        else
        {
            obj = document.getElementById("QX9");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
    }
}

function DetailedFeat(divname)
{
    ShowDetailedFeat(divname);
    HideDetailedFeat(divname);
}

function ShowDetailedFeat(divname){
    obj = document.getElementById(divname);
    obj.style.display = "block";
    obj.style.visibility = "visible";
}

function HideDetailedFeat(divname){
        var obj2 = null;
        if(divname != "QX9"){
            obj2 = document.getElementById("QX9");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }
        if(divname != "QX8"){
            obj2 = document.getElementById("QX8");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }
        if(divname != "QX7"){
            obj2 = document.getElementById("QX7");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        } 
        if(divname != "QX6"){
            obj2 = document.getElementById("QX6");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }    
        if(divname != "QX5"){
            obj2 = document.getElementById("QX5");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        } 
        if(divname != "QX4"){
            obj2 = document.getElementById("QX4");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }            
}

////////////////////////////////////
//  3rd Party Solutions Page
///////////////////////////////////

function ShowThirdPartySubsection()
{
     var obj = document.getElementById('ctl00_QXContentLeft_ShowSection');
     if(obj != null){
        if(obj.value == "Solutions")
        {
            obj = document.getElementById("Solutions");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
        else if(obj.value == "Resellers")
        {
            obj = document.getElementById("Resellers");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }      
        else if(obj.value == "QXSDK")
        {
            obj = document.getElementById("QXSDK");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
        else{

            obj = document.getElementById("Overview");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
     }
     else{
        //do nothing
     }
}

function ThirdParty(divname)
{
    ShowThirdParty(divname);
    HideThirdParty(divname);
}

function ShowThirdParty(divname){
    obj = document.getElementById(divname);
    obj.style.display = "block";
    obj.style.visibility = "visible";
}

function HideThirdParty(divname){
        var obj2 = null;
        if(divname != "Solutions"){
            obj2 = document.getElementById("Solutions");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }
        if(divname != "Resellers"){
            obj2 = document.getElementById("Resellers");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }
        if(divname != "QXSDK"){
            obj2 = document.getElementById("QXSDK");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        } 
        if(divname != "Overview"){
            obj2 = document.getElementById("Overview");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }      
}

////////////////////////////////////
//  SuggestionBox Page
///////////////////////////////////
function ShowSuggestionSubsection()
{
     var obj = document.getElementById('ctl00_QXContentLeft_ShowSection');
     if(obj != null){
        if(obj.value == "SuggestionNotSubmitted")
        {
            obj = document.getElementById("SuggestionNotSubmitted");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
        else if(obj.value == "SuggestConfirm")
        {
            obj = document.getElementById("SuggestConfirm");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }      
        else if(obj.value == "SuggestionSubmitted")
        {
            obj = document.getElementById("SuggestionSubmitted");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
        else{

            obj = document.getElementById("SuggestSubmit");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
                CL_HTMLEDIT.Visible = true;
            }
        }
     }
     else{
        //do nothing
     }
}

function Suggestion(divname)
{
    ShowSuggestion(divname);
    HideSuggestion(divname);
}

function ShowSuggestion(divname){
    obj = document.getElementById(divname);
    obj.style.display = "block";
    obj.style.visibility = "visible";
    CL_HTMLEDIT.Visible = true;
}

function HideSuggestion(divname){
        var obj2 = null;
        if(divname != "SuggestionSubmitted"){
            obj2 = document.getElementById("SuggestionSubmitted");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }
        if(divname != "SuggestionNotSubmitted"){
            obj2 = document.getElementById("SuggestionNotSubmitted");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }
        if(divname != "SuggestConfirm"){
            obj2 = document.getElementById("SuggestConfirm");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        } 
        if(divname != "SuggestSubmit"){
            obj2 = document.getElementById("SuggestSubmit");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
            CL_HTMLEDIT.Visible = false;
        }      
}
////////////////////////////////////
//  Support Policy Page
///////////////////////////////////

//Check for which Support Policy section to show on initial load or GetURLstring
function ShowPolicySubsection()
{
     var obj = document.getElementById('ctl00_QXContentLeft_ShowSection');
     if(obj != null){

        if(obj.value == "KMCP")
        {
            obj = document.getElementById("KMCP");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
        else if(obj.value == "DataTransfer")
        {
            obj = document.getElementById("DataTransfer");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
                document.getElementById('iDL').src = "forms/DownloadTrial.aspx";
            }
        }      
        else
        {
            obj = document.getElementById("Support");
            if(obj != null)
            {
                obj.style.display = "block";
                obj.style.visibility = "visible";
            }
        }
     }
     else{
        //do nothing
     }
}

function Policy(divname){
    ShowPolicy(divname);
    HidePolicy(divname);
}

function ShowPolicy(divname){
    obj = document.getElementById(divname);
    obj.style.display = "block";
    obj.style.visibility = "visible";
}

function HidePolicy(divname){
        var obj2 = null;
        if(divname != "Support"){
            obj2 = document.getElementById("Support");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }
        if(divname != "KMCP"){
            obj2 = document.getElementById("KMCP");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }
        if(divname != "DataTransfer"){
            obj2 = document.getElementById("DataTransfer");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }        
}


/////////////////////////////////////
/// Learn More Page
///////////////////////////////////////////

//Check for which Learn More section to show on PostBack or initial load
function ShowLearnSubsection()
{

     obj = document.getElementById('ctl00_QXContentLeft_QXBannerTop_CurrPage');
     if(obj != null && obj.value != null){

        if(obj.value == "LPDRead")
        {
            Learn("LPDRead");
        }
        else if(obj.value == "LPDSubmit")
        {
            Learn("LPDSubmit");
        }
        else if(obj.value == "CommonQs")
        {
            Learn("CommonQs");
        }
        else if(obj.value == "DownloadSubmit")
        {
            Learn("DownloadSubmit");
        }
        else if(obj.value == "RequestCD")
        {
            Learn("RequestCD");
        }
        else if(obj.value == "QXFormsSubmit")
        {
            Learn("QXFormsSubmit");
        }
        else if(obj.value == "QXForms")
        {
            Learn("QXForms");
        }
        else if(obj.value == "QXMobile")
        {
            Learn("QXMobile");
        }            
        else
        {
            Learn("Overview");
        }
     }
     else{

        //do nothing
     }
}
//Show Learn Section, hide others
function Learn(divname){
    ShowLearn(divname);
    HideLearn(divname);
}

function ShowLearn(divname){
    if(divname == 'none')
    {
        divname = 'Overview';
    }

    obj = document.getElementById(divname);
    if(obj != null)
    {
        obj.style.display = "block";
        obj.style.visibility = "visible";
        //exectue iframe src change for loading speed
        if(divname == "LPDSubmit")
        {
            document.getElementById('iLPD').src = "forms/LPDRequest.aspx";
        }
        if(divname == "DownloadSubmit")
        {
            document.getElementById('iDL').src = "forms/DownloadTrial.aspx";
        }
        if(divname == "RequestCD")
        {
            document.getElementById('iCD').src = "forms/RequestCD.aspx";
        }
        if(divname == "QXFormsSubmit")
        {
            document.getElementById('iQXF').src = "forms/QXForms.aspx";
        }
    }
}

function HideLearn(divname){
        var obj2 = null;
        if(divname != "Overview"){
            obj2 = document.getElementById("Overview");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }
        if(divname != "LPDRead"){
            obj2 = document.getElementById("LPDRead");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }
        if(divname != "LPDSubmit"){
            obj2 = document.getElementById("LPDSubmit");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none";
        }
        if(divname != "DownloadSubmit")
        {
            obj2 = document.getElementById("DownloadSubmit");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none"; 
        }
        if(divname != "RequestCD")
        {
            obj2 = document.getElementById("RequestCD");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none"; 
        }
        if(divname != "QXForms")
        {
            obj2 = document.getElementById("QXForms");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none"; 
        }
        if(divname != "QXFormsSubmit")
        {
            obj2 = document.getElementById("QXFormsSubmit");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none"; 
        }
        if(divname != "QXMobile")
        {
            obj2 = document.getElementById("QXMobile");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none"; 
        }
        if(divname != "CommonQs")
        {
            obj2 = document.getElementById("CommonQs");
            obj2.style.visibility = "hidden";
            obj2.style.display = "none"; 
        }                
}

//function to change iframe height
function changeframe(framename,height)
{
	var new_height = height;
	var obj = document.getElementById(framename);
	if(obj != null)
	{
	    obj.height = new_height;
	}

}
/////////////////////////////////////
//QuickLinks from Product Page
//////////////////////////////////////

function QLinkLearn(divname)
{
    var currtab = CL_ProdIden.GetActiveTab().GetText();
    //Check if Learn tab is already selected
    if (currtab.indexOf("Learn") > -1) {
        Learn(divname);
    }
    else
    {
        obj = document.getElementById('ctl00_QXContentLeft_QXBannerTop_CurrPage');
        if(obj!=null)
        {
            obj.value = divname;
        }
        ProdPageSelect('Learn');
    }
}


///////////////////////////////////////////////////////////////
////////  Functions for Altering Tab Page Controls
///////////////////////////////////////////////////////////////

//function to select product tab pname is the tab name, sub is the subection
function ProdPageSelect(pname){
    //Cannot use when autopostback is set to true on devexpress pagecontrol
    var obj2 = CL_ProdIden.GetTabByName(pname);
    CL_ProdIden.SetActiveTab(obj2);
}

//Variable to indicate a tab is changed on the clientside
//var TabChangedCaseLoad = false;
//var initialCaseLoad = true;

//function to check when a call back has completed for the PageControl
function OnEndCallback(s, e) {
//now, does nothing!
    
}
//Function to catch on change event, cancel the change and 
//redirect to a different page
function OnActiveTabChanging(s,e){

    var tabname = e.tab.GetText();
    e.cancel = true;
    
    //redirect, as the page should have a parent window
    if (tabname.indexOf("Feat") > -1) {
        window.location.href = "Features.aspx";
    }
    else if (tabname.indexOf("Why") > -1) {
        window.location.href = "Why.aspx";
    }    
    else if (tabname.indexOf("Learn") > -1) {
        window.location.href = "Learn.aspx";
    }        
    else if (tabname.indexOf("Case") > -1) {
        window.location.href = "CaseStudies.aspx";
    }    
    else if (tabname.indexOf("Order") > -1) {
        window.location.href = "Order.aspx";
    }
    else{
        window.location.href = "Products.aspx";
    }   
}

//function to check when an tab has been changed
function OnActiveTabChanged(s,e){

        //Get Industry Category
        var mystr = "";
        var ind = document.getElementById('ctl00_QXContentLeft_L_indprod');
        if(ind !=null)
        {
            var mystr = "";
            if(ind.innerText == null || ind.innerText == "")
            {
                mystr = getCookie('industry');
            }
            else
            {
                mystr = ind.innerText;
            }
        }

    var mycurrtab = CL_ProdIden.GetActiveTab().GetText();
    if (mycurrtab.indexOf("Learn") > -1) {
            ShowLearnSubsection();
    }
    
    if(mycurrtab.indexOf("Case Studies") > -1)
    {
        var obj = document.getElementById('ctl00_QXContentLeft_QXBannerTop_Case');
        CL_CaseCallback.PerformCallback(obj.value); 
        selectSubGroup(mystr);
    }
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}
///////////////////////////////////////////////////////
/// Functions for Altering ASPXMenu ClientSideEvents
////////////////////////////////////////////////////////
var cbItems = new Array();


function selectSubGroup(category)
{
    // Select Case Studies Navbar
    groupobj = CL_RightNavBar.GetGroupByName('Case Studies');
    CL_RightNavBar.SetActiveGroup(groupobj);
    
    //Select Sub group based on category
    for(var i =0; i < cbItems.length; i++)
    {   
        if(cbItems[i][0] == 3)
        {
            CL_Cases = cbItems[i][1];
            groupobj = CL_Cases.GetGroupByName(category);
            CL_Cases.SetActiveGroup(groupobj);
        }
    }
}

function SetAndShowCase(caseid,category)
{
    //check for activetab
    var currtab = CL_ProdIden.GetActiveTab();
    if(currtab.name != 'CaseStudies')
    {
        var obj = document.getElementById('ctl00_QXContentLeft_QXBannerTop_Case');
        if(obj != null){
            obj.value = caseid;
        }
        TabChangedCaseLoad = true;
        ProdPageSelect('CaseStudies');
    }
    else
    {
        CL_CaseCallback.PerformCallback(caseid);
    }
    
    selectSubGroup(category);
    
}


//function to catch Item Click and display CaseStudy
function ItemClick(s, e){
    //check for page
    var currloc = window.location.pathname;
    //If on the case study page
    if(currloc.indexOf("Case") > -1 || currloc.indexOf("Studies") > -1)
    {
        CL_CaseCallback.PerformCallback(e.item.name);
    }
    else{

        //redirect to page
        window.location.href = "CaseStudies.aspx?caseid=" + e.item.name + "&Select=" + e.item.group.name;
    }


}
///////////////////////////////////////////////////////////////
////////  Functions for Altering PopUp Controls
///////////////////////////////////////////////////////////////


//function to hide the industry popup window
function HideIndPop(){
    CL_ChooseInd.Hide();
}

function ShowIndPop(){
    CL_ChooseInd.Show();
}

//function to show and hide Choose Day popup window
function ShowPrinterPop(){
    CL_ShowPrinters.Show();
}
//function to show the 10 QB demands
function ShowDemands(){
    CL_10Demands.Show();
}
//function to show 30 day moneyback guarentee
function ShowGuarentee(){
    CL_Guarentee.Show();
}
//function to show Rental popup message
function RentalPop(){
    CL_Rental.Show();
}
//function to show Purchase popup message
function PurchasePop(){
    CL_Purchase.Show();
}
//function to show Service minutes popup message
function ShowServiceMin()
{
    CL_Service.Show();
}
//function to show EULA message
function ShowEULA(){
    CL_EULA.Show();
}

//Function to show Learn More Email window
function ShowEmail(){
    CL_Email.Show();
}

//Function to show Telephone Support popup window
function ShowTelephone()
{
    CL_Telephone.Show();
}

//Function to show KMCP Popup message
function ShowKMCP(){
    CL_KMCP.Show();
}

//Function to show Username Popup message
function ShowUsername(){
    CL_Username.Show();
}

//Function to show WorkFlow diagram
function ShowWorkflow(){
    CL_Workflow.Show();
}

function ShowDownload(){
    CL_DOWNLOADWIN.Show();
}

//SHOW PRODUCT SHIPPING OPTIONS
function ShowShip1()
{
    CL_Ship1.Show();
}
function ShowShip2()
{
    CL_Ship2.Show();
}
function ShowShip3()
{
    CL_Ship3.Show();
}


//Show Product Features star popups
function ShowStar(val)
{
    
    //make sure an industry has been selected
    
    objlbl = document.getElementById('lblStar');
    if(objlbl != null)
    {
        objlbl.innerHTML = val;
        CL_Star.Show();
    }
}

//function to show the MovieTutorial Popup in the center of the window
function LoadQXMovie(Murl){
    
    FadeOpacity('fadecontainer',100,25,300,8);
    CL_MPlay.Show();
    document.getElementById('qxbody').style.backgroundImage = "url(Images/Bg_Grad3.jpg)";
    document.getElementById('qxbody').style.backgroundColor = "#8B8B8B";   
   
    document.getElementById('hiddenURL').value = "http://www.alocet.net/movietutorials/" + Murl + "/Flash.html";Murl;
    
}

function ShowMovie()
{
    setTimeout('timedoutshow()',300);
}

function timedoutshow()
{
    frames['iMplay'].location.href = document.getElementById('hiddenURL').value;
    
    document.getElementById('iMplay').height = "600px";
    document.getElementById('iMplay').width = "800px";
    var url = document.getElementById('hiddenURL').value;
    if(url.indexOf("Menu") > -1)
    {
      document.getElementById('iMplay').height = '608px';
    //document.getElementById('iMplay').width = '796px';
    }
}

function SetOpacity(elem, opacityAsInt)
{
    var opacityAsDecimal = opacityAsInt;
    
    if (opacityAsInt > 100)
        opacityAsInt = opacityAsDecimal = 100; 
    else if (opacityAsInt < 0)
        opacityAsInt = opacityAsDecimal = 0; 
    
    opacityAsDecimal /= 100;
    if (opacityAsInt < 1)
        opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0
    
    elem.style.opacity = (opacityAsDecimal);
    elem.style.filter  = "alpha(opacity=" + opacityAsInt + ")";
}
function FadeOpacity(elemId, fromOpacity, toOpacity, time, fps)
{
    var steps = Math.ceil(fps * (time / 1000));
    var delta = (toOpacity - fromOpacity) / steps;
    
    FadeOpacityStep(elemId, 0, steps, fromOpacity, 
                    delta, (time / steps));
}

function FadeOpacityStep(elemId, stepNum, steps, fromOpacity, delta, timePerStep)
{
    SetOpacity(document.getElementById(elemId), 
               Math.round(parseInt(fromOpacity) + (delta * stepNum)));

    if (stepNum < steps)
        setTimeout("FadeOpacityStep('" + elemId + "', " + (stepNum+1) 
                 + ", " + steps + ", " + fromOpacity + ", "
                 + delta + ", " + timePerStep + ");", 
                   timePerStep);
}

//pop the movie demonstration in a new window
function moviepop(Murl, ev){
    var obj = document.getElementById("MoviePlayer");
    obj.style.visibility = "visible";
    
    
    var e = ev ? ev : window.event;
    var s = e.clientX + ',' + e.clientY;
    alert(s);
    //set pic:
    obj.style.top = e.clientY - 10;
    
    
    frames['iMplay'].location.href = "http://www.alocet.net/movietutorials/" + Murl + "/Flash.html";
   document.getElementById('iMplay').height = "600px";
    document.getElementById('iMplay').width = "800px";
    
    //Hide the right navbar as it floats overtop
    var currloc = window.location.pathname;
    if(currloc!= null)
    {

        var obj2 = document.getElementById('ctl00_QXContentRight_Menudiv');
        if(obj2 != null)
        {
            obj2.style.visibility = "hidden";
            obj2.style.display = "none"; 
        }
    }
    
}

function movieclose(){
    document.getElementById('qxbody').style.backgroundImage = "url(Images/Bg_Grad2.jpg)";
    document.getElementById('qxbody').style.backgroundColor = "#3985dd"; 
    frames['iMplay'].location.href = "about:blank";
    FadeOpacity('fadecontainer',25,100,300,8);
    
    //Hide the right navbar as it floats overtop
    var currloc = window.location.pathname;
    if(currloc!= null)
    {
        //If on the Products page
        var obj2 = document.getElementById('ctl00_QXContentRight_Menudiv');
        if(obj2 != null)
        {
            obj2.style.visibility = "visible";
            obj2.style.display = "block";
        }

    }
}

//pop the movie tutorial in a new window
function movieTutPop(num){

    document.getElementById('qxbody').style.backgroundImage = "url(Images/Bg_Grad3.jpg)";
    document.getElementById('qxbody').style.backgroundColor = "#8B8B8B"; 
    FadeOpacity('fadecontainer',100,25,300,8);
    CL_MPlay.Show();
    var Murl = "";
    
    if(num==1){
        Murl = "http://www.alocet.net/utilities/custdb/CleaningIndustry/CleaningIndustryMenu.html";
    }
    else if(num==2){
        Murl = "http://www.alocet.net/utilities/custdb/IrrigationIndustry/IrrigationIndustryMenu.html";
    }
    else if(num==3){
        Murl = "http://www.alocet.net/utilities/custdb/LandscapingIndustry/LandscapingIndustryMenu.html";
    }
    else if(num==4){
        Murl = "http://www.alocet.net/utilities/custdb/LawnMaintenanceIndustry/LawnMaintenanceIndustryMenu.html";
    }
    else if(num==5){
        Murl = "http://www.alocet.net/utilities/custdb/LawnAndTreeSprayingIndustry/LawnAndTreeSprayingIndustryMenu.html";
    }  
    else if(num==6){
        Murl = "http://www.alocet.net/utilities/custdb/PestControlIndustry/PestControlIndustryMenu.html";
    }   
    else if(num==7){
        Murl = "http://www.alocet.net/utilities/custdb/PlumbingIndustry/PlumbingIndustryMenu.html";
    }
    else if(num==8){
        Murl = "http://www.alocet.net/utilities/custdb/PoolMaintenanceIndustry/PoolMaintenanceIndustryMenu.html";
    }  
    else if(num==9){
        Murl = "http://www.alocet.net/utilities/custdb/SnowRemovalIndustry/SnowRemovalMenu.html";
    }   
      
    document.getElementById('hiddenURL').value = Murl;
}

////////////////////////////////////////////////////////////////
//function for closing a QXPopup
/////////////////////////////////////////////////////////////////
function CloseQXWin(wname)
{
    var obj = document.getElementById(wname);
    obj.style.visibility = "hidden";
}


////////////////////////////////////////////////////////////////
//function for opening a QXPopup and positioning it vertically
////////////////////////////////////////////////////////////////
function OpenQXWin(wname,pos){
    var obj = document.getElementById(wname);
    obj.style.visibility = "visible";
    
    var obj2 = document.getElementById(pos);
    var Ypos = findPosY(obj2);
    var Xpos = findPosX(obj2);
    var Ypos = Ypos - 220;  
    obj.style.top = Ypos.toString() + 'px'; 
}


function findPosX(obj)
 {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
   else if(obj.x)
        curleft += obj.x;
   return curleft;
 }

function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

///////////////////////////////////////////////////////////////////////////////
// function which closes an old window and opens a new one at the same position
////////////////////////////////////////////////////////////////////////////////
function ReplaceWin(oldwin,newwin){
    
       CloseQXWin(oldwin);
       OpenQXWin(newwin,oldwin);
}

function SetCook(val)
{
    if(val == 1)
    {
        Set_Cookie("SiteTracker","1","99","/","","");
    }
    else if(val == 2)
    {
        Set_Cookie("SiteTracker","2","99","/","","");
    }
    else if(val == 3)
    {
        Set_Cookie("SiteTracker","3","99","/","","");
    }
    
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}
