<!--

//jquery


$(document).ready(function(){
    
    //convert pg and nm to js variables                                                     
							 
    if(typeof php2js == 'function') {
	
	php2js();
	
    }
    
    if(typeof med2js == 'function') {
	
	med2js();
	
    }
     //convert lang to js variables                                                     
							 
	
	lang2js();
	
	if(infoLang != 'cy') {
			    
		splashPage();
	    
	}
   
    						   
    isIE6();

    silentMovie();
    
    
////////////////////////////////

//delete alert

    $(".del_btn").click(function(event){
	
	if(!confirm("Are you sure you want to delete this item?")) {
	    
	  	event.preventDefault(); 
	    
	}
    });

//past shows

    $("p#shows_past a").live('click', function(event){
	
	
	$("#photobar").animate({  height: 'hide'}, 'slow', function(){$("#photobar").load("/ajax/photobar.php?nm=past", function(){$("#photobar").animate({  height: 'show'}, 'slow') ;}) });
	
	
	event.preventDefault();
	
    });
    
    $("p#shows_current a").live('click', function(event){
	
	
	$("#photobar").animate({  height: 'hide'}, 'slow', function(){$("#photobar").load("/ajax/photobar.php", function(){$("#photobar").animate({  height: 'show'}, 'slow') ;}) });
	
	
	event.preventDefault();
	
    });
    
//fill container then testimonials
    if (!jQuery.browser.msie || $.browser.version > 7) {

    $("#photobar p a:not(p#shows_past a, p#shows_current a), .show_lk a").live('click', function(event){
	
		var qy = $(this).attr('href');
		
		terms = qy.split("/");
		
		//lang = (terms[0] == 'http://www.pypedauvagabondi.com') ? 'cy' : 'en' ;
		
		pg= terms[1];
				
		nm = terms[2];

		infoNm = nm;
		
	$("#container").animate({  height: 'hide'}, 'slow', function(){
	    $("#container").load("/ajax/fillcontainer.php?pg=" + pg + "&nm=" + nm, function(){
		$("#container").animate({  height: 'show'}, 'slow', function(){
		    $("#testimonials").animate({  height: 'hide'}, 'slow', function(){
			$("#testimonials").load("/ajax/fillcomments.php?pg=" + pg + "&nm=" + nm + "&lang=" + infoLang, function(){
			    $("#testimonials").animate({  height: 'show'});//, 'slow', function(){
				//$("#pic_frame").load("/ajax/slideshow.php?pg=" + pg + "&nm=" + nm, function(){
					//silentMovie();
				    //});
//
			    });
			});
		    });
		});
	    });
	
	
	
	event.preventDefault();
	
 
 
    });

   
	    $("#backlink p a").live( 'click', function(event){
		
	
			var qy = $(this).attr('href');
					//alert(qy)
	
			terms = qy.split("/");
			
			pg= terms[1];
			
			infoNm = '';
	
		$("#container").animate({  height: 'hide'}, 'slow', function(){
		    $("#container").load("/ajax/fillcontainer.php?pg=" + pg, function(){
			$("#container").animate({  height: 'show'}, 'slow', function(){
			    $("#testimonials").animate({  height: 'hide'}, 'slow', function(){
				$("#testimonials").load("/ajax/fillcomments.php?pg=" + pg, function(){
				    $("#testimonials").animate({  height: 'show'});//, 'slow', function(){
					//$("#pic_frame").load("/ajax/slideshow.php?pg=" + pg, function(){
					//	silentMovie()
					 //   });
					//});
				    });
				});
			    });
			});
		    });
		
	
		    event.preventDefault();
	 
	 
	    });
	    
    }
	
    
    //Phone
    $("#sec_phone a").click(function(event){
	
		if($("#grey").length == 0) {
		    
		    if($("#wrapper").length == 0) { // homepage
			
			$("#wrapper_hm").append('<div id="grey"></div>');

			
		    } else {  // other pages

			$("#wrapper").append('<div id="grey"></div>');
		    
		    }

		}

		if($("#bigpic").length == 0) {
		    
		    var phone_pop = (infoLang == 'cy') ? '<p id="bigpic_close">caewch<span></span></p><h3>Galwch Jo Munton ar: +44 7779 893412</h3>' : '<p id="bigpic_close">close<span></span></p><h3>Call Jo munton on: +44 7779 893412</h3>' ;
			    		    
		    if($("#wrapper").length == 0) { // homepage
			
			$("#wrapper_hm").append('<div id="bigpic">' + phone_pop + '<div id="bigpic_img" ><img src="http://www.vagabondipuppets.com/images/phone_jo_munton.jpg" alt="Jo Munton" /></div></div>');

			
		    } else {  // other pages
			
			$("#wrapper").append('<div id="bigpic">' + phone_pop + '<div id="bigpic_img" ><img src="http://www.vagabondipuppets.com/images/phone_jo_munton.jpg" alt="Jo Munton" /></div></div>');
		     
		    }
		     
		}
		

		    
		    $("#grey, #bigpic").hide();
		   $("#grey").fadeTo('fast', 0.8);
		    $("#bigpic").fadeIn('slow');
		    

		    
		    
	    event.preventDefault();
		

    });

    //Company info
    $("#co_info p a").click(function(event){
	
		if($("#grey").length == 0) {
		    
		    if($("#wrapper").length == 0) { // homepage
			
			$("#wrapper_hm").append('<div id="grey"></div>');

			
		    } else {  // other pages

			$("#wrapper").append('<div id="grey"></div>');
		    
		    }

		}

		if($("#btmpic").length == 0) {
		    
		    $("#bigpic").detach();
		    
		    var co_pop = (infoLang == 'cy') ? '<p id="bigpic_close">caewch<span></span></p><h3>Gwybodaeth y Cwmni</h3><p>CELF THEATR VAGABONDI:</p><p>Cwmni cyfyngedig trwy warant<br/>cofrestrwyd yng Nghymru ac yn Lloegr.</p><p>Swyddfa Gofrestredig:<br/>Studio 3, Y Dolydd, Llanfyllin, Powys. SY22 5LD</p><p>Rhif Cwmni: 6280879</p>' : '<p id="bigpic_close">close<span></span></p><h3>Company Info</h3><p>Vagabondi Theatrical Arts is a<br/>Company Limited by Guarantee<br/>registered in England and Wales.</p><p>Company number: 7513362</p><p>Registered Address:<br/>Studio 3, Y Dolydd, Llanfyllin, SY22 5LD</p>' ;
			    		    
		    if($("#wrapper").length == 0) { // homepage
			
			$("#wrapper_hm").append('<div id="btmpic">' + co_pop + '</div>');

			
		    } else {  // other pages
			
			$("#wrapper").append('<div id="btmpic">' + co_pop + '</div>');
		     
		    }
		     
		}
		

		    
		    $("#grey, #bigpic").hide();
		   $("#grey").fadeTo('fast', 0.8);
		    $("#bigpic").fadeIn('slow');
		    

		    
		    
	    event.preventDefault();
		

    });
    
    //crm tabs
    

    $(".crm_tab a").live('click', function(event){
	
	pg = $(this).text();
	id = $("#crm_id").val();
	$("#crm_card").load("/cefn/ajax/crm_details.php?id=" + id + "&pg=" + pg);
	$(".crm_tab").css('border-bottom', '1px solid #2A1700');
	$(this).parent().css('border-bottom', '1px solid #FFF0CC');
	
	//alert(id + '-' + h);
	
		    
	    event.preventDefault();

    });
    
    
    //crm form

$("#crm_edit").live('click', function(event){
    
	    var id = $(this).parent().children("input#crm_id").val();
	    var pg = $(this).parent().children("input#crm_pg").val();
	    //alert(pg);
 
	    $("#crm_card").load("/cefn/ajax/crm_details_edit.php?id=" + id + "&pg=" + pg);
 	    event.preventDefault();
	    
	    
    });

    $("#crm_edit_cancel").live('click', function(event){
	
	    var id = $(this).parent().children("input#crm_id").val();
	    var pg = $(this).parent().children("input#crm_pg").val();
	
	$("#crm_card").load("/cefn/ajax/crm_details.php?id=" + id + "&pg=" + pg);
	    
 	    event.preventDefault();
	    
    });
	
 $("#crm_close").live('click', function(event){
    
	    pgno = $("#crm_pgno").val();
	    window.location.href='/db?pg=' + pgno;

 	    event.preventDefault();
	    
    });

 $("#crm_print").live('click', function(event){
    
	    var id = $("#crm_card_btns").children("input#crm_id").val();
    
	    window.open('/cefn/crm_print.php?id=' + id,'win','width=800,height=500,toolbar=yes,resizable=yes');

 	    event.preventDefault();
	    
    });


 $("#crm_fld_submit").live('click', function(event){
 
	    var id = $("#crm_card_btns").children("input#crm_id").val();
	    var pg = $("#crm_card_btns").children("input#crm_pg").val();
	    var querystring = "?id=" + id + "&pg=" + pg;
	  
	$.post("/cefn/ajax/crm_details_update.php" + querystring, $("#crm_edit_form").serialize(),
	    function(data) {
		
		$("#crm_card").load("/cefn/ajax/crm_details.php" + querystring);
		
	    });
  

	    
 	    event.preventDefault();
	    
	    
    });
    	

 $("#crm_bulk_submit").live('click', function(event){
    
 	    var id = '';
	    
	    $("input:checkbox").each(function(index) {
		
		if($(this).attr("checked")) {
		    id = id + $(this).val() + ','; 
		}
	    });
	    
	    var querystring = "?id=" + id + "&pg=general";

	  
	$.post("/cefn/ajax/crm_details_update.php" + querystring, $("#crm_edit_form").serialize(),
	    function(data) {
    	      location.reload();
	    });
	  	   // alert(post);
  

	//$("#crm_card").load("/cefn/ajax/crm_details.php" + querystring);
	    
 	    event.preventDefault();
	    
/*

  
	    var querystring = "?idee=" + idee;
	    
	  
	//$.post("/cefn/ajax/crm_details_update.php" + querystring, $("#crm_edit_form").serialize(),
	//    function(data) {
	   //   alert( data);
	  // });
	  	   // alert(post);
  

	    
 	    event.preventDefault();
	    
*/	    
    });
 

    $("#crm_action_print_env a").click( function(event){

 		if($("#grey").length == 0) {

			$("#wrapper_crm").append('<div id="grey"></div>');
		    
		}

		if($("#bigpic").length == 0) {
		    
		    $("#wrapper_crm").append('<div id="bigpic"></div>');
		     
		}
		
 	    var id = '';
	    
	    $("input:checkbox").each(function(index) {
		
		if($(this).attr("checked")) {
		    id = id + $(this).val() + ','; 
		}
	    });
	    
	    if(id) {
	    
		window.open('/cefn/crm_print_bulk.php?id=' + id,'win','width=800,height=500,toolbar=yes,resizable=yes');
		
	    }
		
	    $("#bigpic").load("/cefn/ajax/crm_details_bulk.php?id=" + id + "&action=print_env"); 
		    
		    $("#grey, #bigpic").hide();
		   $("#grey").fadeTo('fast', 0.8);
		    $("#bigpic").fadeIn('slow');
		    

		    
		    
	    event.preventDefault();
	    
	    
    });
    	
    $("#crm_action_comm a").click( function(event){

 		if($("#grey").length == 0) {

			$("#wrapper_crm").append('<div id="grey"></div>');
		    
		}

		if($("#bigpic").length == 0) {
		    
		    $("#wrapper_crm").append('<div id="bigpic"></div>');
		     
		}
		
 	    var id = '';
	    
	    $("input:checkbox").each(function(index) {
		
		if($(this).attr("checked")) {
		    id = id + $(this).val() + ','; 
		}
	    });
	    
	    $("#bigpic").load("/cefn/ajax/crm_details_bulk.php?id=" + id + "&action=comm"); 
		    
		    $("#grey, #bigpic").hide();
		   $("#grey").fadeTo('fast', 0.8);
		    $("#bigpic").fadeIn('slow');
		    

		    
		    
	    event.preventDefault();
	    
	    
    });
    	


    $("#crm_action_note a").click( function(event){

 		if($("#grey").length == 0) {

			$("#wrapper_crm").append('<div id="grey"></div>');
		    
		}

		if($("#bigpic").length == 0) {
		    
		    $("#wrapper_crm").append('<div id="bigpic"></div>');
		     
		}
		
 	    var id = '';
	    
	    $("input:checkbox").each(function(index) {
		
		if($(this).attr("checked")) {
		    id = id + $(this).val() + ','; 
		}
	    });
	    
	    $("#bigpic").load("/cefn/ajax/crm_details_bulk.php?id=" + id + "&action=note"); 
		    
		    $("#grey, #bigpic").hide();
		   $("#grey").fadeTo('fast', 0.8);
		    $("#bigpic").fadeIn('slow');
		    

		    
		    
	    event.preventDefault();
	    
	    
    });
    	


    
    
   //Splash
    function splashPage () {
		
		    			
			$("#wrapper_hm").append('<div id="grey"></div>');


		    
			$("#wrapper_hm").append('<div id="bigpic"><p id="bigpic_close">close<span></span><h3 id="splash">NEWS SPLASH!<span></span></h3><h4>We are now officially<br/><strong>VAGABONDI THEATRICAL ARTS</strong><br/>a not for profit Company Limited by Guarantee<br/>with knobs on!<br/><br/>We have gratefully received support from the<br/>Arts Council of Wales, Wateraid,<br/> ESG Robinson Charitable Trust, and Dulas Ltd for our new show and workshop series:<br/><a href="/shows/water">Hydroscape</a><br/><br/>become a <a id="splash_fb" href="http://www.facebook.com/pages/Vagabondi-Theatrical-Arts/156592207725139" target="_blank" >FRIEND OF VAGABONDI</a><br/><br/>or a <a id="splash_ag" href="/contact?agent=1">VAGABONDI SECRET AGENT</a><br/><br/>or</h4><h4 id="close_splash"><a href="#">ENTER WEBSITE</a></h4></div>');
		     		

		    
		    $("#grey, #bigpic").hide();
		   $("#grey").fadeTo('fast', 0.8);
		    $("#bigpic").fadeIn('slow');		
                              
    }

    
    function fillContainer()
    {
	$("#container").load("/ajax/fillcontainer.php?qy=" + qy) ;
    }


// Footer pop ups

    $(".footer_item a").click( function(event){

 		if($("#grey").length == 0) {
		    
		    if($("#wrapper").length == 0) { // homepage
			
			$("#wrapper_hm").append('<div id="grey"></div>');

			
		    } else {  // other pages

			$("#wrapper").append('<div id="grey"></div>');
		    
		    }

		}

		if($("#bigpic").length == 0) {
		    
		    if($("#wrapper").length == 0) { // homepage
			
			$("#wrapper_hm").append('<div id="bigpic"><p id="bigpic_close">close<span></span></p></div>');

			
		    } else {  // other pages
			
			$("#wrapper").append('<div id="bigpic"><p id="bigpic_close">close<span></span></p></div>');
		     
		    }
		     
		}
		
	       // var pop = $(this).parent().next().attr('id');
	       // id = pop.replace("footer_pop_", "")
		var id = $(this).parent().parent().attr('id');
		id = id.replace("footer_item_", "")
		
	    $("#bigpic").load("/ajax/sponsor.php?id=" + id) 
		    
		    $("#grey, #bigpic").hide();
		   $("#grey").fadeTo('fast', 0.8);
		    $("#bigpic").fadeIn('slow');
		    

		    
		    
	    event.preventDefault();
	    
	    
    });
    	
  
});



