Translation update done using Pootle.
[phpmyadmin-themes.git] / pmd / scripts / history.js
blobace5bae652bfc3f7f2980af55532d7a89651293b
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  * @fileoverview    function used in this file builds history tab and generates query.
4   *
5   * @requires    jQuery
6   * @requires    moves.js
7   * @version $Id$
8   */
9   
10 var history_array = []; // Global array to store history objects
11 var select_field = [];  // Global array to store informaation for columns which are used in select clause
12 var g_index;
14 /**
15  * function for panel, hides and shows toggle_container <div>,which is for history elements uses {@link JQuery}.
16  *
17  * @param       index   has value 1 or 0,decides wheter to hide toggle_container on load. 
18 **/
20 function panel(index) {
21     if (!index) {
22         $(".toggle_container").hide(); 
23     }
24     $("h2.tiger").click(function(){
25     $(this).toggleClass("active").next().slideToggle("slow");
26     });
29 /**
30  * Sorts history_array[] first,using table name as the key and then generates the HTML code for history tab,
31  * clubbing all objects of same tables together
32  * This function is called whenever changes are made in history_array[]
33  *
34  * @uses        and_or()
35  * @uses        history_edit()
36  * @uses        history_delete()
37  *      
38  * @param {int}  init   starting index of unsorted array   
39  * @param {int} final   last index of unsorted array
40  *
41 **/
43 function display(init,final) {
44     var str,i,j,k,sto;
45     // this part sorts the history array based on table name,this is needed for clubbing all object of same name together. 
46     for (i = init;i < final;i++) {
47         sto = history_array[i];
48         var temp = history_array[i].get_tab() ;//+ '.' + history_array[i].get_obj_no(); for Self JOINS
49         for(j = 0;j < i;j++){
50             if(temp > (history_array[j].get_tab())) {//+ '.' + history_array[j].get_obj_no())) { //for Self JOINS
51                 for(k = i;k > j;k--) {
52                     history_array[k] = history_array[k-1];
53                 }
54                 history_array[j] = sto;
55                 break;
56             }
57         }
58     }
59     // this part generates HTML code for history tab.adds delete,edit,and/or and detail features with objects.
60     str =''; // string to store Html code for history tab
61     for ( var i=0; i < history_array.length; i++){
62         var temp = history_array[i].get_tab(); //+ '.' + history_array[i].get_obj_no(); for Self JOIN
63         str += '<h2 class="tiger"><a href="#">' + temp + '</a></h2>';                           
64         str += '<div class="toggle_container">\n';
65         while((history_array[i].get_tab()) == temp) { //+ '.' + history_array[i].get_obj_no()) == temp) {
66             str +='<div class="block"> <table width ="250">';
67             str += '<thead><tr><td>';
68             if(history_array[i].get_and_or()){
69                 str +='<img src="pmd/images/or_icon.png" onclick="and_or('+i+')" title="OR"/></td>';
70             }
71             else {
72                str +='<img src="pmd/images/and_icon.png" onclick="and_or('+i+')" title="AND"/></td>';
73             }
74             str +='<td style="padding-left: 5px;" align="right"><img src="./themes/original/img/b_sbrowse.png" title="column name"/></td><td width="175" style="padding-left:            5px">' + history_array[i].get_column_name();
75             if (history_array[i].get_type() == "GroupBy" || history_array[i].get_type() == "OrderBy") {
76                 str += '</td><td align="center"><img src="themes/original/img/b_info.png" title="'+detail(i)+'"/><td title="' + detail(i) +'">' + history_array[i].get_type()                + '</td></td><td onmouseover="this.className=\'history_table\';" onmouseout="this.className=\'history_table2\'" onclick=history_delete('+ i +')><img                src="themes/original/img/b_drop.png" title="Delete"></td></tr></thead>';
77            }
78            else {
79                str += '</td><td align="center"><img src="themes/original/img/b_info.png" title="'+detail(i)+'"/></td><td title="' + detail(i) +'">' + history_array[i].               get_type() + '</td><td <td onmouseover="this.className=\'history_table\';" onmouseout="this.className=\'history_table2\'" onclick=history_edit('+ i +')><img               src="themes/original/img/b_edit.png" title="Edit"/></td><td onmouseover="this.className=\'history_table\';" onmouseout="this.className=\'history_table2\'"               onclick=history_delete('+ i +')><img src="themes/original/img/b_drop.png" title="Delete"></td></tr></thead>'; 
80            }
81            i++;
82            if(i >= history_array.length) {
83                break;
84            }
85            str += '</table></div><br/>';
86         }
87         i--;
88         str += '</div><br/>';
89     }
90     return str;
93 /**
94  * To change And/Or relation in history tab 
95  * 
96  * @uses        panel()
97  *
98  * @param {int} index of history_array where change is to be made
99  *
102 function and_or(index) {
103     if (history_array[index].get_and_or()) {
104         history_array[index].set_and_or(0);
105     }
106     else {
107         history_array[index].set_and_or(1);
108     }
109     var existingDiv = document.getElementById('ab');
110     existingDiv.innerHTML = display(0,0);
111     panel(1);
115  * To display details of obects(where,rename,Having,aggregate,groupby,orderby,having)
116  * 
117  * @param       index   index of history_array where change is to be made
121 function detail (index) {
122     var type = history_array[index].get_type();
123     var str;
124     if (type == "Where") {
125         str = 'Where ' + history_array[index].get_column_name() + history_array[index].get_obj().getrelation_operator() + history_array[index].get_obj().getquery();
126     }
127     if (type == "Rename") {
128         str = 'Rename ' + history_array[index].get_column_name() + ' To ' + history_array[index].get_obj().getrename_to();
129     }
130     if (type == "Aggregate") {
131         str = 'Select ' + history_array[index].get_obj().get_operator() + '( ' + history_array[index].get_column_name() + ' )';
132     }
133     if (type == "GroupBy") {
134         str = 'GroupBy ' + history_array[index].get_column_name() ;
135     }
136     if (type == "OrderBy") {
137         str = 'OrderBy ' + history_array[index].get_column_name() ;
138     }
139     if (type == "Having") {
140         str = 'Having ';
141         if (history_array[index].get_obj().get_operator() != 'None') {
142             str += history_array[index].get_obj().get_operator() + '( ' + history_array[index].get_column_name() + ' )';
143             str += history_array[index].get_obj().getrelation_operator() + history_array[index].get_obj().getquery();
144         }
145         else {
146             str = 'Having ' + history_array[index].get_column_name() + history_array[index].get_obj().getrelation_operator() + history_array[index].get_obj().getquery();
147         }
148     }
149     return str;
153  * Deletes entry in history_array
155  * @uses        panel()
156  * @uses        display()
157  * @param       index   index of history_array[] which is to be deleted
161 function history_delete(index) {
162     for(var k =0 ;k < from_array.length;k++){
163         if(from_array[k] == history_array[index].get_tab()){ 
164             from_array.splice(k,1); 
165             break;
166         }
167     }
168     history_array.splice(index,1);
169     var existingDiv = document.getElementById('ab');
170     existingDiv.innerHTML = display(0,0);
171     panel(1);
175  * To show where,rename,aggregate,having forms to edit a object
176  * 
177  * @param{int} index    index of history_array where change is to be made
181 function history_edit(index) {
182     g_index = index;
183     var type = history_array[index].get_type();
184     if (type == "Where") {
185         document.getElementById('eQuery').value = history_array[index].get_obj().getquery();
186         document.getElementById('erel_opt').value = history_array[index].get_obj().getrelation_operator();
187         document.getElementById('query_where').style.left =  '530px';
188         document.getElementById('query_where').style.top  = '130px';
189         document.getElementById('query_where').style.position  = 'absolute';
190         document.getElementById('query_where').style.zIndex = '9';
191         document.getElementById('query_where').style.visibility = 'visible';
192     }
193     if (type == "Having") {
194         document.getElementById('hQuery').value = history_array[index].get_obj().getquery();
195         document.getElementById('hrel_opt').value = history_array[index].get_obj().getrelation_operator();
196         document.getElementById('hoperator').value = history_array[index].get_obj().get_operator();
197         document.getElementById('query_having').style.left =  '530px';
198         document.getElementById('query_having').style.top  = '130px';
199         document.getElementById('query_having').style.position  = 'absolute';
200         document.getElementById('query_having').style.zIndex = '9';
201         document.getElementById('query_having').style.visibility = 'visible';
202     }
203     if (type == "Rename") {
204         document.getElementById('query_rename_to').style.left =  '530px';
205         document.getElementById('query_rename_to').style.top  = '130px';
206         document.getElementById('query_rename_to').style.position  = 'absolute';
207         document.getElementById('query_rename_to').style.zIndex = '9';
208         document.getElementById('query_rename_to').style.visibility = 'visible';
209     }
210     if (type == "Aggregate") {
211         document.getElementById('query_Aggregate').style.left = '530px';
212         document.getElementById('query_Aggregate').style.top  = '130px';
213         document.getElementById('query_Aggregate').style.position  = 'absolute';
214         document.getElementById('query_Aggregate').style.zIndex = '9';
215         document.getElementById('query_Aggregate').style.visibility = 'visible';
216     }
220  * Make changes in history_array when Edit button is clicked
221  * checks for the type of object and then sets the new value
222  * @uses        panel()
223  * @uses        display()
225  * @param       index   index of history_array where change is to be made
228 function edit(type) {
229     if (type == "Rename") {
230         if (document.getElementById('e_rename').value != "") {
231             history_array[g_index].get_obj().setrename_to(document.getElementById('e_rename').value);
232             document.getElementById('e_rename').value = "";
233         }
234         document.getElementById('query_rename_to').style.visibility = 'hidden';
235     }
236     if (type == "Aggregate") {
237         if (document.getElementById('e_operator').value != '---') {
238             history_array[g_index].get_obj().set_operator(document.getElementById('e_operator').value);
239             document.getElementById('e_operator').value = '---';
240         }
241         document.getElementById('query_Aggregate').style.visibility = 'hidden';
242     }
243     if (type == "Where") {
244         if (document.getElementById('erel_opt').value != '--' && document.getElementById('eQuery').value !="") {
245         history_array[g_index].get_obj().setquery(document.getElementById('eQuery').value);
246         history_array[g_index].get_obj().setrelation_operator(document.getElementById('erel_opt').value);
247         }
248         document.getElementById('query_where').style.visibility = 'hidden';
249     }
250     if (type == "Having") {
251         if (document.getElementById('hrel_opt').value != '--' && document.getElementById('hQuery').value !="") {
252             history_array[g_index].get_obj().setquery(document.getElementById('hQuery').value);
253             history_array[g_index].get_obj().setrelation_operator(document.getElementById('hrel_opt').value);
254             history_array[g_index].get_obj().set_operator(document.getElementById('hoperator').value);
255         }
256         document.getElementById('query_having').style.visibility = 'hidden';
257     }
258     var existingDiv = document.getElementById('ab');
259     existingDiv.innerHTML = display(0,0);
260     panel(1);
264  * history object closure  
266  * @param       ncolumn_name    name of the column on which conditions are put
267  * @param       nobj                    object details(where,rename,orderby,groupby,aggregate)
268  * @param       ntab                    table name of the column on which conditions are applied
269  * @param       nobj_no                 object no used for inner join
270  * @param       ntype                   type of object
274 function history(ncolumn_name,nobj,ntab,nobj_no,ntype) {
275     var and_or;
276     var obj;
277     var tab;
278     var column_name;
279     var obj_no;
280     var type;
281     this.set_column_name = function (ncolumn_name) {
282         column_name = ncolumn_name;
283     };
284     this.get_column_name = function() {
285         return column_name;
286     };
287     this.set_and_or = function(nand_or) {
288         and_or = nand_or;
289     };
290     this.get_and_or = function() {
291         return and_or;
292     }
293     this.get_relation = function() {
294         return and_or;
295     };
296     this.set_obj = function(nobj) {
297         obj = nobj;
298     };
299     this.get_obj = function() {
300         return obj;
301     };
302     this.set_tab = function(ntab) {
303         tab = ntab;
304     };
305     this.get_tab = function() {
306         return tab;
307     };
308     this.set_obj_no = function(nobj_no) {
309         obj_no = nobj_no;
310      };
311     this.get_obj_no = function() {
312         return obj_no;
313     };
314     this.set_type = function(ntype) {
315         type = ntype;
316     }
317     this.get_type = function() {
318         return type;
319     }
320     this.set_obj_no(nobj_no);
321     this.set_tab(ntab);
322     this.set_and_or(0);
323     this.set_obj(nobj);
324     this.set_column_name(ncolumn_name);
325     this.set_type(ntype);
329  * where object closure, makes an object with all information of where
331  * @param       nrelation_operator      type of relation operator to be applied
332  * @param       nquery                          stores value of value/sub-query 
337 var where = function (nrelation_operator,nquery) {
338     var relation_operator;
339     var query;
340     this.setrelation_operator = function(nrelation_operator) {
341         relation_operator = nrelation_operator;
342     };
343     this.setquery = function(nquery) {
344         query = nquery;
345     };
346     this.getquery = function() {
347         return query;
348     };
349     this.getrelation_operator = function() {
350         return relation_operator;
351     };
352     this.setquery(nquery);
353     this.setrelation_operator(nrelation_operator);
358  * Having object closure, makes an object with all information of where
360  * @param       nrelation_operator      type of relation operator to be applied
361  * @param       nquery                          stores value of value/sub-query 
365 var having = function (nrelation_operator,nquery,noperator) {
366     var relation_operator;
367     var query;
368     var operator;
369     this.set_operator = function(noperator) {
370         operator = noperator;
371     };
372     this.setrelation_operator = function(nrelation_operator) {
373         relation_operator = nrelation_operator;
374     };
375     this.setquery = function(nquery) {
376         query = nquery;
377     };
378     this.getquery = function() {
379         return query;
380     };
381     this.getrelation_operator = function() {
382         return relation_operator;
383     };
384     this.get_operator = function() {
385         return operator;
386     };
387     this.setquery(nquery);
388     this.setrelation_operator(nrelation_operator);
389     this.set_operator(noperator);
393  * rename object closure,makes an object with all information of rename
395  * @param       nrename_to      new name information
399 var rename = function(nrename_to) {
400     var rename_to;
401     this.setrename_to = function(nrename_to) {
402         rename_to = nrename_to;
403     };
404     this.getrename_to =function() {
405         return rename_to;
406     };
407     this.setrename_to(nrename_to);
411  * aggregate object closure
413  * @param       noperator       aggregte operator
417 var aggregate = function(noperator) {
418     var operator;
419     this.set_operator = function(noperator) {
420         operator = noperator;
421     };
422     this.get_operator = function() {
423         return operator;
424     };
425     this.set_operator(noperator);
429  * This function returns unique element from an array
431  * @param arraName array from which duplicate elem are to be removed.
432  * @return unique array
433  */
435 function unique(arrayName) {
436     var newArray=new Array();
437     label:for(var i=0; i<arrayName.length;i++ )
438     {  
439         for(var j=0; j<newArray.length;j++ )
440         {
441             if(newArray[j]==arrayName[i]) 
442                 continue label;
443         }
444         newArray[newArray.length] = arrayName[i];
445     }
446    return newArray;
450  * This function takes in array and a value as input and returns 1 if values is present in array
451  * else returns -1
453  * @param arrayName array
454  * @param value  value which is to be searched in the array
455  */
457 function found(arrayName,value) {
458     for(var i=0; i<arrayName.length; i++) {
459         if(arrayName[i] == value) { return 1;}
460     }
461     return -1;
463                 
465  * This function is the main function for query building.
466  * uses history object details for this.
468  * @ uses query_where()
469  * @ uses query_groupby()
470  * @ uses query_having() 
471  * @ uses query_orderby()
472  * 
473  * @param formtitle title for the form
474  * @param fadin      
475  */
477 function build_query(formtitle, fadin) {
478     var q_select = "SELECT ";
479     var temp;
480     for(i = 0;i < select_field.length; i++) {
481         temp = check_aggregate(select_field[i]);
482         if (temp != "") {
483             q_select += temp;
484             temp = check_rename(select_field[i]);
485             q_select += temp + ",";
486         }
487         else {
488             temp = check_rename(select_field[i]);
489             q_select += select_field[i] + temp +","; 
490         }
491     }
492     q_select = q_select.substring(0,q_select.length - 1);
493     q_select += " FROM " + query_from();
494     if(query_where() != "") {
495         q_select +="\n WHERE";
496                 q_select += query_where();
497     }
498     if(query_groupby() != "") { q_select += "\nGROUP BY " + query_groupby(); }
499     if(query_having() != "") { q_select += "\nHAVING " + query_having(); }
500     if(query_orderby() != "") { q_select += "\nORDER BY " + query_orderby(); }
501     var box = document.getElementById('box'); 
502     document.getElementById('filter').style.display='block';
503     var btitle = document.getElementById('boxtitle');
504     btitle.innerHTML = 'SELECT';//formtitle;
505     if(fadin){
506         gradient("box", 0);
507         fadein("box");
508     }
509     else{       
510         box.style.display='block';
511     }   
512     document.getElementById('textSqlquery').innerHTML = q_select;
514  /**
515   * This function builds from clause of query
516   * makes automatic joins.
517   * 
518   * @uses unique
519   * @uses add_array
520   * @uses remove_array
521   *
522   */
525 function query_from() {
526     var i =0;
527     var tab_left = [];
528     var tab_used = [];
529     var t_tab_used = [];
530     var t_tab_left = [];
531     var temp;
532     var query = "";
533     var quer = "";
534     var parts = [];
535     var t_array = [];
536     t_array = from_array;
537     var K = 0;
538     for(i; i < history_array.length ; i++) {
539         from_array.push(history_array[i].get_tab());
540     }
541     from_array = unique( from_array );
542     tab_left = from_array;
543     temp = tab_left.shift();
544     quer = temp;
545     tab_used.push(temp);
546     // if master table (key2) matches with tab used get all keys and check if tab_left matches 
547     //after this check if master table (key2) matches with tab left then check if any foriegn matches with master . 
548         for( i =0; i<2 ; i++) {
549         for (K in contr){
550             for (key in contr[K]){// contr name
551                      for (key2 in contr[K][key]){// table name
552                     parts = key2.split(".");
553                     if(found(tab_used,parts[1]) > 0)  {
554                         for (key3 in contr[K][key][key2]) {
555                             parts1 = contr[K][key][key2][key3][0].split(".");
556                             if(found(tab_left,parts1[1]) > 0) {
557                                 query += "\n" + 'LEFT JOIN ';
558                                 query += '`' + parts1[0] + '`.`' + parts1[1] + '` ON ' ;
559                                 query += '`' + parts[1] +'`.`' + key3 + '` = ';
560                                 query += '`' + parts1[1] + '`.`' + contr[K][key][key2][key3][1] + '` ';
561                                 t_tab_left.push(parts1[1]);
562                             }
563                         }
564                     }
565                 }
566             }
567         }       
568         K = 0;
569         t_tab_left = unique (t_tab_left);
570         tab_used = add_array(t_tab_left,tab_used);
571         tab_left = remove_array(t_tab_left,tab_left);
572         t_tab_left = [];
573         for (K in contr) {
574              for (key in contr[K]) {
575                  for (key2 in contr[K][key]){// table name
576                      parts = key2.split(".");
577                          if(found(tab_left,parts[1]) > 0){      
578                            for (key3 in contr[K][key][key2]){
579                                parts1 = contr[K][key][key2][key3][0].split(".");
580                                if(found(tab_used,parts1[1]) > 0) {
581                                    query += "\n" + 'LEFT JOIN ';
582                                    query += '`' + parts[0] + '`.`' + parts[1] + '` ON ' ;
583                                    query += '`' + parts1[1] + '`.`' + contr[K][key][key2][key3][1] + '` = ';
584                                    query += '`' + parts[1] + '`.`' + key3 + '` ';
585                                    t_tab_left.push(parts[1]);
586                                }
587                            }
588                      }
589                  }
590             }
591         }
592         t_tab_left = unique (t_tab_left);
593         tab_used = add_array(t_tab_left,tab_used);
594         tab_left = remove_array(t_tab_left,tab_left);
595         t_tab_left = [];
596     }
597     for (k in tab_left) {
598         quer += " , `" + tab_left[k] + "`";
599     }
600         query = quer + query;
601         from_array = t_array;
602         return query;
604                                 /*              document.write(key3+";"); //master_field
605                                                         document.write(contr[K][key][key2][key3][0]+";"); // foreign_table
606                                                         document.write(contr[K][key][key2][key3][1]+";"); //forieign_feild */
608  * This function concatenates two array
610  * @params add array elements of which are pushed in
611  * @params arr array in which elemnets are added
612  */
613 function add_array(add,arr){
614     for( var i=0; i<add.length; i++){
615         arr.push(add[i]);
616     }
617     return arr;
620 /* This fucntion removes all elements present in one array from the other.
622  * @params rem array from which each element is removed from other array.
623  * @params arr array from which elements are removed.
625  */
626 function remove_array(rem,arr){
627     for(var i=0; i<rem.length; i++){
628         for(var j=0; j<arr.length; j++)
629             if(rem[i] == arr[j]) { arr.splice(j,1); }
630     }
631     return arr;
635  * This function builds the groupby clause from history object
637  */
639 function query_groupby() {
640     var i = 0;
641     var str = "";
642     for(i; i < history_array.length;i++) {
643         if(history_array[i].get_type() == "GroupBy") { str +=history_array[i].get_column_name() + ", ";}
644     }
645     str = str.substr(0,str.length -1);
646     return str;
650  * This function builds the Having clause from the history object.
652  */
654 function query_having() {
655     var i = 0;
656     var and = "(";
657     for(i; i < history_array.length;i++) {
658         if(history_array[i].get_type() == "Having") {
659             if (history_array[i].get_obj().get_operator() != 'None') {
660                 and += history_array[i].get_obj().get_operator() + "(" + history_array[i].get_column_name() + " ) " + history_array[i].get_obj().getrelation_operator();
661                 and += " " + history_array[i].get_obj().getquery() + ", " ; 
662             }
663             else {
664                 and +=  history_array[i].get_column_name() + " " + history_array[i].get_obj().getrelation_operator() + " " + history_array[i].get_obj().getquery() + ", ";
665             }
666         }
667     }
668     if (and =="(") { and = "" ;}
669     else { and = and.substr(0,and.length -2) + ")";}
670     return and;
675  * This function builds the orderby clause from the history object.
677  */
679 function query_orderby() {
680     var i = 0;
681     var str = "" ;
682     for(i; i < history_array.length;i++) {
683         if(history_array[i].get_type() == "OrderBy") { str += history_array[i].get_column_name() + " , "; }
684     }
685     str = str.substr(0,str.length -1);
686     return str;
691  * This function builds the Where clause from the history object.
693  */
695 function query_where(){
696     var i = 0;
697     var and = "(";
698     var or = "(";
699     for(i; i < history_array.length;i++) {
700         if(history_array[i].get_type() == "Where") {
701             if(history_array[i].get_and_or() == 0) {
702                 and += "( " + history_array[i].get_column_name() + " " + history_array[i].get_obj().getrelation_operator() +" " + history_array[i].get_obj().getquery() + ")";                and += " AND ";
703             }
704             else {
705                 or +="( " + history_array[i].get_column_name() + " " + history_array[i].get_obj().getrelation_operator() + " " + history_array[i].get_obj().getquery() +")";
706                 or +=" OR " ;
707             }
708         }
709     }
710     if ( or != "(") {   or = or.substring(0,(or.length - 4 )) + ")"; }
711     else { or = "" ;}
712     if (and !="(") {and = and.substring(0,(and.length - 5)) + ")"; }
713     else {and = "" ;}
714     if ( or != "" ) { and = and + " OR " + or + " )"; }
715     return and;
718 function check_aggregate(id_this) {
719     var i = 0;
720     for(i;i < history_array.length;i++) {
721         var temp = '`' + history_array[i].get_tab() + '`.`' +history_array[i].get_column_name() +'`';
722         if(temp == id_this && history_array[i].get_type() == "Aggregate") {
723             return history_array[i].get_obj().get_operator() + '(' + id_this +')';
724         }
725     }
726     return "";
729 function check_rename(id_this) {
730     var i = 0;
731     for (i;i < history_array.length;i++) {
732         var temp = '`' + history_array[i].get_tab() + '`.`' +history_array[i].get_column_name() +'`';
733         if(temp == id_this && history_array[i].get_type() == "Rename") {
734             return  " AS `" + history_array[i].get_obj().getrename_to() +"`";
735         }
736     }
737     return "";
740 function gradient(id, level)
742     var box = document.getElementById(id);
743     box.style.opacity = level;
744     box.style.MozOpacity = level;
745     box.style.KhtmlOpacity = level;
746     box.style.filter = "alpha(opacity=" + level * 100 + ")";
747     box.style.display="block";
748     return;
752 function fadein(id) 
754     var level = 0;
755     while(level <= 1){
756         setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
757         level += 0.01;
758     }
761 function closebox()
763     document.getElementById('box').style.display='none';
764     document.getElementById('filter').style.display='none';