<?php
/*
Plugin Name: Virtual Tour Plugin
Plugin URI: http://www.zhuzh.info/
Description: Virtual Tour Show
Version: 2010.10.24
Author: zhuzh
Author URI: http://www.zhuzh.info
License: 
*/
?>
<?php
function vtour($content){
    $dir = get_bloginfo("wpurl") . "/wp-content/plugins/vtour";
    $c = <<<EOF
    <div class="clearfix" id="vtour_area">
        <div id="vtour_movie">
            <img src="$dir/images/default.png" alt=""/>
        </div>
        <div id="vtour_flag1" hidden="1" class="vtour_flag"><img src="$dir/images/flag1.jpg"></div>
        <div id="vtour_flag2" hidden="2" class="vtour_flag"><img src="$dir/images/flag2.jpg"></div>
        <div id="vtour_flag3" hidden="3" class="vtour_flag"><img src="$dir/images/flag3.jpg"></div>
        <div id="vtour_showroom1" hidden="1" class="vtour_showroom"><img src="$dir/images/showroom1.jpg"></div>
        <div id="vtour_showroom2" hidden="2" class="vtour_showroom"><img src="$dir/images/showroom2.jpg"></div>
        <div id="vtour_showroom3" hidden="3" class="vtour_showroom"><img src="$dir/images/showroom3.jpg"></div>
    </div>
    <script type="text/javascript" language="JavaScript">
        jQuery(document).ready(function(){
            jQuery(".vtour_flag").hover(function(){
                id =  jQuery(this).attr("hidden");
                jQuery(this).children("img").attr("src", "$dir/images/flag" + id + "-over.jpg");
                jQuery("#vtour_showroom" + id).children("img").attr("src", "$dir/images/showroom" + id + "-over.jpg");
            }, function(){
                id =  jQuery(this).attr("hidden");
                if(!jQuery(this).hasClass("activate")){
                    jQuery(this).children("img").attr("src", "$dir/images/flag" + id + ".jpg");
                    jQuery("#vtour_showroom" + id).children("img").attr("src", "$dir/images/showroom" + id + ".jpg");
                }
            });
            
            jQuery(".vtour_showroom").hover(function(){
                id =  jQuery(this).attr("hidden");
                jQuery(this).children("img").attr("src", "$dir/images/showroom" + id + "-over.jpg");
                jQuery("#vtour_flag" + id).children("img").attr("src", "$dir/images/flag" + id + "-over.jpg");
            }, function(){
                id =  jQuery(this).attr("hidden");
                if(!jQuery(this).hasClass("activate")){
                    jQuery(this).children("img").attr("src", "$dir/images/showroom" + id + ".jpg");
                    jQuery("#vtour_flag" + id).children("img").attr("src", "$dir/images/flag" + id + ".jpg");
                }
            });
    

            jQuery(".vtour_flag").click(function(){
                for(i=1; i<=3; i++){
                    jQuery("#vtour_flag" + i).children("img").attr("src", "$dir/images/flag" + i + ".jpg");
                    jQuery("#vtour_flag" + i).removeClass("activate");
                    jQuery("#vtour_showroom" + i).children("img").attr("src", "$dir/images/showroom" + i + ".jpg");
                    jQuery("#vtour_showroom" + i).removeClass("activate");
                }
                id =  jQuery(this).attr("hidden");
                jQuery(this).addClass("activate");
                jQuery("#vtour_showroom" + id).addClass("activate");
                jQuery(this).children("img").attr("src", "$dir/images/flag" + id + "-over.jpg");
                jQuery("#vtour_showroom" + id).children("img").attr("src", "$dir/images/showroom" + id + "-over.jpg");
                jQuery("#vtour_movie").html('<object width="524" height="202" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">'
                + '<param name="src" value="$dir/moviess/room' + id + 'b.mov">'
                + '<param name="autoplay" value="true">'
                + '<param name="controller" value="true">'
                + '<param name="scale" value="tofit">'
                + '<param name="cache" value="true">'
                + '<param name="border" value="0">'
                + '<param name="align" value="absmiddle">'
                + '<embed src="$dir/movies/room' + id + 'b.mov" width="524" height="202" autoplay="true" controller="true" scale="tofit" border="0" cache="true" align="absmiddle" pluginspage="http://www.apple.com/quicktime/download/"></embed>'
                + '</object>');
            });

            jQuery(".vtour_showroom").click(function(){
                for(i=1; i<=3; i++){
                    jQuery("#vtour_flag" + i).children("img").attr("src", "$dir/images/flag" + i + ".jpg");
                    jQuery("#vtour_flag" + i).removeClass("activate");
                    jQuery("#vtour_showroom" + i).children("img").attr("src", "$dir/images/showroom" + i + ".jpg");
                    jQuery("#vtour_showroom" + i).removeClass("activate");
                }
                id =  jQuery(this).attr("hidden");
                jQuery(this).addClass("activate");
                jQuery("#vtour_flag" + id).addClass("activate");
                jQuery(this).children("img").attr("src", "$dir/images/showroom" + id + "-over.jpg");
                jQuery("#vtour_flag" + id).children("img").attr("src", "$dir/images/flag" + id + "-over.jpg");
                jQuery("#vtour_movie").html('<object width="524" height="202" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">'
                + '<param name="src" value="$dir/moviess/room' + id + 'b.mov">'
                + '<param name="autoplay" value="true">'
                + '<param name="controller" value="true">'
                + '<param name="scale" value="tofit">'
                + '<param name="cache" value="true">'
                + '<param name="border" value="0">'
                + '<param name="align" value="absmiddle">'
                + '<embed src="$dir/movies/room' + id + 'b.mov" width="524" height="202" autoplay="true" controller="true" scale="tofit" border="0" cache="true" align="absmiddle" pluginspage="http://www.apple.com/quicktime/download/"></embed>'
                + '</object>');
            });
        });
    </script>
EOF;
    return str_replace('[vtour]', $c, $content);
}

add_filter ( 'the_content', 'vtour');
?>
