function appObj() {
    //alert("app");
    this.specArr = new Array();
    this.catArr = new Array();
    this.viewArr = new Array();
    this.OfferArr = new Array();
    this.sortView = {s1:"none",s2:"none"};
    this.filtCat = "";
    this.filtering = {options:"",values:""};
    this.filtered = false;
    this.Col = new ColumnsObj();
    this.emailName = "";
    this.emailAddr = "";
    this.emailDetails = "";

    this.addSpec = function(specObj) {
    // Add new Special object to the specials array 'app.specArr' with the next
    // parameters in the object:
    // .CatID, .Id, .Dest, .Thumb, .Heading, .Pricefrom, .Currency, .CSign,
    // .CatTitle, .HTML
    //
    // return: nothing.
        
        this.specArr[this.specArr.length] = specObj;
    }    

    this.addCat = function(category) {
    // Add new Category object to the array 'app.catArr' with the category name
    // 'category' (col.Title), with the index of array lenght position as
    // category id (col.ID) and the html structure of the category (col.HTML).
    //
    // return: the id of the inserted or existing category.
        
        for (j=0; j<this.catArr.length; j++) {
            if (this.catArr[j].Title == category) {
                return j;
            }
        }
        this.Col.addNew(j,category);
        //$('#specials_main').append(app.catArr[j].HTML); //print into html
        return j;
    }
    
    this.getCatId = function(sid) {
    // geting the category id of the specific spesial id (sid)
    //
    // return: category id.
        
        for (i=0; i<this.viewArr.length; i++)
            if (this.viewArr[i].Id == sid)
                return this.viewArr[i].CatID
        return -1
    }

    this.buildView = function(specObjArr) {
    // build the view array, show all specials.
    //
    // return: nothing.
        
        this.viewArr = new Array();   // init viewArr
        if (typeof(specObjArr) == "undefined") {
            for (i=0; i<this.specArr.length; i++) {
                this.viewArr[this.viewArr.length] = this.specArr[i];
            }
        } else {
            for (i=0; i<specObjArr.length; i++) {
                this.viewArr[this.viewArr.length] = specObjArr[i];
            }
        }
    }
    
 //////////////////////////////////////////////////////////////////////////////
 //////////////////////   B E G I N   S O R T I N G   /////////////////////////
 ///                                                                        ///
    this.orderView = function() {
    // order specials view array (category >> 'order1' >> 'order2').
    //
    // return: nothing.
        
        if (app.sortView.s1=="price" && app.sortView.s2=="none") {
        // order first sorting by price only
        
            for (i=this.viewArr.length; i>1; i--) {  
                for (j=1; j<i; j++) {
                    if (this.viewArr[j-1].Pricefrom > this.viewArr[j].Pricefrom) {  //order asc.
                        temp = this.viewArr[j-1];
                        this.viewArr[j-1] = this.viewArr[j];
                        this.viewArr[j] = temp;
                    }
                }
            }
        } else if (app.sortView.s1=="dest" && app.sortView.s2=="none") {
        // order first sorting by destination only
        
            for (i=this.viewArr.length; i>1; i--) {
                for (j=1; j<i; j++) {
                    if (this.viewArr[j-1].Dest > this.viewArr[j].Dest) {  //order asc.
                        temp = this.viewArr[j-1];
                        this.viewArr[j-1] = this.viewArr[j];
                        this.viewArr[j] = temp;
                    }
                }
            }
        } else if (app.sortView.s1=="price" && app.sortView.s2=="dest") {
        // order first sorting by price and second sorting by destination
            for (i=this.viewArr.length; i>1; i--) { 
                for (j=1; j<i; j++) {
                    if (this.viewArr[j-1].Pricefrom > this.viewArr[j].Pricefrom) {  //order asc.
                        temp = this.viewArr[j-1];
                        this.viewArr[j-1] = this.viewArr[j];
                        this.viewArr[j] = temp;
                    } else if (this.viewArr[j-1].Pricefrom == this.viewArr[j].Pricefrom) {  
                        if (this.viewArr[j-1].Dest > this.viewArr[j].Dest) {  //order asc.
                            temp = this.viewArr[j-1];
                            this.viewArr[j-1] = this.viewArr[j];
                            this.viewArr[j] = temp;
                        }
                    }
                }
            }
        } else if (app.sortView.s1=="dest" && app.sortView.s2=="price") {
        // order first sorting by destination and second sorting by price
            for (i=this.viewArr.length; i>1; i--) {
                for (j=1; j<i; j++) {
                    if (this.viewArr[j-1].Dest > this.viewArr[j].Dest) {  //order asc.
                        temp = this.viewArr[j-1];
                        this.viewArr[j-1] = this.viewArr[j];
                        this.viewArr[j] = temp;
                    } else if (this.viewArr[j-1].Dest == this.viewArr[j].Dest) {  
                        if (this.viewArr[j-1].Pricefrom > this.viewArr[j].Pricefrom) {  //order asc.
                            temp = this.viewArr[j-1];
                            this.viewArr[j-1] = this.viewArr[j];
                            this.viewArr[j] = temp;
                        }
                    }
                }
            }
        }
        
        // after all order by category
        for (i=this.viewArr.length; i>1; i--) {  
            for (j=1; j<i; j++) {
                if (this.viewArr[j-1].CatID > this.viewArr[j].CatID) {  //order asc.
                    temp = this.viewArr[j-1];
                    this.viewArr[j-1] = this.viewArr[j];
                    this.viewArr[j] = temp;
                }
            }
        }
        if (g('OP_order_but') && typeof app.order=="object") {
            g('order_content').innerHTML = app.order.tmpHTML;
            g('OP_order_but').style.display = '';
            for (i=0; i<this.order.SpecDetails.Columns.length; i++) {
                $('#num_'+i+'_'+app.order.aid).removeAttr("disabled");
            }
            app.order = undefined;
            
        }
        //app.debugView();
    }
 ///                                                                        ///
 ////////////////////////   E N D   S O R T I N G   ///////////////////////////
 //////////////////////////////////////////////////////////////////////////////
    
    this.showSpec = function() {
    // show special in each category and divide it to parts 
    //
    // return: nothing.
        
        $('#specials_main').html('&nbsp;'); // clear result div id: specials_main
        ncat = this.Col.showCat(); //show categories and return number categories showed
        shownext = 10; // number of specials to show more
        strco = new Array();
        
        for (k=0; k<this.viewArr.length; k++) {
            sid = this.viewArr[k].Id;
            cid = this.viewArr[k].CatID;
            curpos = app.specPos(sid,cid);
            lastpos = app.viewCount(cid)-1;
            if (curpos%shownext==0 && curpos!=0) {
                if (typeof(strco[cid])=="undefined") strco[cid] = 0;
                htm = "<div class=\"more_specials\" id=\"more_click_"+cid+"_"+strco[cid]+"\" style=\"display:";
                
                if (strco[cid] == 0) {
                    strco[cid] = 1;
                    htm += "block";
                } else {
                    strco[cid]++;
                    htm += "none";
                }
                
                htm += "\" onclick=\"";
                shownext1 = shownext;
                for (i=0; i<shownext; i++) {
                    if (typeof(this.viewArr[k+i]) != "undefined" && this.viewArr[k+i].CatID == cid)
                        htm += "g('sp"+this.viewArr[k+i].Id+"').style.display = 'block'; ";
                    else {
                        shownext1--;
                        strco[cid] == -1;
                    }
                }
                
                htm += "this.style.display = 'none'; ";
                
                if (strco[cid] != -1)
                    htm += "g('more_click_"+cid+"_"+strco[cid]+"').style.display = 'block';";
                    
                htm += "\" onmouseover=\"this.style.color='#7bb8be'; this.style.textDecoration='underline'\""
                    +" onmouseout=\"this.style.color='#0472b2'; this.style.textDecoration='none'\">הצג עוד "+shownext1+" מבצעים</div>";
                $('#cat_'+cid+'_content').append(htm);
            }
            $('#cat_'+cid+'_content').append(this.viewArr[k].HTML());
            this.viewArr[k].addPopups();
            if (curpos>=shownext) {
                g('sp'+this.viewArr[k].Id).style.display = "none";
            }
        }
    }
    
    this.debugView = function() {
        txt="";
        for (i=0; i<app.viewArr.length; i++) {
            txt+=i+"\t"+app.viewArr[i].Id+"\t"+app.viewArr[i].CatTitle+(((app.viewArr[i].CatTitle=="שייט")||(app.viewArr[i].CatTitle=="קצר וזול"))?"\t":"")+"\t"+app.viewArr[i].Dest+"\t"+app.viewArr[i].Pricefrom+"\n";
        }
        txt +="\n\ntotal: "+i;
        alert(txt);
    }
    
    this.filterAll = function(refresh,lastFilt,filtVal) {
    // filter all we need using the order in app.filtering variable.
    //
    // return: number of specials filtered.
        
        if (typeof(lastFilt) == "undefined") lastFilt="";
        
        opt_order = new Array();
        opt_order_t = new Array();
        opt_order = app.filtering.options.split("@,@");
        val_order = new Array();
        val_order_t = new Array();
        val_order = app.filtering.values.split("@,@");
        
        app.rebuild.mkChange.category();
        //alert(app.filtCat);
        for (counter=0; counter<opt_order.length; counter++) {
            if (opt_order[counter] != lastFilt && opt_order[counter] != "") {
                v = val_order[counter];
                o = opt_order[counter];
                //alert("("+counter+") app.rebuild.mkChange."+o+"('"+v+"');");
                eval("app.rebuild.mkChange."+o+"('"+v+"');");
                opt_order_t[opt_order_t.length] = o;
                val_order_t[val_order_t.length] = v;
            }
        }
        if (lastFilt != "") {
            eval("app.rebuild.mkChange."+lastFilt+"('"+filtVal+"');");
            opt_order_t[opt_order_t.length] = lastFilt;
            val_order_t[val_order_t.length] = filtVal;
        }
        app.filtering.options = opt_order_t.join("@,@");
        app.filtering.values = val_order_t.join("@,@");
        //alert("app.filtering.options="+app.filtering.options);
        //alert("app.filtering.values="+app.filtering.values);
        
        return refresh?app.rebuild.all():-1;
    }
    
    this.viewCount = function(cid) {
    // count of specials in view array.
    //
    // return: number of specials in the 'cid' category id. if 'cid' not given,
    //         return all view specials
        
        if (typeof(cid) == "undefined") return app.viewArr.length;
        co1 = 0;
        for (i=0; i<app.viewArr.length; i++) {
            if (app.viewArr[i].CatID == cid) {
                co1++;
            }
        }
        return co1;
    }
    
    this.specPos = function(sid,cid) {
    // count the special position with special id 'sid' in the category id 'cid'.
    //
    // return: special position in the category. if cid
        
        co = 0;
        for (i=0; i<app.viewArr.length; i++) {
            if (typeof(cid) == "number")
                if (app.viewArr[i].CatID==cid) {
                    if (app.viewArr[i].Id==sid)
                        return co;
                    co++;
                }
            else
                if (app.viewArr[i].Id==sid)
                    return i;
        }
        return -1;
    }
    
    this.waitSpecials = function() {
        htm = "<div class=\"wait_specials\">הדף טוען, אנא המתינו ...</div>";
        $("#specials_main").html(htm);
    }
    
    this.emptySpecials = function() {
        htm = "<div class=\"empty_specials\">לא נמצאו תוצאות כלשהן לסינון שביצעתם.<br>בכדי להציג את כל התוצאות <span style=\"text-decoration:underline; cursor:pointer;\" onclick=\"initiate_all();\">לחצו כאן</span>.</div>";
        $("#specials_main").html(htm);
    }
    
    this.rebuild = {
    // rebuild the viewArr by filter and sorting
    //
    // return: number of specials filtered
        
        filter : {  // app.rebuild.filter   -  make synchronizing with all filters
            category : function(cats,refresh) { // turn to filter by categories
                app.filtCat = cats;
                return app.filterAll(refresh);
            },
            numppl : function(ppl,refresh) {  // turn to filter by number of people
                return app.filterAll(refresh,"numppl",ppl);
            },
            destination : function(dest,refresh) {  // turn to filter by destination
                return app.filterAll(refresh,"destination",dest);
            },
            dates : function(bDate,eDate,refresh) {  // turn to filter by dates
                return app.filterAll(refresh,"dates",bDate+"','"+eDate);
            },
            price : function(price,refresh) {  // turn to filter by price
                return app.filterAll(refresh,"price",price);
            }
        },
        mkChange : {  // effect changes directly on app.viewArr
            category : function() { // filter by categories
                arr = new Array();
                arr = app.filtCat.split(",");
                tmpArr = new Array();
                for (i=0; i<arr.length; i++) {
                    for (j=0; j<app.specArr.length; j++) {
                        //alert("if ('"+arr[i]+"' == '"+app.specArr[j].CatTitle+"')");
                        if (app.specArr[j].CatTitle.search(arr[i]) != -1) {
                            tmpArr[tmpArr.length] = app.specArr[j];
                        }
                    }
                }
                app.buildView(tmpArr);
                //app.debugView();
                if (app.filtCat == "") {
                    app.buildView();
                    //app.debugView();
                }
            },
            numppl : function(ppl) {  // filter by number of people
                tmpArr = new Array();
                for (i=0; i<app.viewArr.length; i++) {
                    arr = new Array();
                    arr = app.viewArr[i].People.split("-");
                    if (ppl>=parseInt(arr[0]) && ppl<=parseInt(arr[1])) {
                        tmpArr[tmpArr.length] = app.viewArr[i];
                    }
                }
                app.buildView(tmpArr);
            },
            destination : function(dest) {  // filter by destination
                tmpArr = new Array();
                for (i=0; i<app.viewArr.length; i++) {
                    if ((typeof(dest)=="undefined") || (dest=="") || (dest=="all") || (app.viewArr[i].Dest.search(dest)!=-1)) {
                        tmpArr[tmpArr.length] = app.viewArr[i];
                    }
                }
                app.buildView(tmpArr);
            },
            dates : function(bDate,eDate) {  // filter by dates
                tmpArr = new Array();
                filtBeg = parseInt(bDate);
                filtEnd = parseInt(eDate);
                for (i=0; i<app.viewArr.length; i++) {
                    specBeg = parseInt(app.viewArr[i].Month.split("-")[0]);
                    specEnd = parseInt(app.viewArr[i].Month.split("-")[1]);
                    if (specBeg > specEnd) specEnd+=12;
                    if (filtBeg > filtEnd) filtEnd+=12;
                    if ((specBeg>=filtBeg && specBeg<=filtEnd) || (specEnd>=filtBeg && specEnd<=filtEnd) || (filtBeg>=specBeg && filtBeg<=specEnd)) {
            // special  [     b-------e   or       b---e     ] || [ b-------e       or       b---e     ] || [ b-------e       or    b-----------e ]
            // filter   [ b-------e            b-----------e ] || [     b-------e        b-----------e ] || [     b-------e             b---e     ]
                        tmpArr[tmpArr.length] = app.viewArr[i];
                    }
					if (filtEnd>12) {
						if ((specBeg>=1 && specBeg<=filtEnd-12) || (specEnd>=1 && specEnd<=filtEnd-12) || (1>=specBeg && 1<=specEnd)) {
							tmpArr[tmpArr.length] = app.viewArr[i];
						}
					}
                }
				//alert("begin: "+filtBeg+"\nend: "+filtEnd);
                app.buildView(tmpArr);
            },
            price : function(price) {  // filter by price
                arr = new Array();
                arr = price.split("|");
                bPrice=parseInt(arr[0]); ePrice=parseInt(arr[1]);
                tmpArr = new Array();
                for (i=0; i<app.viewArr.length; i++) {
                    if (app.viewArr[i].Pricefrom >= bPrice && app.viewArr[i].Pricefrom <= ePrice) {
                        tmpArr[tmpArr.length] = app.viewArr[i];
                    }
                }
                app.buildView(tmpArr);
                //app.debugView();
            }
        },
        sort1 : function(sort,refresh) {  // first sorting : app.rebuild.sort1(sort)
            app.sortView.s1 = sort;
            app.sortView.s2 = sort=="none"?"none":app.sortView.s2;
            return refresh?app.rebuild.all():-1;
        },
        sort2 : function(sort,refresh) {  // second sorting : app.rebuild.sort2(sort)
            app.sortView.s2 = sort;
            return refresh?app.rebuild.all():-1;
        },
        all : function() {  // reorder and show all specials grouped by categories
            app.orderView();
            app.showSpec();  // show specials
            if (app.viewArr.length==0) {
                app.emptySpecials();
            }
            return app.viewArr.length;
        }
        
    }
    
    this.DebugObjDump = function(obj, name, indent, depth) {
    // dump the contents of any object.
    // debug function.
    //
    // return: object dumping
        
        if (typeof indent == "undefined") indent="";
        if (typeof depth == "undefined") depth=0;
        if (depth > 10) {
            return indent + name + ": <Maximum Depth Reached>\n";
        }
        if (typeof obj == "object") {
            var child = null;
            var output = indent + name + "\n";
            indent += "\t";
            for (var item in obj)
            {
                try {
                    child = obj[item];
                } catch (e) {
                    child = "<Unable to Evaluate>";
                }
                if (typeof child == "object") {
                    output += this.DebugObjDump(child, item, indent, depth + 1);
                } else {
                    output += indent + item + ": " + child + "\n";
                }
            }
            return output;
        } else {
            return obj;
        }
    }
    
    this.addSpecPrices = function(sid,cols,included,not_included,terms,prices) {
    // adding prices information to the each special parameter and object
    //
    // return: nothing.
        
        //alert(app.DebugObjDump(cols,"cols","",0));
        //alert(app.DebugObjDump(prices,"prices"));

        for (i=0; i<this.viewArr.length; i++) {
            if (this.viewArr[i].Id == sid) break;
        }
        
        htm = ""
            +'<div style="text-align:right;font-size:14px;border-bottom:1px dashed #00c505">בחר מחיר:</div>'
            +"<table class=\"prices_table\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\">"
            +"<tr>"
            +"  <td class=\"prices_table_top-right_td\" valign=\"bottom\"><div class=\"prices_table_top prices_table_header\">תאריכים</div></td>"
            +"";
        for (c=0; c<cols.ppl.length; c++) {
            htm += "    <td class=\"prices_table_top_td\" valign=\"bottom\"><div class=\"prices_table_top prices_table_cell\">"+cols.desc[c]+"</div></td>";
            this.viewArr[i].prices.ppl[c] = parseInt(cols.ppl[c]);
            this.viewArr[i].prices.desc[c] = cols.desc[c];
        }
        
        htm += "</tr></table>";
        htm += "<div id=\"prices-table-div\">"
            +"<table class=\"prices_table\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\">"
        
        for (c=0; c<prices.price.length; c++) {  //rows
            this.viewArr[i].prices.flight[c] = prices.flight[c];
            if (prices.date_from[c]=="" && prices.date_to[c]=="") {
                this.viewArr[i].prices.date_from[c] = "";
                this.viewArr[i].prices.date_to[c] = "";
                this.viewArr[i].prices.dates[c] = prices.flight[c];
            } else {
                df = prices.date_from[c];   //from
                dt = prices.date_to[c];     //to
                dfy = df[2]%100<10 ? "0"+df[2]%100 : df[2]%100
                dty = dt[2]%100<10 ? "0"+dt[2]%100 : dt[2]%100
                this.viewArr[i].prices.date_from[c] = df[0] + df[1] + df[2]
                this.viewArr[i].prices.date_to[c]   = dt[0] + dt[1] + dt[2]
                if (parseInt(dt[0])!=parseInt(df[0])) {
                    if (parseInt(dt[1])!=parseInt(df[1])) {
                        this.viewArr[i].prices.dates[c] = "מ " + df[0]+"/"+df[1] + " עד " + dt[0]+"/"+dt[1] + ", " + (df[2]==dt[2]?df[2]:df[2]+"-"+dt[2])
                    } else {
                        this.viewArr[i].prices.dates[c] = df[0]+"-"+dt[0] + "/" + df[1] + "/" + dfy
                    }
                }
            }
            
            this.viewArr[i].prices.price[c] = new Array();
            prcs = prices.price[c];
            counter = 0;
            for (x=0; x<prcs.length; x++)
                if (prcs[x] == "")
                    counter++
            if (counter<prcs.length) {   //cols
                htm += "<tr class=\"prices_table_prices\">"
                htm += "<td class=\"prices_table_content-right_td\"><div class=\"prices_table_header\">"+this.viewArr[i].prices.dates[c]+"</div></td>"
                for (cin=0; cin<prcs.length; cin++) {
                    if (prcs[cin] == "") {
                        htm+= "<td id=\"cell"+sid+"_"+c+"_"+cin+"\" class=\"prices_table_content_td\" style=\"cursor:default\">&nbsp;</td>"
                    } else {
                        htm+= "<td id=\"cell"+sid+"_"+c+"_"+cin+"\" class=\"prices_table_content_td\" "
                            +"onclick=\"app.addOffer("+sid+","+cin+","+c+")\" "
                            +"title=\"לחץ על המחיר בכדי להוסיף להצעות מחיר\" alt=\"לחץ על המחיר בכדי להוסיף להצעות מחיר\" "
                            +"onmouseover=\"this.style.backgroundColor='#00c505';this.style.color='#FFFFFF';"
                        for (k=0; k<prcs.length; k++)
                            if (prcs[k]!="" && k!=cin)
                                htm+="document.getElementById('cell"+sid+"_"+c+"_"+k+"').style.backgroundColor='#77E57c';"
                        htm+="\" "
                            +"onmouseout=\"this.style.backgroundColor='transparent';this.style.color='#000000';"
                        for (k=0; k<prcs.length; k++)
                            if (prcs[k]!="" && k!=cin)
                                htm+="document.getElementById('cell"+sid+"_"+c+"_"+k+"').style.backgroundColor='transparent';"
                        htm+="\"><div class=\"prices_table_cell\">"+this.viewArr[i].CSign+"<b>"+prcs[cin]+"</b></div></td>";
                    }
                    this.viewArr[i].prices.price[c][cin] = prcs[cin];
                }
                htm += "</tr>";
            } else if (prices.flight[c] != "" && prices.flight[c].search("קוד טיסה")==-1) {
                htm += "<tr class=\"prices_table_prices\">";
                htm += "<td colspan=\""+(prices.price[c].length+1)+"\" class=\"prices_table_content-right_td\" style=\"border-left-style:dotted;border-right-width:0px;font-weight:bold;font-size:11px;padding-top:4px;\">"+this.viewArr[i].prices.flight[c]+"</td>";
                htm += "</tr>";
            }
        }
        htm += "</table></div>";
        this.viewArr[i].prices.included = included;
        this.viewArr[i].prices.notincluded = not_included;
        this.viewArr[i].prices.terms = terms;
        htm += "<table class=\"prices_table\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\">"
        htm += "<tr class=\"prices_table_prices\"><td><b>המחיר כולל:</b> "+included+"</div></tr>";
        htm += "<tr class=\"prices_table_prices\"><td><b>המחיר אינו כולל:</b> "+not_included+"</div></tr>";
        htm += "<tr class=\"prices_table_prices\"><td><b>תנאים נוספים:</b> "+terms+"</div></tr></table>";
        
        this.viewArr[i].pricePopup = htm; 
    }
    
    this.addSpecDetails = function(sid,title,stitle,details,dimg,hotel,himg) {
    // add details information to each special parameter and object
    //
    // return: nothing.
        
        for (i=0; i<this.viewArr.length; i++)
            if (this.viewArr[i].Id == sid) break;
        
        this.viewArr[i].details.title = title;
        this.viewArr[i].details.stitle = stitle;
        this.viewArr[i].details.details = details;
        this.viewArr[i].details.dimage = dimg;
        this.viewArr[i].details.hotel = hotel;
        this.viewArr[i].details.himage = himg;
        
        htm = "<div class=\"details-main\">"
            +"    <div class=\"details-title\">"+title+"</div>"
            +"    <div class=\"details-subtitles\">"+stitle+"</div>"
            +"    <div class=\"details-content\">"+details+"<br><b>מלון:</b><br>"+hotel+"<br><br></div>"
            +"    <div class=\"details-pictitle\">תמונות</div>"
            +"    <div class=\"details-image\">לחץ על התמונה בכדי להגדיל<br>"
            if (dimg.charAt(dimg.length-1) != '/') {
                //htm+="        <a href=\"javascript:showimgpopup('"+escape(dimg)+"','"+title+"')\"><img src=\""+dimg+"\" height=\"70\" border=\"0\"></a>&nbsp;"
                htm+="        <img src=\""+dimg+"\" height=\"70\" border=\"0\" onclick=\"$('#dimg_"+sid+"').nyroModalManual();\"><a href=\""+dimg+"\" id=\"dimg_"+sid+"\" class=\"nyroModal\" title=\""+/*title+*/"\"></a>&nbsp;"
            } else {
                this.viewArr[i].details.dimage = "";
            }
            if (himg.charAt(himg.length-1) != '/') {
                //htm+="        <a href=\"javascript:showimgpopup('"+escape(himg)+"','"+title+"')\"><img src=\""+himg+"\" height=\"70\" border=\"0\"></a>"
                htm+="        <img src=\""+himg+"\" height=\"70\" border=\"0\" onclick=\"$('#himg_"+sid+"').nyroModalManual();\"><a href=\""+himg+"\" id=\"himg_"+sid+"\" class=\"nyroModal\" title=\""+/*title+*/"\"></a>"
            } else {
                this.viewArr[i].details.himage = "";
            }
        htm+="    </div>"
            +"    <div class=\"details-thumbimg\" style=\"background-image:url('"+this.viewArr[i].Thumb+"')\"><img src=\""+this.viewArr[i].Thumb+"\" width=\"100%\" height=\"100%\"></div>"
            +"</div>";
        this.viewArr[i].detailsPopup = htm;
    }
    
    this.addOffer = function(sid,x,y) {
    // add specific offer to the offer price side div
    // x,y - position of the selected price at prices table of the special sid
    //       x - by columns
    //       y - by dates
    //
    // return: nothing
        
        //alert(sid+" "+x+" "+y);
        var len = 0//this.OfferArr.length
        
        for (i=0; i<this.viewArr.length; i++)
            if (this.viewArr[i].Id == sid) break;
        id = i;
        
        if (typeof this.OfferArr[len] != "undefined") {
            for (i=0; i<this.viewArr.length; i++)
                if (this.viewArr[i].Id == this.OfferArr[len].sid) break;
            id2 = i;
            $("#sp"+this.OfferArr[len].sid).css("background-image","url(images/box-bg2.png)")
                .attr("alt","לחצו כאן בכדי לצבוע חלונית זו לכחול")
                .attr("title","לחצו כאן בכדי לצבוע חלונית זו לכחול")
            app.viewArr[id2].bgImg = "images/box-bg2.png";
        }
        
        if (!this.viewArr[id].DetailsLoaded) {
            this.viewArr[id].DetailsLoaded = true
            $.get('xml/details/details'+sid+'.xml', function(xml,status){
                var SDetail = $.xml2json(xml);
                //alert(app.DebugObjDump(Sdetail,"SDetail"))
                app.addSpecDetails(SDetail.sid,SDetail.title,SDetail.subtitle,SDetail.dest_details,SDetail.dest_image,SDetail.hotel_details,SDetail.hotel_image);
                if (status) {
                    ///////////////////// google analystics/////////////////////
                    try {
                        //var pageTracker = _gat._getTracker("UA-713440-4");
                        pageTracker._trackPageview("/details/dest_"+app.viewArr[id].Dest+"/sid_"+sid+"/head_"+app.viewArr[id].Heading+"/");
                    } catch(err) {}
                    //////////////////////////////////////////////////////////
                    app.OfferArr[len] = new OfferPriceObj(len,sid,x,y);
                    $('#op_cont').html(app.OfferArr[len].HTML());
                    setHeight("cont_offer","main_offer",32);
                    hidedetails(sid);
                    hideprice(sid);
                }
            });
        } else {
            this.OfferArr[len] = new OfferPriceObj(len,sid,x,y);
            $('#op_cont').html(this.OfferArr[len].HTML());
            setHeight("cont_offer","main_offer",32);
            hidedetails(sid);
            hideprice(sid);
        }
        
        $("#sp"+sid).css("background-image","url(images/box-bg0.png)")
            .removeAttr("alt")
            .removeAttr("title");
        app.viewArr[id].bgImg = "images/box-bg0.png";
    }
    
    this.OPClick = function(action,id) {
    // offer price's action buttons
    //
    // return: nothing
        
		if (typeof(id)=="undefined") id=0;

        var pr = this.OfferArr[id];
        
        for (i=0; i<this.viewArr.length; i++)
            if (this.viewArr[i].Id == pr.sid) break;
        var va = this.viewArr[i];
        index = i;
        
        switch (action) {
        case 'order':
            ///////////////////// google analystics/////////////////////
            try {
                //var pageTracker = _gat._getTracker("UA-713440-4");
                pageTracker._trackPageview("/orderClick/dest_"+va.Dest+"/sid_"+pr.sid+"/head_"+va.Heading+"/");
            } catch(err) {}
            //////////////////////////////////////////////////////////
            if (typeof this.order == "undefined")
                this.order = new OrderObj(id);
            g('OP_order_but').style.display = 'none';
            for (i=0; i<this.order.SpecDetails.Columns.length; i++) {
                $('#num_'+i+'_'+id).attr("disabled","disabled");
            }
            //alert(app.DebugObjDump(this.order.SpecDetails,"specDetails"))
            $('#specials_main').html(this.order.HTML());
            setHeight('cont_order_card','main_order_card',32)
            break;
        case 'cancel':
            tempArr = new Array();
            for (i=0; i<this.OfferArr.length; i++) {
                if (i != id)
                    tempArr = this.OfferArr[i];
            }
            this.OfferArr = new Array();
            for (i=0; i<tempArr.length; i++) {
                this.OfferArr[i] = tempArr;
            }
            if (this.OfferArr.length == 0) {
                htm = '<div style="border:2px dotted #000; background-image:url(images/black-bg-40.png);'
                    +'font-family:arial; font-size:12px; font-weight:bold; color:#FFF; margin-top:30px;'
                    +'margin-bottom:50px; padding:5px;">לא בחרתם עדיין מבצע/חבילה.<br><br>בכדי לעשות זאת: '
                    +'בחרו באחד המבצעים והציבו את הסמן על הכותרת "מחיר". משיופיע חלון ירוק ובתוכו מחירים לחצו על '
                    +'המחיר המתאים לכם. לאחר מכן יופיע במקום הטקסט הנוכחי המבצע שבחרתם.<br><br>לעזרה נוספת ניתן להתקשר אל '
                    +'משרדינו בטלפון: 03-6215000.<br>נשמח לעזור!</div>';
            } else {
                htm = this.OfferArr[0].HTML();
            }
            $('#op_cont').html(htm);
            setHeight("cont_offer","main_offer",32)
            $('#sp'+va).css("background-image","url(images/box-bg2.png)")
                .attr("alt","לחצו כאן בכדי לצבוע חלונית זו לכחול")
                .attr("title","לחצו כאן בכדי לצבוע חלונית זו לכחול")
            app.viewArr[index].bgImg = "images/box-bg2.png";
            break;
        case 'print':
            ///////////////////// google analystics/////////////////////
            try {
                //var pageTracker = _gat._getTracker("UA-713440-4");
                pageTracker._trackPageview("/print/dest_"+va.Dest+"/sid_"+va.Id+"/head_"+va.Heading+"/");
            } catch(err) {}
            //////////////////////////////////////////////////////////
            htm ='<div style="display:none">'
                +'<div id="pop_sid">'+pr.sid+'</div>'
                +'<div id="pop_title">'+pr.Title+'</div>'
                +'<div id="pop_stitle">'+pr.subTitle+'</div>'
                +'<div id="pop_startDate">'+pr.StartDate+'</div>'
                +'<div id="pop_EndDate">'+pr.EndDate+'</div>'
                +'<div id="pop_flight">'+pr.FlightDesc+'</div>'
                //+'<div id="pop_singleDesc">'+pr.SinglePriceDesc+'</div>'
                //+'<div id="pop_singlePrice">'+pr.SinglePricePrice+'</div>'
                +'<div id="pop_currency">'+pr.Currency+'</div>'
                //+'<div id="pop_adults">'+pr.TotalPeople+'</div>'
                +'<div id="pop_included">'+pr.Included+'</div>'
                +'<div id="pop_notincluded">'+pr.NotIncluded+'</div>'
                +'<div id="pop_terms">'+pr.Terms+'</div>'
                +'<div id="pop_spec_details">'+app.viewArr[pr.said].details.details+'</div>'
                +'<div id="pop_spec_hotel">'+app.viewArr[pr.said].details.hotel+'</div>'
                +'<div id="pop_spec_dimage">'+app.viewArr[pr.said].details.dimage+'</div>'
                +'<div id="pop_spec_himage">'+app.viewArr[pr.said].details.himage+'</div>'
                //+'<div id="pop_">'++'</div>'
                +'<div id="pop_totalPeople">'+pr.TotalPeople+'</div>'
                +'<div id="pop_totalPrice">'+pr.TotalPrice+'</div>'
                +'</div>';
            $('#op_cont').append(htm);
            print = window.open("print.php","print");
            break;
        case 'email':
            content = '<form id="sendEmailForm" method="POST" action="sendprice.php"><table dir="rtl" width="350" height="180" border="0">\n'
                +'<tr>\n'
                +'  <td colspan="2" style="font-size:14px; font-family:arial; font-weight:bold; color:#000000" align="center">שליחת הצעה בדוא"ל</td>\n'
                +'</tr><tr>\n'
                +'  <td valign="top" style="font-size:12px; font-family:arial; font-weight:bold; color:#555555">שמך הוא </td>\n'
                +'  <td><input style="border:2px solid #EEE; font-family:arial; font-size:13px; color:#00F;" type="text" id="emailName" name="from" value="'+this.emailName+'" '
                +'      onclick="this.style.border=\'2px solid #EEE\'; g(\'emailNameErr\').innerHTML = \'\';" />'
                +'      <br><div style="float:right; font-family:arial; font-size:10px; color:#F00;" id="emailNameErr"></div></td>\n'
                +'</tr><tr>\n'
                +'  <td valign="top" style="font-size:12px; font-family:arial; font-weight:bold; color:#555555">דוא"ל אליו ברצונך לשלוח</td>\n'
                +'  <td><input style="direction:ltr;border:2px solid #EEE; font-family:arial; font-size:13px; color:#00F;" type="text" id="emailAddr" name="to" value="'+this.emailAddr+'" '
                +'      onclick="this.style.border=\'2px solid #EEE\'; g(\'emailAddrErr\').innerHTML = \'\';" />'
                +'      <br><div style="float:right; font-family:arial; font-size:10px; color:#F00;" id="emailAddrErr"></div></td>\n'
                +'</tr><tr>\n'
                +'  <td valign="top" style="font-size:12px; font-family:arial; font-weight:bold; color:#555555">פרטים נוספים</td>\n'
                +'  <td><textarea style="border:2px solid #EEE; font-family:arial; font-size:13px; color:#00F;" id="emailDetails" name="text" value="'+this.emailDetails+'" ></textarea></td>\n'
                +'</tr><tr>\n'
                +'  <td colspan="2"><div class="op_button" style="height:20px; margin-left:8px; width:50px; float:left; text-align:center;font-size:15px;color:#090;"'
                +'      onmouseover="this.style.backgroundColor=\'#0F0\';this.style.border=\'2px solid #090\'"'
                +'      onmouseout="this.style.backgroundColor=\'transparent\';this.style.border=\'2px solid #a2a2a2\'"'
                +'      onclick="app.OPClick(\'sendemail\','+id+');">שלח</div></td>\n'
                +'</tr>\n'
                +'</table>'
                +'<input type="hidden" id="emailInfo" name="info" value="'+pr.sid+'|&&|'+urlencode(pr.Title)+'|&&|'+urlencode(pr.subTitle)
                +'|&&|'+urlencode(pr.StartDate)+'|&&|'+urlencode(pr.EndDate)+'|&&|'+urlencode(pr.FlightDesc)+'|&&|'+pr.Currency
                +'|&&|'+urlencode(pr.Included)+'|&&|'+urlencode(pr.NotIncluded)+'|&&|'+urlencode(pr.Terms)
                +'|&&|'+urlencode(app.viewArr[pr.said].details.details)+'|&&|'+urlencode(app.viewArr[pr.said].details.hotel)
                +'|&&|'+urlencode(app.viewArr[pr.said].details.dimage)+'|&&|'+urlencode(app.viewArr[pr.said].details.himage)
                +'|&&|'+pr.TotalPeople+'|&&|'+pr.TotalPrice+'" />'
                +'</form>\n'
            $.nyroModalManual({content: content});
            break;
        case 'sendemail':
            stp = false;
            if (g('emailName').value == "") {
                $('#emailNameErr').html('אנא כיתבו את שמכם');
                $('#emailName').css('border','2px solid #F00');
                //g('emailNameErr').innerHTML = 'אנא כיתבו את שמכם';
                //g('emailName').style.border = "2px solid #F00";
                stp = true;
            }
            if (g('emailAddr').value == "") {
                $('#emailAddrErr').html('אנא כיתבו דוא"ל');
                $('#emailAddr').css('border','2px solid #F00');
                //g('emailAddrErr').innerHTML = 'אנא כיתבו דוא"ל';
                //g('emailAddr').style.border = "2px solid #F00";
                stp = true;
            } else if (!emailcheck(g('emailAddr').value)) {
                $('#emailAddrErr').html('מבנה הדוא"ל שגוי');
                $('#emailAddr').css('border','2px solid #F00');
                //g('emailAddrErr').innerHTML = 'מבנה הדוא"ל שגוי';
                //g('emailAddr').style.border = "2px solid #F00";
                stp = true;
            }
            if (stp) break;
            this.emailName = g('emailName').value;
            this.emailAddr = g('emailAddr').value;
            this.emailDetails = g('emailDetails').value;
            cnt = '<div id="sndEmail"><table width="300"><tr><td style="font-size:14px; font-family:arial; font-weight:bold; color:#000000" align="center">שולח...<br>אנא המתינו.</td></tr></table></div>';
            //$.nyroModalManual({content: cnt});
            //g('popup_content').innerHTML = cnt;
            //to = this.emailAddr;
            //from = this.emailName;
            //more = this.emailDetails;
            $('#sendEmailForm').nyroModalManual();
            //call("popupresponse","sendprice.php","to="+to+"&from="+from+"&text="+more);
            break;
        }
    }
    
    this.orderClick = function(act,id) {
    // click actions at the order popup
    //
    // return: nothing.

        switch (act) {
        case 'cancel':
            showpopup2();
            app.rebuild.all();
            hidepopup2();
            break;
        case 'submit':
            $("#order_errors").html("");
            g('order_alert').style.display = "block";
            order_input_empty('lname',"חובה לכתוב שם משפחה");
            order_input_empty('fname',"חובה לכתוב שם פרטי");
            order_input_empty('addr',"חובה לכתוב כתובת");
            order_input_empty('city',"חובה לכתוב ישוב");
            order_input_empty('lphone1',"חובה לכתוב טלפון בבית (אם אין, רשמו \"אין\")");
            order_input_empty('cphone1',"חובה לכתוב טלפון נייד (אם אין, רשמו \"אין\")");
            if (!order_input_empty('email',"חובה לרשום דוא\"ל"))
                if (!emailcheck(g('email').value)) {
                    $("#order_errors").append("- "+"הדוא\"ל שהזנתם אינו חוקי, יש לכתוב דוא\"ל חוקי"+"<br>");
                    g('email').style.borderColor = "#F00";
                }
            if (getCheckedValue(document.forms['form1'].elements['payment'])=="creditc") {
                order_input_empty('ccn',"אם כרטיס אשראי סומן כאופן תשלום, חובה להזין את מספר כרטיס האשראי");
                order_input_empty('expm',"אם כרטיס אשראי סומן כאופן תשלום, חובה לבחור את חודש תוקף הכרטיס");
                order_input_empty('expy',"אם כרטיס אשראי סומן כאופן תשלום, חובה לבחור את שנת תוקף הכרטיס");
                order_input_empty('pid',"אם כרטיס אשראי סומן כאופן תשלום, חובה להזין את מספר תעודת הזהות או הדרכון של בעל הכרטיס");
            }
            
            if (g('order_errors').innerHTML == "") {                
                //copy personal information
                this.order.PersonalDetails.LastName = gv('lname')
                this.order.PersonalDetails.FirstName = gv('fname')
                this.order.PersonalDetails.Address = gv('addr')
                this.order.PersonalDetails.City = gv('city')
                this.order.PersonalDetails.LandPhone = gv('lphone0')+" "+gv('lphone1')
                this.order.PersonalDetails.CellPhone = gv('cphone0')+" "+gv('cphone1')
                this.order.PersonalDetails.eMail = gv('email')
                
                //copy payment information
                this.order.PaymentMethod = getCheckedValue(document.forms['form1'].elements['payment'])
                if (this.order.PaymentMethod == "creditc") {
                    this.order.PayCreditCard.Number = gv('ccn')
                    expm = parseInt(gv('expm')); expy = gv('expy')
                    this.order.PayCreditCard.Expiration = (expm<10?"0"+expm:expm)+"/"+expy.charAt(2)+expy.charAt(3)
                    this.order.PayCreditCard.OwnerID = gv('pid')
                }
                
                //checked information
                this.order.ClubMember = g('club').checked?true:false;
                this.order.Ensurance = g('ensure').checked?true:false;
                this.order.SendTicketsHome = g('ticket').checked?true:false;
                
                /*check saved information
                alert(this.DebugObjDump(this.order.PersonalDetails,"PersonalDetails"))
                alert("this.order.PaymentMethod : "+this.order.PaymentMethod)
                alert(this.DebugObjDump(this.order.PayCreditCard,"PayCreditCard"))
                alert(this.DebugObjDump(this.order.SpecDetails,"SpecDetails"))
                alert("this.order.ClubMember : "+this.order.ClubMember
                      +"\nthis.order.Ensurance : "+this.order.Ensurance
                      +"\nthis.order.SendTicketsHome : "+this.order.SendTicketsHome) //*/
                
                ///////////////////////////////////////////////////////////////
                /////////// send information to the order.php page ////////////
                ///////////////////////////////////////////////////////////////
                
                or = this.order
                sdet = or.SpecDetails
                //alert(this.DebugObjDump(sdet,"sdet"))
                pdet = or.PersonalDetails
                pcc = or.PayCreditCard
                for (i=0; i<this.viewArr.length; i++)
                    if (this.viewArr[i].Id == sdet.sid) break;
                va = this.viewArr[i];
                prms ="spec_id="+sdet.sid
                    +"&spec_dest="+urlencode(va.Dest)
                    +"&spec_title="+urlencode(sdet.Title)
                    +"&spec_subtitle="+urlencode(sdet.subTitle)
                    +"&spec_startdate="+urlencode(sdet.StartDate)
                    +"&spec_enddate="+urlencode(sdet.EndDate)
                    +"&spec_flight="+urlencode(sdet.FlightDesc)
                    +"&spec_currency="+urlencode(sdet.Currency)
                    +"&spec_included="+urlencode(sdet.Included)
                    +"&spec_notincluded="+urlencode(sdet.NotIncluded)
                    +"&spec_terms="+urlencode(sdet.Terms)
                    +"&spec_totalprice="+sdet.TotalPrice
                    +"&spec_totalpeople="+sdet.TotalPeople
                for (i=0; i<sdet.Columns.length; i++)
                    if (sdet.Prices[i] > -1)
                        prms+="&spec_column"+i+"="+urlencode(sdet.Columns[i])
                for (i=0; i<sdet.Prices.length; i++)
                    if (sdet.Prices[i] > -1)
                        prms+="&spec_price"+i+"="+sdet.Prices[i]
                for (i=0; i<sdet.People.length; i++)
                    if (sdet.Prices[i] > -1)
                        prms+="&spec_max_people_at_col"+i+"="+sdet.People[i]
                for (i=0; i<sdet.SelectedPeople.length; i++)
                    if (sdet.Prices[i] > -1)
                        prms+="&spec_selected_people_at_col"+i+"="+sdet.SelectedPeople[i]
                
                prms+="&pers_firstname="+urlencode(pdet.FirstName)
                    +"&pers_lastname="+urlencode(pdet.LastName)
                    +"&pers_address="+urlencode(pdet.Address)
                    +"&pers_city="+urlencode(pdet.City)
                    +"&pers_landphone="+urlencode(pdet.LandPhone)
                    +"&pers_cellphone="+urlencode(pdet.CellPhone)
                    +"&pers_email="+pdet.eMail
                
                prms+="&pcc_number="+pcc.Number
                    +"&pcc_exp="+urlencode(pcc.Expiration)
                    +"&pcc_oid="+pcc.OwnerID
                
                prms+="&pay_method="+or.PaymentMethod
                    +"&club="+(or.ClubMember?"yes":"no")
                    +"&ensurance="+(or.Ensurance?"yes":"no")
                    +"&sendticket="+(or.SendTicketsHome?"yes":"no")

                if (app.emailName != "")
                    app.emailName = pdet.FirstName+' '+pdet.LastName;
                
                call("order_resp","order.php",prms)
                
                // erase credit card information:
                this.order.PayCreditCard.Number = ""
                this.order.PayCreditCard.Expiration = ""
                this.order.PayCreditCard.OwnerID = ""
                
                /////////////////////////////////////////////////////////
                /////////////////////////////////////////////////////////
                
                ///////////////////// google analystics/////////////////////
                try {
                    //var pageTracker = _gat._getTracker("UA-713440-4");
                    pageTracker._trackPageview("/orderFinal/dest_"+va.Dest+"/sid_"+va.Id+"/head_"+va.Heading+"/");
                } catch(err) {}
                //////////////////////////////////////////////////////////
                
                g('order_forms').style.display = "none";
                $("#order_alert").html("<center><br>הזמנתכם התקבלה בהצלחה.<br>נציגי לראות עולמות יחזרו אליך בהקדם.<br><br>מיד תועברו לתחילת העמוד...<br><br></center>");
                g('order_content').innerHTML = app.order.tmpHTML;
                redi = setTimeout("redirect()",2000);
            }
            setHeight("cont_order_card","main_order_card",32)
            break;
        }
    }
    
    this.OPpplchg = function(id) {
    // update total ppl at the offer price
    //
    // return: nothing;
        
        tot = 0;
        totp = 0;
        for (i=0; i<app.OfferArr[id].Columns.length; i++) {
            if (app.OfferArr[id].Prices[i] != -1) {
                rppl = parseInt(g('num_'+i+'_'+id).value)
                this.OfferArr[id].SelectedPeople[i] = rppl
                rprc = app.OfferArr[id].Prices[i]
                tot += rppl
                totp += ( rppl * rprc )
                g('ppl_'+i+'_'+id).innerHTML = rppl
                g('tot_'+i+'_'+id).innerHTML = rppl * rprc
            }
        }
        this.OfferArr[id].TotalPrice = totp
        this.OfferArr[id].TotalPeople = tot
        g('total_ppl_'+id).innerHTML = tot
        g('total_price_'+id).innerHTML = totp
    }

    this.showdetails = function(sid) {
    // show details of specific special
    //
    // return: nothing.
        
        hfunc("details","block","3",sid);
        
        for (i=0; i<this.viewArr.length; i++)
            if (this.viewArr[i].Id == sid) break;
		 var index = i;

        repop("details",sid)
        
        if (!this.viewArr[i].DetailsLoaded) {
            this.viewArr[i].DetailsLoaded = true
            $.get('xml/details/details'+sid+'.xml', function(xml,status){
                var SDetail = $.xml2json(xml);
                //alert(app.DebugObjDump(Sdetail,"SDetail"))
                app.addSpecDetails(SDetail.sid,SDetail.title,SDetail.subtitle,SDetail.dest_details,SDetail.dest_image,SDetail.hotel_details,SDetail.hotel_image);
                if (status) {
                    ///////////////////// google analystics/////////////////////
                    try {
                        //var pageTracker = _gat._getTracker("UA-713440-4");
                        pageTracker._trackPageview("/details/dest_"+app.viewArr[index].Dest+"/sid_"+sid+"/head_"+app.viewArr[index].Heading+"/");
                    } catch(err) {}
                    //////////////////////////////////////////////////////////
                    app.reload("details",index);
                    side = calibrating_popup(document.getElementById('detailsmain_'+sid),document.getElementById('details_but_'+sid),document.getElementById('detailscon_'+sid),0,0,2);
                    if (side==0) {
                        g('detailsleftconnector_'+sid).style.display = "block"
                        g('detailssep_'+sid).style.left = "-2px"
                        g('detailssep_'+sid).style.right = "auto"
                    } else {
                        g('detailsrightconnector_'+sid).style.display = "block"
                        g('detailssep_'+sid).style.left = "auto"
                        g('detailssep_'+sid).style.right = "-2px"
                    }
                    repop('price',sid);
                }
            });
        } else {
            side = calibrating_popup(document.getElementById('detailsmain_'+sid),document.getElementById('details_but_'+sid),document.getElementById('detailscon_'+sid),0,0,2);
            if (side==0) {
                g('detailsleftconnector_'+sid).style.display = "block"
                g('detailssep_'+sid).style.left = "-2px"
                g('detailssep_'+sid).style.right = "auto"
            } else {
                g('detailsrightconnector_'+sid).style.display = "block"
                g('detailssep_'+sid).style.left = "auto"
                g('detailssep_'+sid).style.right = "-2px"
            }
            repop('price',sid);
        }
    }
    
    this.showprice = function(sid) {
    // show details of specific special
    //
    // return: nothing.
        
        hfunc("price","block","3",sid);
        
        for (i=0; i<this.viewArr.length; i++)
            if (this.viewArr[i].Id == sid) break;
        var index = i;

        repop("price",sid)
        
        if (!this.viewArr[i].PriceLoaded) {
            this.viewArr[i].PriceLoaded = true
            var index = i;
            $.get('xml/prices/prices'+sid+'.xml', function(xml,status){
                var SPrice = $.xml2json(xml);
                //alert(app.DebugObjDump(SPrice,"SPrice"))
                SID = SPrice.sid;
                
                var cols = new Object();
                var prices = new Object();
                
                cols.ppl = new Array()
                cols.desc = new Array()
                prices.date_from = new Array()
                prices.date_to = new Array()
                prices.flight = new Array()
                prices.price = new Array()
                //alert(typeof SPrice.columns.col[0] + " : " + SPrice.columns.col[0])
                if (typeof SPrice.columns.col[0] == "undefined") {
                    cols.ppl[0] = 1 //the COL.ppl always zero, change it when all data will change
                    cols.desc[0] = SPrice.columns.col.desc
                } else {
                    for (j=0; j<SPrice.columns.col.length; j++) {
                        cols.ppl[j] = j+1 //the COL.ppl always zero, change it when all data will change
                        cols.desc[j] = SPrice.columns.col[j].desc
                    }
                }
                //alert(app.DebugObjDump(SPrice.prices.price,"SPrice.prices.price"))
                if (typeof SPrice.prices.price[0] == "undefined" || typeof SPrice.prices.price[0] == "string") {
                    PRCS = SPrice.prices.price;
                    prices.date_from[0] = PRCS.date_from==""?"":PRCS.date_from.split("/");
                    prices.date_to[0] = PRCS.date_to==""?"":PRCS.date_to.split("/");
                    prices.flight[0] = PRCS.flight;
                    prices.price[0] = new Array();
                    if (PRCS.price != undefined) {
                        if (cols.ppl.length == 1) {
                            prices.price[0][0] = PRCS.price.p
                        } else for (k=0; k<cols.ppl.length; k++) {
                            if (typeof PRCS.price[k] != "undefined"){
                                prices.price[0][k] = PRCS.price[k].p;
                            }
                        }
                    }
                } else {
                    for (j=0; j<SPrice.prices.price.length; j++) {
                        PRCS = SPrice.prices.price[j]
                        prices.date_from[j] = PRCS.date_from==""?"":PRCS.date_from.split("/");
                        prices.date_to[j] = PRCS.date_to==""?"":PRCS.date_to.split("/");
                        prices.flight[j] = PRCS.flight;
                        prices.price[j] = new Array();
                        if (PRCS.price != undefined) {
                            if (cols.ppl.length == 1) {
                                prices.price[j][0] = PRCS.price.p
                            } else for (k=0; k<cols.ppl.length; k++) {
                                if (typeof PRCS.price[k] != "undefined"){
                                    prices.price[j][k] = PRCS.price[k].p;
                                }
                            }
                        }
                    }
                }
                for (l=0; l<prices.price.length; l++) //rows
                    for (m=0; m<cols.ppl.length; m++) //cols
                        prices.price[l][m] = typeof prices.price[l][m]=="undefined"?"":prices.price[l][m]
                //alert(app.DebugObjDump(prices.price,"prices.price"))
                app.addSpecPrices(SID,cols,SPrice.conditions.included,SPrice.conditions.not_included,SPrice.conditions.terms,prices);
                if (status) {
                    ///////////////////// google analystics/////////////////////
                    try {
                        //var pageTracker = _gat._getTracker("UA-713440-4");
                        pageTracker._trackPageview("/prices/dest_"+app.viewArr[index].Dest+"/sid_"+sid+"/head_"+app.viewArr[index].Heading+"/");
                    } catch(err) {}
                    //////////////////////////////////////////////////////////
                    app.reload("price",index);
                    side = calibrating_popup(document.getElementById('pricemain_'+sid),document.getElementById('price_but_'+sid),document.getElementById('pricecon_'+sid),0,0,1);
                    if (side==0) {
                        g('priceleftconnector_'+sid).style.display = "block"
                        g('pricesep_'+sid).style.left = "-2px"
                        g('pricesep_'+sid).style.right = "auto"
                    } else {
                        g('pricerightconnector_'+sid).style.display = "block"
                        g('pricesep_'+sid).style.left = "auto"
                        g('pricesep_'+sid).style.right = "-1px"
                    }
                    repop('price',sid);
                }
            });
        } else {
            side = calibrating_popup(document.getElementById('pricemain_'+sid),document.getElementById('price_but_'+sid),document.getElementById('pricecon_'+sid),0,0,1);
            if (side==0) {
                g('priceleftconnector_'+sid).style.display = "block"
                g('pricesep_'+sid).style.left = "-2px"
                g('pricesep_'+sid).style.right = "auto"
            } else {
                g('pricerightconnector_'+sid).style.display = "block"
                g('pricesep_'+sid).style.left = "auto"
                g('pricesep_'+sid).style.right = "-1px"
            }
            repop('price',sid);
        }
    }
    
    this.reload = function(type,index) {
    // reload details/price of specific special
    //  type: details/price
    //  index: index in the viewArr to reload
    //
    // return: nothing.
        
        sid = this.viewArr[index].Id
        eval("content = this.viewArr[index]."+type+"Popup")
        $('#'+type+'con_'+sid).html(content)
        // set the of the popup details bg div the same resolution as content details div
        repop(type,sid)
        //window.scrollBy(0,50);
    }
    
    this.reload2 = function(type,sid) {
        for (i=0; i<this.viewArr.length; i++)
            if (this.viewArr[i].Id == sid) break;
            
        str = type.charAt(0).toUpperCase() + type.slice(1)
        eval("this.viewArr[i]."+str+"Loaded = false")
        eval("this.show"+type+"(sid)")
    }
    
    this.UpdateCounriesFilter = function() {
    // update list of countries in the header filtering.
    //
    // return: nothing.
        
        arr = new Array();
        for (i=0; i<this.specArr.length; i++)
            arr[i] = this.specArr[i].Dest
        arr.sort()
        updateSelect(g('target'),arr)
    }
    
    this.UpdateCategoriesFilter = function() {
    // update boxes of categories in the header filtering.
    //
    // return: nothing.
        
        arr = new Array();
        for (i=0; i<this.catArr.length; i++)
            arr[i] = this.catArr[i].Title
        arr.sort()
        putCategories(arr)
        for (i=0; i<arr.length; i++)
            cat_arr[i] = g('cat_'+i)
    }
}

var app = new appObj;
