var c_imageswitch_speed=0;
var c_imageswitch_i=0;
var c_switchbox_w=0;
var c_switchbox_h=0;
var c_switchbox_panle_w=0;
var c_switchbox_panle_h=0;
var c_imageswitch_panle=0;
var c_imageswitch_obj=new Object();
var c_imageswitch_array=new Object();
var c_switchimages=new Array();
var c_timeout_1='';
$.fn.extend({
c_imageswitch:function(width,height,sec,panle,p_w,p_h){
	c_switchbox_w=width;
    c_switchbox_h=height;
	c_switchbox_panle_w=p_w;
	c_switchbox_panle_h=p_h;
	c_imageswitch_speed=sec;
	c_imageswitch_panle=panle;
	c_imageswitch_obj=$(this);
	c_imageswitch();
	}
			});

function c_imageswitch()
{
	//c_imageswitch_obj.css({display:"none"});
	c_imageswitch_obj.append('<div class="displayer1" style="z-index:2; position:absolute;  width:'+c_switchbox_w+';height:'+c_switchbox_h+'; overflow:hidden;background-color:#ffffff; text-align:center; border: 0pt none; padding: 0pt; margin: 0pt;"><img src="jquery.imageswitch/loading.gif" /></div><div class="displayer2" style="z-index:1; position:absolute;   width:'+c_switchbox_w+';height:'+c_switchbox_h+'; overflow:hidden;background-color:#ffffff; border: 0pt none; padding: 0pt; margin: 0pt;"></div>');
if(c_imageswitch_panle)c_imageswitch_obj.append('<div style="width:'+c_switchbox_w+';height:'+c_switchbox_panle_h+';overflow:hidden; " class="switchbox_panle advertis" align="left"></div>');
c_imageswitch_obj.find("li").each(function(){
c_switchimages[c_imageswitch_i]=new Image();
c_imageswitch_array[c_imageswitch_i]=$(this).html();
c_switchimages[c_imageswitch_i].style.width=c_switchbox_w;
c_switchimages[c_imageswitch_i].style.height=c_switchbox_h;
if(c_imageswitch_panle)c_imageswitch_obj.find(".switchbox_panle").append('<img src="images/loading.gif" class="switchbox_panle_imgs'+c_imageswitch_i+'" lang="'+c_imageswitch_i+'" style="cursor:pointer;width:'+c_switchbox_panle_w+';height:'+c_switchbox_panle_h+';" />');
c_imageswitch_i++;
});

c_imageswitch_i=0;
c_img_onload(0);
setTimeout(c_imgswitch,1500);
	}
	
	function c_imgswitch()
{
if(c_imageswitch_i>=c_switchimages.length)c_imageswitch_i=0;
if(c_switchimages[c_imageswitch_i].complete==1){
c_imageswitch_obj.find(".displayer1").animate({opacity:1},0);
c_imageswitch_obj.find(".displayer2").html(c_switchimages[c_imageswitch_i]);
c_imageswitch_obj.find(".displayer1").animate({opacity:"0"},800,function(){
$(this).html(c_imageswitch_obj.find(".displayer2").html());
$(this).animate({opacity:"1"},0);
c_imageswitch_i++;
c_timeout_1=setTimeout(c_imgswitch,c_imageswitch_speed);
});
}
else
{setTimeout(c_imgswitch,500);}
}

function c_img_onload(img_obj_index){
		if(img_obj_index>=c_switchimages.length)return false;
	c_switchimages[img_obj_index].onload=function(){
		if(c_imageswitch_panle){
			c_imageswitch_obj.find(".switchbox_panle_imgs"+img_obj_index).attr("src",c_imageswitch_array[img_obj_index]);
			c_imageswitch_obj.find(".switchbox_panle_imgs"+img_obj_index).click(function(){
																	c_imageswitch_i=$(this).attr("lang");
																	clearTimeout(c_timeout_1);
																	c_imageswitch_obj.find(".displayer1").stop();
																	c_imgswitch();
																	});
		}
		c_img_onload(img_obj_index+1);
		}
	c_switchimages[img_obj_index].src=c_imageswitch_array[img_obj_index];
	
	}