function isIE6() {
    
    ie6 = 0;
    jQuery.each(jQuery.browser, function(i, val){
	if (i == 'msie' && val == true) {
	    ie6 = 1;
    }
	if (i == 'version' && val > 6) {
	    ie6 = 0;
    }

    });

}
 function silentMovie(){

    //silent movie effect
    //alert('hi')
    
        ///////////////////////////////////////
        
        //parameter defaults
 
           // time for each image in frames ( 25 frames per second )
           this.timeDiv = 100;
           
           //fade time in frames - add this to above to get total time image is visible
           this.fade = 25;
           
           //overlap delay, if it's bigger than fade, there will be a gap, 0 will give a smooth transition
           this.overlap_delay = 50;
           
           //splodge frequency - avg number of frames for pattern
           this.splodge_freq = 15;
           //splodge opacity, 0 - .99
           this.splodge_opacity = 0.99;
            //splodge intensity, positive number, the higher, the less splodges
           this.splodge_int = 0.5;
          
             //lines speed 
           this.lines_speed = 1;
           //lines opacity, 0 - .99
           this.lines_opacity = 0.5;
	   
	   //spotlight frequency- avg number of frames
	   this.spot_speed = 2;
	   //spotlight opacity
	   this.spot_max_opacity = 0.5;
	   
          
         
           

           
           /////////////////////////////////
           
           
            this.sumDiv = this.timeDiv;
            this.delay = this.overlap_delay;
           
           //start values
           
           var slideshow_current = 0;
           this.current=0,  this.nIndex = 1, this.cFade = .99, this.nFade = 0, this.sumSplodge = 0, this.sumLines = 0, this.lines_x = 0, this.lines_y = 0, this.lines_xdir = 1, this.lines_ydir = 1, this.sumOpacity = 5;
           
           
           this.num = $("#rotator img").length - 1 ;
	   
           /*
           ///////////////////////////////////////////////////////////////
            
            //centralize image
            
            ///////////////////////////////////////////////////////////////

            //get size of div
            
            this.div_width =  $("#rotator ").width();
            this.div_height =  $("#rotator ").height();
            
           //get size of image
            
            this.img_width =  $("#rotator img:eq(0)").width();
            this.img_height =  $("#rotator img:eq(0)").height();
            
            //centralize image if results not wild
	    
	    
            
            this.offset_left =  Math.round((this.div_width - this.img_width)/2);
            this.offset_top = Math.round(this.div_height - this.img_height);
	    
                        
            if (this.img_width > 40) {
		$("#rotator img:eq(0)").css('left', this.offset_left);
	    }
	    if(this.img_height > 40) {
            $("#rotator img:eq(0)").css('top', this.offset_top);
	    }
	   */
            /////////////////////////////////////////////////////////////////
            
            // hide images
            
            /////////////////////////////////////////////////////////////////
   
           $("#rotator img").hide();
           $("#rotator img:eq(0)").show();
           	  //.div_width + ' ' + this.img_width+ ' ' + this.offset_left);

	    //append stuff
	    
           new function() {
	    append();
	   }
           
          // start slideshow
	    var oldIntervalId;
	    
          if(typeof(intervalId) != 'undefined') {
	    
	    //oldIntervalId = intervalId;
	    clearInterval(intervalId);
	    
	  } 
	    
	    intervalId = setInterval(slideshow,40);
  
      	  
	  
	  //if(oldIntervalId != intervalId) {
	    
	    //clearInterval(oldIntervalId);
	    
	 //}
	  


                            
                // pause on hover
                    
                    $("#rotator_curtain, #rotator_back, #rotator_forward, p#clikpix a").live('mouseover', function () {
			
                          clearInterval(intervalId);
                                $("#rotator_back").show();
                                $("#rotator_forward").show();

                        });
                    $("#rotator_curtain, #rotator_back, #rotator_forward, p#clikpix a").live('mouseout', function () {
                                                   
			    if(typeof(intervalId) != 'undefined') {
			      
			      clearInterval(intervalId);
			      
			    } 

			    intervalId = setInterval(slideshow,40);
			 
                                $("#rotator_back").hide();
                                 $("#rotator_forward").hide();

                        }
                      );

 	    function append () {
		
			   
			if(!ie6) {   
			    //////////////////////////////////////////////////////////////////
			    
			    // line mask
			    
			    //////////////////////////////////////////////////////////////////
			    
			    
			    $("#rotator").append('<div id="rotator_lines"></div>');
			    
			    $("#rotator_lines").fadeTo(0, this.lines_opacity);
			    
			     //////////////////////////////////////////////////////////////////
			    
			    // splodge mask
			    
			    //////////////////////////////////////////////////////////////////
			    
			    
			    $("#rotator").append('<div id="rotator_splodge"></div>');
			    
			    $("#rotator_splodge").fadeTo(0, this.splodge_opacity);
			    
			    
			    //////////////////////////////////////////////////////////////////
			    
			    // oval mask
			    
			    //////////////////////////////////////////////////////////////////
			    
			    
			    $("#rotator").append('<div id="rotator_mask"></div>');
			    
			    //$("#rotator_mask").fadeTo(0, 0.95);
			    
			   
			    
			     //////////////////////////////////////////////////////////////////
			    
			    // spotlight mask
			    
			    //////////////////////////////////////////////////////////////////
			    
			    
			    $("#rotator").append('<div id="rotator_spot"></div>');
			    
			    $("#rotator_spot").fadeTo(0, 0.5);
			    
			}
			
			    //////////////////////////////////////////////////////////////////
			    
			    // curtain
			    
			    //////////////////////////////////////////////////////////////////
			    
			    
			    $("#rotator").append('<div id="rotator_curtain"></div>');
			    
			    
			   
			    
			    //////////////////////////////////////////////////////////////////
			    
			    // back arrow
			    
			    //////////////////////////////////////////////////////////////////
			    
			    
			    $("#rotator").append('<div id="rotator_back"></div>');
			    $("#rotator_back").hide();
			    
			    
			   
			     //////////////////////////////////////////////////////////////////
			    
			    // forward arrow
			    
			    //////////////////////////////////////////////////////////////////
			    
			    
			    $("#rotator").append('<div id="rotator_forward"></div>');
			    $("#rotator_forward").hide();
			    
			    if(infoLang && infoLang == 'cy') {
			    
				$("#wrapper #rotator").append('<p id="clikpix"><a href="#">Cliciwch i weld y lluniau</a></p>');
				
			    } else {
				
				$("#wrapper #rotator").append('<p id="clikpix"><a href="#">Click to View Pictures</a></p>');				
				
			    }


			 /**/    
	    }
	    
           function fwdArrow() {                          
                                $("#rotator img:eq(" + this.current + ")").fadeTo(0, 0);
                                $("#rotator img:eq(" + this.nIndex + ")").fadeTo(0, 0.99);
                           
                                this.cFade = .99;
                                this.nFade = 0;
                                this.current = this.nIndex;
                                this.sumDiv = this.timeDiv;
                                this.delay =this.overlap_delay;
                                this.nIndex = (this.nIndex < this.num) ? this.current+1 : 0;
				
				slideshow_current  = this.current;
                                 
            }
            
            function backArrow() {                          
                                $("#rotator img:eq(" + this.current + ")").fadeTo(0, 0);
                           
                                this.cFade = .99;
                                this.nFade = 0;
                                this.current = (this.current > 0) ? this.current - 1: this.num ;
                                this.sumDiv = this.timeDiv;
                                this.delay =this.overlap_delay;
                                this.nIndex = (this.current < this.num) ? this.current+1 : 0;
				
				slideshow_current  = this.current;

				 $("#rotator img:eq(" + this.current + ")").fadeTo(0, 0.99);
                                
            }
            
            function showPic(next, src) {
		
		if(src == 'slide') {
		
		
			if(next == 1) {
			    
			    
			    this.bigpicNum = (this.bigpicNum < this.num) ? this.bigpicNum + 1 : 0;
 	
			    
			}
			
			if (next == -1) {
			    
			    this.bigpicNum = (this.bigpicNum > 0) ? this.bigpicNum - 1 : this.num;
			    
			}
			
			if (next == 0) {
	
			   
			    this.bigpicNum =  slideshow_current ;
			    
			}
			
		}
	    

		if(src == 'med') {
		    
			this.medNm = $("#med_nm").val();
			this.medNum = $("#med_num").val();
			
		//if(infoLang == 'cy') { alert($("#med_num").val()); }
			if(next == 1) {
			    
			    
			    this.medpicNum = (this.medpicNum < this.medNum - 1) ? this.medpicNum + 1 : 0;	

			}
			
			if (next == -1) {
			    
			    this.medpicNum = (this.medpicNum > 0) ? this.medpicNum - 1 : this.medNum - 1;
			    
			}
			
			if (next == 0) {
	
			   
			    this.medpicNum =  0 ;
			    
			}
			
	    }
	    
			
		if($("#grey").length == 0) {
		    
		    if($("#wrapper").length == 0) { // homepage
			
			$("#wrapper_hm").prepend('<div id="grey"></div>');

			
		    } else {  // other pages

			$("#wrapper").prepend('<div id="grey"></div>');
		    
		    }

		}

		if($("#bigpic").length == 0) {
		    
		    if($("#wrapper").length == 0) { // homepage
			
			$("#wrapper_hm").append('<div id="bigpic"><p id="bigpic_close">close<span></span></p><p id="bigpic_fwd_slide">fwd<span></span></p><p id="bigpic_back_slide">back<span></span></p><div id="bigpic_img" ></div></div>');

			
		    } else {  // other pages
			
			$("#wrapper").append('<div id="bigpic"><p id="bigpic_close">close<span></span></p><p id="bigpic_fwd_'+ src + '">fwd<span></span></p><p id="bigpic_back_'+ src + '">back<span></span></p><div id="bigpic_img" ></div></div>');
		     
		    }
		     
		}
		
		if(src == 'slide') {
		
		    if (next == 0) {
			
			$("#grey, #bigpic").hide();
		       $("#grey").fadeTo('fast', 0.8);
			$("#bigpic_img").load("/ajax/bigpic.php?pg=" + infoPg  + "&i=" + this.bigpicNum);
			$("#bigpic").fadeIn('slow');
			
		    } else {
			
			//$("#bigpic img").fadeOut('slow', function(){
			    $("#bigpic_img").load("/ajax/bigpic.php?pg=" + infoPg + "&i=" + this.bigpicNum, function(){
				$("#bigpic img").fadeOut(0, function(){
				    $("#bigpic img").fadeIn('slow')
				});
			    });
			//});
			
		    }
		    
		}
		
		if(src == 'med') {
    
		    if (next == 0) {
			
			$("#grey, #bigpic").hide();
		       $("#grey").fadeTo('fast', 0.8);
			$("#bigpic_img").load("/ajax/bigpic.php?pg=" + infoPg  + "&nm=" + this.medNm + "&i=" + this.medpicNum);
			$("#bigpic").fadeIn('slow');
			
		    } else {
			
			//$("#bigpic img").fadeOut('slow', function(){
			    $("#bigpic_img").load("/ajax/bigpic.php?pg=" + infoPg + "&nm=" + this.medNm + "&i=" + this.medpicNum, function(){
				$("#bigpic img").fadeOut(0, function(){
				    $("#bigpic img").fadeIn('slow')
				});
			    });
			//});
			
		    }
		    
		}   
		
		    
		    
                               
            }
                             //forward arrow
                            $("#rotator_forward").live('click', function(){
                                
                              fwdArrow();
                              
                            })
                           
                            // back arrow
                            
                            $("#rotator_back").live('click', function(){
        
                                backArrow();
                                                    
                            })
			    
			    //bigpic
			    
                            $("#rotator_curtain, p#clikpix a").live('click', function(){
				
                                showPic(0, 'slide');
                                                    
                            })
			    
                            $("img#med_img").live('click', function(){
                                showPic(0, 'med');
                                                    
                            })
			    //bigpic controls
			    
			    $("#bigpic_close, #close_splash, #crm_bulk_cancel").live('click',function(event){
				$("#bigpic, #btmpic, #grey").fadeOut('slow', function() {
				    $("#bigpic, #btmpic").detach();
				})
				
				event.preventDefault();

                            })
			    
			    
			    $("#bigpic_fwd_slide").live('click',function(){
				    showPic(1, 'slide');
                            })
			    $("#bigpic_back_slide").live('click',function(){
				    showPic(-1, 'slide');
                            })
          
			    $("#bigpic_fwd_med").live('click',function(){
				    showPic(1, 'med');
                            })
			    $("#bigpic_back_med").live('click',function(){
				    showPic(-1, 'med');
                            })

           function slideshow() {
            

                    //////////////////////////////////////////////////////////////////
                   
                   //change image
                   
                   ///////////////////////////////////////////////////////////////////
                   
                   
                   this.sumDiv -= 1;
                   
                   if (this.sumDiv <= 0) {
                           
                           this.cFade -= (1/this.fade);
                           this.cFade = (this.cFade < 0) ? 0 : this.cFade
        
                           this.delay -= 1;
                           
                           if(this.delay <= 0) {
                           
                                this.nFade += (1/this.fade);
                                this.nFade = (this.nFade >= .99) ? .99 : this.nFade;
				slideshow_current = (this.nFade > this.cFade) ? this.nIndex: this.current;
                                
                           }
        
                          $("#rotator img:eq(" + this.current + ")").fadeTo(0, this.cFade);
                           $("#rotator img:eq(" + this.nIndex + ")").fadeTo(0, this.nFade);
                           
                           if(this.nFade >= .99) {
                           
                                //reset
                                this.cFade = .99;
                                this.nFade = 0;
                                this.current = this.nIndex;
                                this.sumDiv = this.timeDiv;
                                this.delay =this.overlap_delay;
                                this.nIndex = (this.nIndex < this.num) ? this.current+1 : 0;
        
	
                           }

                   }
                   
           
        
          
                    
			if(!ie6) {
			    
				    //change spotlight opacity
				 
				    this.sumOpacity -= 1;	
				    
				    if (this.sumOpacity <= 0) {
				     
					    z= 25;
					    x = Math.floor(Math.random()*z) ;
					    this.spot_opacity = this.spot_max_opacity*x*x*x/(z*z*z);
					    $("#rotator_spot").fadeTo(0,this.spot_opacity);
					    this.timeOpacity = Math.floor(Math.random()*2*this.spot_speed);			   
					    this.sumOpacity = (this.timeOpacity >= 1) ? this.timeOpacity : 1;
					    
				    }
			    
				    //Splodges
					 
				    this.sumSplodge -= 1;	
				    
				    if (this.sumSplodge <= 0) {
					
					    z= this.splodge_int*280;
					    
					    x = z - Math.floor(Math.random()*z) ;
					    y = z - Math.floor(Math.random()*z);
					    
					    $("#rotator_splodge").css("backgroundPosition", x + "px " + y + "px")
					    
					    this.sumSplodge = Math.floor(Math.random()*this.splodge_freq*2)+1;
				    
				    }
			 
				    //lines		
					 
					 x_rand = Math.random();
					    
					 y_rand = Math.random();
					 
					 
					 //hide lines occassionally
					 
					 if(y_rand <.1) {
			  
					     if(x_rand < .2) {
						 
						 $("#rotator_lines").hide();
						 this.lines_x = Math.random()*300;
								     
					     } else {
						 
						 $("#rotator_lines").show();
			 
						 
					     }
					     
					 }
			  
					     if(x_rand >= 0.6) {
						 
						   this.lines_x = this.lines_x + this.lines_speed * this.lines_xdir;
						   
					     }
					     
					     if(x_rand >= 0.95) {
						 
						     this.lines_xdir = 0 - this.lines_xdir;
						     
					     }
			 
			  
					     if(y_rand >= 0.8) {
						 
						   this.lines_y = this.lines_y + this.lines_speed * this.lines_ydir ;
						   
					     }
					     
					      if(x_rand >= 0.95) {
						 
						     this.lines_ydir = 0 - this.lines_ydir;
						     
					     }
					       
					     if(this.lines_x >= 300 || this.lines_x <= -300 || this.lines_y >= 300 || this.lines_y <= -300) {
						 
						 this.lines_xdir = 0 - this.lines_xdir;
						  this.lines_ydir = 0 - this.lines_ydir;
						
					     }
					     
					    $("#rotator_lines").css("backgroundPosition", this.lines_x + "px " + this.lines_y + "px");
			}  
            
           }
   
 }

//-->
