$(document).ready(function() {	

var totalcarousel=parseInt(document.getElementById("count_carousel").innerHTML);
for(ca=0;ca<=totalcarousel;ca++)
{
document.getElementById("imageid"+ca).setAttribute("class", "deactive");
}

if(totalcarousel>0)
{
document.getElementById("imageid0").setAttribute("class", "active");
}
	$("#fronter span").click(function(){ 
		//Set Variables
	      
		
		 
		 var spanidval=this.id;
		var myNewString = spanidval.replace(/car/, '');
		
		mainvalue=parseInt(myNewString);
	
			
		$("#script1 a").attr({href: mainvalue});	
		
		$("#script2 a").attr({href: mainvalue});
		
		

		var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		
		var imgSRC = $(this).find('img').attr("src");
		
		
		var mainimgSRC = imgSRC.replace(/35/, '250');
		
		
		var aHREF = $(this).find('a').attr("href");
		
		
		var spanTEXT=$(this).find('#texthide'+mainvalue).html();
		var spanTEXT2=$(this).find('#texthide2'+mainvalue).html();
		//    nul for php value mean firtst value 
		
		document.getElementById('forfirstval').innerHTML='';
		// end //////
		
		
		
		//var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		
		
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			/////////////// code for active inactive ////////////////
			
			
			
			var totalcarousel=parseInt(document.getElementById("count_carousel").innerHTML);
            for(ca=0;ca<=totalcarousel;ca++)
            {
            document.getElementById("imageid"+ca).setAttribute("class", "deactive");
             }
			
		document.getElementById("imageid"+mainvalue).setAttribute("class", "active");
		
		//////////////////// end code for active inactive        ////////////////
		$("#image img").hide();
		//var loadingImage = 'loading.gif';
		//$("#image img").attr({ src: '' , alt: 'loading image...' ,title: 'loading image...'});
		$("#image img").attr({ src: mainimgSRC , alt: imgAlt});
		$("#image img").fadeIn(500);
		$("#image a").attr({ href: aHREF , rel: 'lightbox' ,title: imgAlt});
		$("#image a").attr({ href: aHREF , rel: 'lightbox' ,name: spanTEXT});
		
	    $("#titlecarousel").html(imgAlt);
		$("#text").html(spanTEXT2);
		
		$("#text").slideUp(0);
		$("#text").fadeIn(1000);
		
		}
		
		 initLightbox();
		
		return false;
		
	}) ;
	
	
	////////// for next previous of carousel /////////
	
	$("#fronter2 STRONG").click(function(){ 
		//Set Variables
		
		var mainvalue = $(this).find('a').attr("href");
		var wholevalue = $(this).find('a').attr("name");
		
		if(mainvalue>0)
		{
		mainvalue=parseInt(mainvalue) - 1;	
		}else
		{
		mainvalue=wholevalue;	
		}
		
		
		
		var aHREF='#car'+mainvalue;
		
				
		var imgAlt = $(aHREF).find('img').attr("alt"); //Get Alt Tag of Image
		
		var imgSRC = $(aHREF).find('img').attr("src");
		
		var mainimgSRC = imgSRC.replace(/35/, '250');
		
		
		var aHREF = $(aHREF).find('a').attr("href");
		
		var spanTEXT=$("#fronter span").find('#texthide'+mainvalue).html();
		var spanTEXT2=$("#fronter span").find('#texthide2'+mainvalue).html();
		
		
		
		//    nul for php value mean firtst value 
		
		document.getElementById('forfirstval').innerHTML='';
		// end //////
		
		//var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		
		
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			
			/////////////// code for active inactive ////////////////
			
			var totalcarousel=parseInt(document.getElementById("count_carousel").innerHTML);
              for(ca=0;ca<=totalcarousel;ca++)
               {
                document.getElementById("imageid"+ca).setAttribute("class", "deactive");
               }
			
		document.getElementById("imageid"+mainvalue).setAttribute("class", "active");
		
		//////////////////// end code for active inactive        ////////////////
		
		$("#image img").hide();
		//var loadingImage = 'loading.gif';
		//$("#image img").attr({ src: '' , alt: 'loading image...' ,title: 'loading image...'});
		$("#image img").attr({ src: mainimgSRC , alt: imgAlt});
		$("#image img").fadeIn(500);
		$("#image a").attr({ href: aHREF , rel: 'lightbox' ,title: imgAlt});
		$("#image a").attr({ href: aHREF , rel: 'lightbox' ,name: spanTEXT});
	    $("#titlecarousel").html(imgAlt);
		$("#text").html(spanTEXT2);
		
		$("#text").slideUp(0);
		$("#text").fadeIn(1000);
		
		
			
		$("#script1 a").attr({href: mainvalue});
		$("#script2 a").attr({href: mainvalue});
		
		
		
		}
		
		 initLightbox();
		
		return false;
		
	}) ;
	
	
	
	$("#fronter2 FONT").click(function(){ 
		//Set Variables
		
		var mainvalue = $(this).find('a').attr("href");
		var wholevalue = $(this).find('a').attr("name");
		
		mainvalue=parseInt(mainvalue);
		wholevalue=parseInt(wholevalue);
		
		if(mainvalue<wholevalue)
		{
		mainvalue=parseInt(mainvalue) + 1;	
		}else
		{
			
		mainvalue=0;	
		}
		
		
		
		var aHREF='#car'+mainvalue;
		
				
		var imgAlt = $(aHREF).find('img').attr("alt"); //Get Alt Tag of Image
		
		var imgSRC = $(aHREF).find('img').attr("src"); 
		var totalcarousel=parseInt(document.getElementById("count_carousel").innerHTML);
		
		var mainimgSRC = imgSRC.replace(/35/, '250');
		
		
		var aHREF = $(aHREF).find('a').attr("href");
		
		
		
		var spanTEXT=$("#fronter span").find('#texthide'+mainvalue).html();
		var spanTEXT2=$("#fronter span").find('#texthide2'+mainvalue).html();
		
		//    nul for php value mean firtst value 
		
		document.getElementById('forfirstval').innerHTML='';
		// end //////
		
		//var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		
		
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			
			/////////////// code for active inactive ////////////////
		
			var totalcarousel=parseInt(document.getElementById("count_carousel").innerHTML);
              for(ca=0;ca<=totalcarousel;ca++)
               {
                document.getElementById("imageid"+ca).setAttribute("class", "deactive");
               }
			
		document.getElementById("imageid"+mainvalue).setAttribute("class", "active");
		
		//////////////////// end code for active inactive        ////////////////
		
		$("#image img").hide();
		//var loadingImage = 'loading.gif';
		//$("#image img").attr({ src: loadingImage , alt: 'loading image...' ,title: 'loading image...'});
		$("#image img").attr({ src: mainimgSRC , alt: imgAlt});
		$("#image img").fadeIn(500);
		$("#image a").attr({ href: aHREF , rel: 'lightbox' ,title: imgAlt});
		$("#image a").attr({ href: aHREF , rel: 'lightbox' ,name: spanTEXT});
	    $("#titlecarousel").html(imgAlt);
		$("#text").html(spanTEXT2);
		
		$("#text").slideUp(0);
		$("#text").fadeIn(1000);
		
		
			
		$("#script2 a").attr({href: mainvalue});
		$("#script1 a").attr({href: mainvalue});
		
		
		
		}
		
		 initLightbox();
		
		return false;
		
	}) ;
	
	/////////// end for next previous of carousel ///////
	
		
	$(".myYoutubePlaylist_Ul img").click(function(){ 
	
	var uALR = $(this).attr("alt");
	
	var uTITLE = $(this).attr("title"); //Get Alt Tag of Image
	
	width='210';
	height='140';
	
	myYoutubePlaylist_cfStr = '<obj' + 'ect width="' + width + '" height="' + height + '" data="http://www.youtube.com/v/' + uALR + '" type="application/x-shockwave-flash">';
	myYoutubePlaylist_cfStr += '<param name="movie" value="http://www.youtube.com/v/'+ uALR  + '"/>';
	myYoutubePlaylist_cfStr += '<param name="allowFullScreen" value="true"/>';
	myYoutubePlaylist_cfStr += '<param name="allowscriptaccess" value="always"/>';
	
	myYoutubePlaylist_cfStr += '<embed src="http://www.youtube.com/v/'+ uALR  + ' width="' + width + '" height="' + height + '" allowscriptaccess="always" allowfullscreen="true"/>';
	myYoutubePlaylist_cfStr += '<' + '/object><div><a href="http://www.youtube.com/watch?v='+ uALR +'"><span id="bs">'+uTITLE+' </span></a></div>';
	
	
	$("#youtubeplay").html(myYoutubePlaylist_cfStr);
	
	
	
	return false;
	
	}) ;
	
	
	$(".videoslist_box img").click(function(){ 
	
	var uALR = $(this).attr("alt");
	
	var uTITLE = $(this).attr("title"); //Get Alt Tag of Image
	
	width='210';
	height='140';
	
	myYoutubePlaylist_cfStr = '<obj' + 'ect width="' + width + '" height="' + height + '" data="http://www.youtube.com/v/' + uALR + '" type="application/x-shockwave-flash">';
	myYoutubePlaylist_cfStr += '<param name="movie" value="http://www.youtube.com/v/'+ uALR  + '"/>';
	myYoutubePlaylist_cfStr += '<param name="allowFullScreen" value="true"/>';
	myYoutubePlaylist_cfStr += '<param name="allowscriptaccess" value="always"/>';
	
	myYoutubePlaylist_cfStr += '<embed src="http://www.youtube.com/v/'+ uALR  + ' width="' + width + '" height="' + height + '" allowscriptaccess="always" allowfullscreen="true"/>';
	myYoutubePlaylist_cfStr += '<' + '/object><div><a href="http://www.youtube.com/watch?v='+ uALR +'"><span id="bs">'+uTITLE+' </span></a></div>';
	
	
	$("#youtubeplay").html(myYoutubePlaylist_cfStr);
	
	
	
	return false;
	
	}) ;
	
	
		
	
});//Close Function

