﻿function ISC_Exception(msg)
{
	try
	{
		var strInfo = "<b>ISC Error Message:</b> "+msg+"<br /><b>URL:</b> "+document.location.href+"<br /><hr />";
		var strParams = "strErrorMsg="+strInfo.replace("&", "&#38;")+getDebugInfo().replace("&", "&#38;")+"&strSubject=JS_ISC-EXCEPTION&bIsHtmlMsg=true";
		ajaxPost(strParams,location.protocol+"//"+location.hostname+"/ws/tcws.asmx/LogError", null);
   }
   catch(ex){/*carry on*/}
}

function isc_notification(objType,task,sectionId,result){
    try
        { 
        switch (objType) 
        {
            case "Band":
                switch (task) {
                    case "Visible":
                        // result = true / false
                        break;
                }
                break;
             case "Movie":
                switch (task) {
                    case "Stage":
                        // result = <scale> Invalid, Set to <scale>
                        break;
                }
             case "Section":
                switch (task) {
                    case "Highlight":
                        /// result = highlighed / normal */
                        break;
                    case "Rollover":
                        /* result = On / Off */
                        break;
                    case "Selected":
                        /* result = true / false */
                        var IMCookie = "IM_" + getPageName().toUpperCase();
                        if(readCookie(IMCookie)!='' && readCookie(IMCookie)!=null)//cookie exists - so append it
                        {
                           var old_cookie = readCookie(IMCookie);
                           eraseCookie(IMCookie);
                           if (old_cookie.indexOf("'" + sectionId + "_'") != -1)
                           {   
                               old_cookie = old_cookie.replace("'"+sectionId + "_'", ""); 
                               createCookie(IMCookie, old_cookie)
                               filterBySection(readCookie(IMCookie));   
                           }
                           else
                           {
                                createCookie(IMCookie, old_cookie+"'"+sectionId+"_'");
                                filterBySection(readCookie(IMCookie));  
                            }
                             
                        }
                        else
                        {  
                            createCookie(IMCookie, "'"+sectionId+"_'");                             
                            filterBySection(readCookie(IMCookie));  
                        }
                        if (returnObj("divDetailedIMapInstructionsWrapper").style.display=="")
                        {
                            showHideMapInstructions('hide');                              
                        }
                        break;
                    case "Status":
                        /* result = not found */
                        break;
                }
                break;
            case "SectionNames":
                switch (task) {
                    case "Visible":
                        /* result = true / false */
                        break;
                }
                break;
            case "Venue":
                switch (task) {
                    case "Status":
                        /* result = loaded, error loading venue <name>, Error <desc> */
                        break;
                }
                break;
        }
}
catch(ex)
{
    var strParams = "strErrorMsg="+getDebugInfo()+getExceptionInfo(ex)+"&strSubject=JS_Exception_isc_Notification&bIsHtmlMsg=true";  
    ajaxPost(strParams,location.protocol+"//"+location.hostname+"/ws/tcws.asmx/LogError", null);    
}      
}

 function  filterBySection(sectionNames)
 {
    try
    {
        var strSortDirection = "ASC";
        var strSortField = "Price";
        strSortField=returnObj("hidSortField").obj.value;
        strSortDirection=returnObj("hidSortDirection").obj.value;

        var strServiceURL =  location.protocol+"//"+location.hostname+"/ws/tcws.asmx/GetTicketList";
        var nBrokerID = returnObj("hidBrokerId").obj.value;
        var nEventID = returnObj("hidEventId").obj.value;
        var nMinPrice = returnObj("ddMinPrice").obj.options[returnObj("ddMinPrice").obj.selectedIndex].value;
        var nMaxPrice = returnObj("ddMaxPrice").obj.options[returnObj("ddMaxPrice").obj.selectedIndex].value;
        var nQty = returnObj("ddFilterQty").obj.options[returnObj("ddFilterQty").obj.selectedIndex].value;
        var strFilter = returnObj("hidFilter").obj.value;
        var strFilterParking = returnObj("chkFilterParking").obj.checked.toString(); 
        var bTransform = "true"; 

        showHide("divTicketListingsLoading","show");
        showHide("divTicketListings","hide");
        showHide("divTicketListingsAjax","hide"); 
        showHide("divTicketFilters","hide");
        showHide("divTicketColumnHeaders","hide"); 
        showHide("divTicketSummary","hide"); 

        var strParams = "BrokerID="+nBrokerID+"&EventID="+nEventID+"&MinPrice="+nMinPrice+"&MaxPrice="+nMaxPrice+"&Qty="+nQty+"&Sort="+strSortField+" "+strSortDirection+"&Filter="+strFilter+"&Transform="+bTransform+"&SectionList="+sectionNames+"&FilterParking="+strFilterParking;
        ajaxPost(strParams,strServiceURL,"renderTickets");	   
    }
    catch(ex)
    {
        var strParams = "strErrorMsg="+getDebugInfo()+getExceptionInfo(ex)+"&strSubject=JS_Exception_filterBySection&bIsHtmlMsg=true";  
        ajaxPost(strParams,location.protocol+"//"+location.hostname+"/ws/tcws.asmx/LogError", null);    
    }	    
 }

 function reloadFlashMap()
 {
    try
    {
        var IMCookie = "IM_" + getPageName().toUpperCase();
	    
        eraseCookie(IMCookie); 	 /* Start Fresh */
        
        isc_clearSelected();
     }
    catch(ex)
    {
        var strParams = "strErrorMsg="+getDebugInfo()+getExceptionInfo(ex)+"&strSubject=JS_Exception_reloadFlashMap&bIsHtmlMsg=true";  
        ajaxPost(strParams,location.protocol+"//"+location.hostname+"/ws/tcws.asmx/LogError", null);    
    }         

 }
function showHideMapInstructions(method)
{ 
    if(method=="show")
    { 
        returnObj("divTicketListingsWrapper").style.display="none";
        returnObj("divDetailedIMapInstructionsWrapper").style.display="";
    }
    else /*hide*/
    {
        returnObj("divTicketListingsWrapper").style.display="";
        returnObj("divDetailedIMapInstructionsWrapper").style.display="none";
    }
}	 

