﻿<?xml version="1.0" encoding="UTF-8"?>
<Module>
    <!--xmlns="http://dzonny.cz/google/HPgadget" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://dzonny.cz/google/HPgadget http://dzonny.cz/google/HPgadget.xsd"-->
    <!--Version 1.0.1-->
    <ModulePrefs title="Background"
                 directory_title="Background"
                 description="Chabges background of homepage if is inline"
                 author="Đonny"
                 author_email="dzonny.DZ@gmail.com"
                 author_location="Praha, Česká Republika"
                 scaling="true"
                 render_inline="required"
                 screenshot="http://dzonny.cz/google/Google.plugin.Background.png"
                 author_affiliation="Đonny"
                 author_link="dzonny.cz/google"
                 singleton="true"
                 title_url="http://dzonny.cz/google#Background"
                 />
    <UserPref name="BackgroundColor"
              display_name="background-color"
              datatype="string"
              required="false"
              />
    <UserPref name="BackgroundImage"
              display_name="background-image"
              datatype="string"
              required="false"
              />
    <UserPref name="BackgroundRepeat"
              display_name="background-repeat"
              datatype="enum"
              required="true"
              default_value="repeat">
        <EnumValue value="repeat" />
        <EnumValue value="repeat-x" />
        <EnumValue value="repeat-y" />
        <EnumValue value="no-repeat" />
    </UserPref>
    <UserPref name="BackgroundAttachment"
              display_name="background-attachment"
              datatype="enum"
              required="true"
              default_value="scroll">
        <EnumValue value="scroll" />
        <EnumValue value="fixed" />
    </UserPref>
    <UserPref name="White2Transparent"
              display_name="Make elements transparent (not for IE)"
              datatype="bool"
              default_value="false"/>
    <Content type="html">
        <![CDATA[
            <script type="text/javascript">
                document.body.background="__UP_BackgroundImage__";
                document.body.style.backgroundColor="__UP_BackgroundColor__";
                document.body.style.backgroundRepeat="__UP_BackgroundRepeat__";
                document.body.style.backgroundAttachment="__UP_BackgroundAttachment__";
                var prefs=new _IG_Prefs(__MODULE_ID__);
                if(prefs.getBool("White2Transparent")==true){
                     _IG_RegisterOnloadHandler(walk);
                }
                
                function walk(){
                    try{
                        item=document.body.firstChild;
                        while(item){
                            //Set color
                            if(item.style){
                                if(
                                    item.style.backgroundColor.toLowerCase()=="white" ||
                                    item.style.backgroundColor.toLowerCase()=="#fff" ||
                                    item.style.backgroundColor.toLowerCase()=="rgb(255,255,255)" ||
                                    item.style.backgroundColor.toLowerCase()=="rgb(255, 255, 255)" ||
                                    item.style.backgroundColor==""
                                ){
                                    item.style.backgroundColor="Transparent";                            
                                }
                            }
                            
                            //Browse for next item in pseudo-recursive pre-order 
                            if(item.firstChild){
                                item=item.firstChild;
                            }else if(item.nextSibling){
                                item=item.nextSibling;
                            }else if(item.parentNode){
                                ParentItem=item.parentNode;
                                item=null;
                                while(ParentItem){
                                    if(ParentItem.nextSibling){
                                        item=ParentItem.nextSibling;
                                        break;
                                    }else{
                                        ParentItem=ParentItem.parentNode;
                                    }
                                }
                            }else{
                                item=null;
                            }
                        }
                    }catch(ex){}//BG collor setting does not work in IE
                }
            </script>
]]>
    </Content>
</Module>
