window.addEvent('domready', function(){
  var del_str='';
  var params='';
  var slides = new Array();
  var responseText='';
  var temp_str;
  var add_url='cart.php';
  var del_url='del_pro_cart.php';
  var click_track=0;
  var chk_no_class=0;
  var header_img='';
  var prev_id;
  var next_id;
  var get_id;
  var total_pro_count;
  var prev_highlight;
  var pselid='';
  var poptionid='';
  var set_click;
  var max_last_color_div=4;
  var loader_img='<img src=http://www.white-desert.com/shop/skin1/images/ajax-loader.gif />';
  var img_buy_now='http://www.white-desert.com/shop/skin1/images/buy_this_item.jpg';
  var img_not_for_sell='http://www.white-desert.com/shop/skin1/images/not-for-sale.jpg';
// var loader_img='<img src=http://localhost/white-desert/shop/skin1/images/ajax-loader.gif />';
  var loader_img_url='http://www.white-desert.com/shop/skin1/images/ajax-loader.gif';
// var loader_img_url='http://localhost/white-desert/shop/skin1/images/ajax-loader.gif';
//  var header_img='http://localhost/white-desert/shop/skin1/images/header.jpg';
 // var temp_loader_img='http://localhost/white-desert/shop/skin1/images/temp-loader.gif';
//  var temp_loader_img='http://www.white-desert.com/shop/skin1/images/temp-loader.gif';
  var cur_req_url='';
  var DEL_IMG_URL='http://www.white-desert.com/shop/skin1/images/del.jpg';
  //var DEL_IMG_URL='http://localhost/white-desert/shop/skin1/images/del.jpg';
  var div_gen_str="";  
  var cartPcon= new Array();
  var cartDelImg=new Array();
  var cartProIndex= new Array();
  var cartProName=new Array();
  var cartDelImgCon=new Array();
  var pro_list=new Array();
  var cur_currency="";
  var exchange_rate="";
  var currency_symbol="";
  
  //hide top order div
  var myFx = new Fx.Slide('order_top', {
			    duration: 1500,
			    transition: Fx.Transitions.Pow.easeOut
				});
				 myFx.hide();

  var myFx = new Fx.Slide('pcolor_container', {
			    duration: 1500,
			    transition: Fx.Transitions.Pow.easeOut
				});
				 myFx.hide();
  //hide top order div
  
  //delete products on load from minicart
  $$('img.del_pro').addEvent('click', function(){

		var id2 = this.get('id');
		cur_del_str=id2.split("del_pro_");	
		cur_id=cur_del_str[1];
	    var cur_div ='kit_'+cur_id;
	    params='?mode=delete&productindex='+cur_id;
		$('cart_total_cost').innerHTML=loader_img;	

		$(id2).set('send', {
   			     method: 'post',url: del_url+params,
     		     onSuccess: function(responseText, responseXML) {
				 response_str=responseText.split("|");
				 $('cart_total_cost').set('html', '<p>SUBTOTAL='+response_str[1]+'</p>');
				//$('cart_total_items').set('html', response_str[2]);
				minicart.init();
			
               	 },
          		 onFailure: function(headerName, value) {
			 	 $('cart_total_cost').set('html', '<p>SUBTOTAL='+'Sorry for Ajax Error! Please Try again<p>');
				 }
		 });
		 $(id2).send(); 

	/* HIDE DIV */
	 var myFx = new Fx.Slide(cur_div, {
    	duration: 1500,
	    transition: Fx.Transitions.Pow.easeOut
		});
 	myFx.hide();
	
	var myFx = new Fx.Slide('currency', {
			    duration: 1500,
			    transition: Fx.Transitions.Pow.easeOut
				});
				 myFx.hide();
	
	
	/* HIDE DIV */

  });
//END delete products from minicart

//ADD products on minicart
	$$('div.order').addEvent('click', function(){
		//clear all existing childs under cart_pinfo

		var element = document.getElementById("cart_pinfo");
			while (element.firstChild) {
			  element.removeChild(element.firstChild);
		}
		//clear all existing childs under cart_pinfo

		/*Clear all stock message */
		/*
		$$('div.stock_msg').each(function(el){
			el.set('html', ''); 
	 	}); 
		*/
		/*Clear all stock message */

		var id2 = this.get('id');
		cur_padd=id2.split("top_");		
	
		
		var id2 = this.get('id');
	    cur_padd=id2.split("order");
		
		$('kits').value=cur_padd[1];
		
        $('cart_total_cost').innerHTML=loader_img;	
		target_form_id='orderform';
 	    $(target_form_id).set('send', {
			method: 'post',
            onSuccess: function(responseText, responseXML) {

				obj=JSON.decode(responseText);
				$('cart_total_cost').set('html', '<p>SUBTOTAL='+obj.subtotal+'</p>');
				var div_gen_str='';
				
				var del_pro_id='';
				var cur_div='';
								
				if(obj.product){
					$('cart_pinfo').set('html', '');
					for( intIndex = 0; intIndex < obj.product.length; intIndex++ )
					{
						var cartid=obj.product[intIndex]['cartid'];
						del_pro_id='del_pro_'+cartid;
						var BRClass  = new Element('br', {'class': 'clearStyle'});
						cartPcon[cartid]  = new Element('div', {'class':'cart',id: 'kit_'+cartid});
						cartProIndex[cartid]  = new Element('div', {'class':'cart-container--01'});
						cartProName[cartid]  = new Element('div', {'class':'cart-container--02'});
						cartDelImgCon[cartid]=new Element('div', {'class':'cart-container--03'});
					
						///generate On click del fucntion////
						cartDelImg[cartid] = new Element('img', {
							'class': 'del_pro',
							'src':DEL_IMG_URL,id:del_pro_id,
							events: 
							{
								'click': function()
								{	
									//cur_div= this.getParent();
									//alert(cur_div);
									var cartid = this.id.replace('del_pro_', '');
									//alert('cur_div'+cur_div);
									cur_div= 'kit_'+cartid;
									params='?mode=delete&productindex='+cartid;
									$('cart_total_cost').innerHTML=loader_img;	
 									$(this.id).set('send', {
						 	       		method: 'post',url: del_url+params,
    	             					onSuccess: function(responseText, responseXML) {
											response_str=responseText.split("|");
											$('cart_total_cost').set('html', '<p>SUBTOTAL='+response_str[1]+'</p>');
						 				minicart.init();
                     				},
				               			onFailure: function(headerName, value) {
			          		 			}
								 	});
							    	$(this.id).send(); 
							    	/* HIDE DELETED DIV*/
							     	var myFx = new Fx.Slide(cur_div, {
								 	  duration: 1500,
								      transition: Fx.Transitions.Pow.easeOut
							  	 	});
							  	 	myFx.hide();	
  							  		/* HIDE DELETED DIV*/
						 		  }
						 	}
						
					     });						
						///generate On click del fucntion////			
						
						//BUilding Mini cart structure
						cartPcon[cartid].inject('cart_pinfo');
						cartProIndex[cartid].inject(cartPcon[cartid]);
						cartProName[cartid].inject(cartPcon[cartid]);
						cartDelImg[cartid].inject(cartDelImgCon[cartid]);
						cartDelImgCon[cartid].inject(cartPcon[cartid],'bottom');
						BRClass.inject(cartPcon[cartid],'bottom');
						
						proIndex=intIndex+1;
 						div_gen_str='<p>'+proIndex+'</p>';
						cartProIndex[cartid].set('html', div_gen_str);
						div_gen_str="";		
		 				div_gen_str+='<p>'+obj.product[intIndex]['product']+'</p>'+obj.product[
			            intIndex]['poptions']+'<br/>'+obj.product[intIndex]['price']+'<br /><span>Quantity:&nbsp;'+obj.product[intIndex]['amount']+'</span>';
						cartProName[cartid].set('html', div_gen_str);
						div_gen_str="";		
						//Building Mini cart structure
				
					 }//end loop
				}//end if of if(obj.product)
				
				if(obj.outofstock>0){
					//UPDATE QTY BOX 
					//var stock_msg_id='stock_msg_'+obj.outofstock;
					/* 
					var qty_id2='pq'+cur_padd[1];
					$(id2).set('class','dis_order');
					$(id2).set('html','BUY');
					
					for( i = $(qty_id2).options.length; i >= 0; i-- )
                  			{		
								$(qty_id2).options[i]=null;
								
							}
					$(qty_id2).options[0] = new Option(0);
					$(qty_id2).options[0].value='0';
					*/
					//UPDATE QTY BOX 
					alert('Sorry requested option is out of stock for the product '+obj.cur_reg_pname);
				}
				
				//on buy now no alternate currecny box
				var myFx = new Fx.Slide('currency', {
			    duration: 1500,
			    transition: Fx.Transitions.Pow.easeOut
				});
				 myFx.hide();
				//on buy now no alternate currecny box
              minicart.init();
              },

              onFailure: function(headerName, value) {
				$('cart_total_cost').set('html', 'Error');
				//$('cart_total_items').set('html', 'Error');
              }

	       });//end  of target_form_id
  		  $(target_form_id).send(this.action); 

});//end of div.order click

///////TOP BUY NOW///////////
//ADD products on minicart
$$('div.order_top').addEvent('click', function(){

		//clear all existing childs under cart_pinfo

		var element = document.getElementById("cart_pinfo");
			while (element.firstChild) {
			  element.removeChild(element.firstChild);
		}
		//clear all existing childs under cart_pinfo

		/*Clear all stock message */
		/*
		$$('div.stock_msg').each(function(el){
			el.set('html', ''); 
	 	}); 
		*/
		/*Clear all stock message */
		var cur_padd2;
		var id2 = this.get('id');
	    cur_padd2=id2.split("top_");

		$('kits').value=cur_padd2[1];
		$('cart_total_cost').innerHTML=loader_img;	
		
		target_form_id='orderform';
 	    $(target_form_id).set('send', {
			method: 'post',
            onSuccess: function(responseText, responseXML) {
			
				obj=JSON.decode(responseText);
							
				$('cart_total_cost').set('html', '<p>SUBTOTAL='+obj.subtotal+'</p>');
				var div_gen_str='';
				
				var del_pro_id='';
				var cur_div='';
								
				if(obj.product){
					$('cart_pinfo').set('html', '');
					for( intIndex = 0; intIndex < obj.product.length; intIndex++ )
					{
						var cartid=obj.product[intIndex]['cartid'];
						del_pro_id='del_pro_'+cartid;
						var BRClass  = new Element('br', {'class': 'clearStyle'});
						cartPcon[cartid]  = new Element('div', {'class':'cart',id: 'kit_'+cartid});
						cartProIndex[cartid]  = new Element('div', {'class':'cart-container--01'});
						cartProName[cartid]  = new Element('div', {'class':'cart-container--02'});
						cartDelImgCon[cartid]=new Element('div', {'class':'cart-container--03'});
					
						///generate On click del fucntion////
						cartDelImg[cartid] = new Element('img', {
							'class': 'del_pro',
							'src':DEL_IMG_URL,id:del_pro_id,
							events: 
							{
								'click': function()
								{	
									//cur_div= this.getParent();
									//alert(cur_div);
									var cartid = this.id.replace('del_pro_', '');
									//alert('cur_div'+cur_div);
									cur_div= 'kit_'+cartid;
									params='?mode=delete&productindex='+cartid;
									$('cart_total_cost').innerHTML=loader_img;	
 									$(this.id).set('send', {
						 	       		method: 'post',url: del_url+params,
    	             					onSuccess: function(responseText, responseXML) {
											response_str=responseText.split("|");
											$('cart_total_cost').set('html', '<p>SUBTOTAL='+response_str[1]+'</p>');
						 				minicart.init();
                     },
				               			onFailure: function(headerName, value) {
			          		 			}
								 	});
							    	$(this.id).send(); 
							    	/* HIDE DELETED DIV*/
							     	var myFx = new Fx.Slide(cur_div, {
								 	  duration: 1500,
								      transition: Fx.Transitions.Pow.easeOut
							  	 	});
							  	 	myFx.hide();	
  							  		/* HIDE DELETED DIV*/
						 		  }
						 	}
						
					     });						
						///generate On click del fucntion////			
						
						//BUilding Mini cart structure
						cartPcon[cartid].inject('cart_pinfo');
						cartProIndex[cartid].inject(cartPcon[cartid]);
						cartProName[cartid].inject(cartPcon[cartid]);
						cartDelImg[cartid].inject(cartDelImgCon[cartid]);
						cartDelImgCon[cartid].inject(cartPcon[cartid],'bottom');
						BRClass.inject(cartPcon[cartid],'bottom');
						
						proIndex=intIndex+1;
 						div_gen_str='<p>'+proIndex+'</p>';
						cartProIndex[cartid].set('html', div_gen_str);
						div_gen_str="";		
		 				div_gen_str+='<p>'+obj.product[intIndex]['product']+'</p>'+obj.product[
			            intIndex]['poptions']+'<br/>'+obj.product[intIndex]['price']+'<br /><span>Quantity:&nbsp;'+obj.product[intIndex]['amount']+'</span>';
						cartProName[cartid].set('html', div_gen_str);
						div_gen_str="";		
						//cartDelImg[cartid].set('html', div_gen_str);
						//Building Mini cart structure
				
					 }//end loop
				}//end if of if(obj.product)
				
				if(obj.outofstock>0){
					//var stock_msg_id='stock_msg_'+obj.outofstock;
								
					alert('Sorry requested option is out of stock for the product '+obj.cur_reg_pname);
				}
				
				//on buy now no alternate currecny box
				var myFx = new Fx.Slide('currency', {
			    duration: 1500,
			    transition: Fx.Transitions.Pow.easeOut
				});
				 myFx.hide();
				//on buy now no alternate currecny box
              minicart.init();
              },

              onFailure: function(headerName, value) {
				$('cart_total_cost').set('html', 'Error');
				//$('cart_total_items').set('html', 'Error');
              }

	       });//end  of target_form_id
  		  $(target_form_id).send(this.action); 

});//end of div.order click

///////TOP BUY NOW///////
/*START LOAD dynamic qty */
$$('select.pro_opt_inv').addEvent('change', function(){
var id3 = this.get('id');
//alert($(id2).options[$(id2).selectedIndex].value);
if($(id3).options[$(id3).selectedIndex].value)
var url='inv_check.php?opt_id='+$(id3).options[$(id3).selectedIndex].value+'&pro_track='+id3;
str=id3.split("pq");
qty_id='pq'+str[2];
$(id3).set('send', {
						
           			     method: 'post',url: url,
    
            			    onSuccess: function(responseText, responseXML) {
							response_str=responseText.split("|");
							obj=JSON.decode(responseText);
							//load dynamic qty on qty box
							var setIndex=0,intIndex=0;
							
							for( i = $(qty_id).options.length; i >= 0; i-- )
                  			{		
								$(qty_id).options[i]=null;
								
							}
							
							for( intIndex = 0; intIndex < obj.amount; intIndex++ )
                  			{		
								setIndex=intIndex+1;
								$(qty_id).options[intIndex] = new Option(setIndex);
								$(qty_id).options[intIndex].value=setIndex;
								//$(qty_id).options[intIndex].text=intIndex;
								
							}
							//load dynamic qty on qty box
               		  },

               		 onFailure: function(headerName, value) {
               		   
               		 }

       			 });
			 $(id3).send(); 

});									   
/*END LOAD dynamic qty */


/* change currency */
$('change_currency').addEvent('click', function(){
											
	var myFx = new Fx.Slide('currency', {
    	duration: 1500,
    	transition: Fx.Transitions.Pow.easeOut
	});
 myFx.toggle();
});

//function for currency convert
$$('a.currency_links').addEvent('click', function(){
cur_req=this.get('id');
cur_req_url='convert_currency.php';
params='?cur_req='+cur_req;
	        $('cart_total_cost').innerHTML=loader_img;	
			
			$(cur_req).set('send', {
			method: 'post',url:cur_req_url+params,
            onSuccess: function(responseText, responseXML) {
				obj=JSON.decode(responseText);
				$('cart_total_cost').set('html', '<p>SUBTOTAL='+obj.subtotal+'</p>');
				var div_gen_str='';
				
				var del_pro_id='';
				var cur_div='';
				if(obj.product){
					$('cart_pinfo').set('html', '');
					for( intIndex = 0; intIndex < obj.product.length; intIndex++ )
					{
						var cartid=obj.product[intIndex]['cartid'];
						del_pro_id='del_pro_'+cartid;
						var BRClass  = new Element('br', {'class': 'clearStyle'});
						cartPcon[cartid]  = new Element('div', {'class':'cart',id: 'kit_'+cartid});
						cartProIndex[cartid]  = new Element('div', {'class':'cart-container--01'});
						cartProName[cartid]  = new Element('div', {'class':'cart-container--02'});
						cartDelImgCon[cartid]=new Element('div', {'class':'cart-container--03'});
					
						///generate On click del fucntion////
						cartDelImg[cartid] = new Element('img', {
							'class': 'del_pro',
							'src':DEL_IMG_URL,'id':del_pro_id,
							events: 
							{
								'click': function()
								{	
									var cartid = this.id.replace('del_pro_', '');
									cur_div= 'kit_'+cartid;
									params='?mode=delete&productindex='+cartid;
									$('cart_total_cost').innerHTML=loader_img;	
 									$(this.id).set('send', {
						 	       		method: 'post',url: del_url+params,
    	             					onSuccess: function(responseText, responseXML) {
											response_str=responseText.split("|");
											$('cart_total_cost').set('html', '<p>SUBTOTAL='+response_str[1]+'</p>');
			                    			minicart.init();											
											
						 				},
				               			onFailure: function(headerName, value) {
			          		 			}
								 	});
							    	$(this.id).send(); 
									/* HIDE DELETED DIV*/
							     	var myFx = new Fx.Slide(cur_div, {
								 	  duration: 1500,
								      transition: Fx.Transitions.Pow.easeOut
							  	 	});
							  	 	myFx.hide();	
  							  		/* HIDE DELETED DIV*/
						 		  }
						 	}
						
					     });						
						///generate On click del fucntion////			
						
						//BUilding Mini cart structure
						cartPcon[cartid].inject('cart_pinfo');
						cartProIndex[cartid].inject(cartPcon[cartid]);
						cartProName[cartid].inject(cartPcon[cartid]);
						cartDelImg[cartid].inject(cartDelImgCon[cartid]);
						cartDelImgCon[cartid].inject(cartPcon[cartid],'bottom');
						BRClass.inject(cartPcon[cartid],'bottom');
						
						proIndex=intIndex+1;
 						div_gen_str='<p>'+proIndex+'</p>';
						cartProIndex[cartid].set('html', div_gen_str);
						div_gen_str="";		
		 				div_gen_str+='<p>'+obj.product[intIndex]['product']+'</p>'+obj.product[
			            intIndex]['poptions']+'<br/>'+obj.product[intIndex]['price']+'<br /><span>Quantity:&nbsp;'+obj.product[intIndex]['amount']+'</span>';
						cartProName[cartid].set('html', div_gen_str);
						div_gen_str="";		
						//Building Mini cart structure
				
					 }//end loop
				}//end if of if(obj.product)
				
						
              },

              onFailure: function(headerName, value) {
				$('cart_total_cost').set('html', 'Error');
				//$('cart_total_items').set('html', 'Error');
              }

	       });//end  of target_form_id
		  $(cur_req).send(); 

   });

//hide currency link initially
var myFx = new Fx.Slide('currency', {
    duration: 1500,
    transition: Fx.Transitions.Pow.easeOut
});
 myFx.toggle();
//hide currency link initially
/* SHAHED currency */

//top banner pinfo PAUL and SHAHED
var sc = new Fx.Scroll(window);
$$('div.col-01').each(function(el)
   {
	el.addEvent('click', function()
	  { 
		target=this.get('id');
		prev_id=target;
		click_track=click_track+1;
		target_pid=target.split("product_");
		//load option image
		$$('Select.pro_opt_inv').each(function(e2){
			str=e2.get('id').split("pq");

			if(str[2]==target_pid[1])
				pselid="pq"+str[1]+"pq"+target_pid[1];
		});
		poptionid='';
		if(pselid){
		poptionid=$(pselid).options[$(pselid).options.selectedIndex].value;
		pselid='';
		}
		//load option image
		///FUNCTION TO LOAD PINFO/////
		if(poptionid){
		params='?pid='+target_pid[1]+'&poptionid='+poptionid;
		poptionid='';
		}
		else{
		params='?pid='+target_pid[1];
		}
		try{
		$('view_next_item').set('html','');
		$('view_prev_item').set('html','');
		}catch(erx){ }
		if($('cat_selected').value=='249')
		{
   	   		header_img='http://www.white-desert.com/shop/skin1/images/KitList_MEN_still-1.jpg';
			   //header_img='http://localhost/white-desert/shop/skin1/images/KitList_MEN_still-1.jpg';
		}
		else if ($('cat_selected').value=='250')
		{
			 header_img='http://www.white-desert.com/shop/skin1/images/KitList_WOMEN_still-1.jpg';
		}
		
		cur_req_url='load_kit_pinfo.php'+params;
		//remove flash with pinfo div
		if(click_track==1){
		
			$('flashcontent').set('html', '');
			var head_img  = new Element('img', {'src':header_img,'id':'head_img','width':'801','height':'358'});
			
			var product_info  = new Element('div', {'id':'product_info'});
			head_img.inject('header', 'top');
			product_info.inject('head_img', 'after');
			var product_name  = new Element('h1', {'id':'product_name'});
			product_name.inject('product_info', 'top');

			var product_description  = new Element('p', {'id':'product_description'});
			product_description.inject('product_name', 'after');
      
      var product_image_loader  = new Element('div', {'id':'product_image_loader'});
			product_image_loader.inject('product_description', 'after');
									
			var product_image  = new Element('img', {'id':'product_image'});
			product_image.inject('product_image_loader', 'top');
			
			var ajax_loader_img  = new Element('div', {'id':'ajax_loader_img'});
			ajax_loader_img.inject('product_image_loader', 'after');
			
			var product_price  = new Element('div', {'id':'product_price'});
			product_price.inject('ajax_loader_img', 'after');
			
			var lbl_product_wd_price  = new Element('label', {'for':'product_wd_price','id':'lbl_product_wd_price','html':'White Desert Price'});
			lbl_product_wd_price.inject('product_price', 'top');
			
			var product_wd_price  = new Element('div', {'id':'product_wd_price'});
			product_wd_price.inject('lbl_product_wd_price', 'after');
			
			var product_details  = new Element('div', {'id':'product_details'});
			product_details.inject('product_price', 'after');

			var product_color_label  = new Element('div', {'id':'product_color_label'});
			product_color_label.inject('product_details', 'top');
			
			var product_color_chooser  = new Element('div', {'id':'product_color_chooser'});
			product_color_chooser.inject('product_color_label', 'after');
    		
	   }
	   //remove flash with pinfo div
		//AJAX LOADER
		try{$('txt_image_enlarge').set('html','');}catch(erx){}
		$('product_dimage_link').set('html', '');
		$('product_dimage_link').inject('product_dimage_link_con', 'top');
		
		$('product_image_loader').set('html','' );
		
		$('product_name').set('html', '');
		// shift POPup links to save
    $('pmore_info').inject('pmore_info_con', 'bottom');
    
    $('product_description').set('html', '');
		
		$('top_buy_link').set('html','');
	
		$('product_color_label').set('html','');
		$('product_wd_price').set('html', '');
		$('product_color_label').set('html','');
		$('lbl_product_wd_price').set('html','');

		$('ajax_loader_img').set('html', loader_img);
		var top_buy_id='top_'+target_pid[1];
		
		//restore pcolor divs to pcolor_container start
					if(set_click==1){
						set_click=0;
						$('pcolor_container').set('html','');
		
						for( pcolor_index = 0; pcolor_index < max_last_color_div; pcolor_index++ )
						{
							pcolor_index_prev='pcolor'+pcolor_index;
							color_pos1=pcolor_index+1;
							
							pcolor_dv_id1='pcolor'+color_pos1;
							hidden_col_opt_id1='pcolor'+color_pos1+'_optid';
							$(hidden_col_opt_id1).set('value','0');
							if(color_pos1>1)
								$(pcolor_dv_id1).inject(pcolor_index_prev, 'after');
							else
								$(pcolor_dv_id1).inject('pcolor_container', 'top');
							
							
							$(pcolor_dv_id1).set('class','');
							$(pcolor_dv_id1).set('style','');
						}
					$('product_color_chooser').set('html','');	
					}
		//restore pcolor divs to pcolor_container end
       
		var found=0;
	 	var next_item_id;
	    var cur_pro_id=this.get('id');
	
	 	var all_pro_div = $(document.body).getElements('div.col-01');
	 	total_pro_count=0;
			all_pro_div.each(function(item, index)
			  {
				total_pro_count++;
				if(cur_pro_id==item.get('id')){
					get_id=total_pro_count;
				}
				pro_list[total_pro_count]=item.get('id');
			 });
			
		//AJAX LOADER
		$(target).set('send', {
   			     method: 'post',url: cur_req_url,
     		     onSuccess: function(responseText, responseXML) {
					obj=JSON.decode(responseText);
					//alert(obj.opt);
					//set_click=set_click+1;
					if(prev_highlight){
						prev_highlight.destroy();
					}
					var highlight_top  = new Element('div', {'id':obj.highlight});
					highlight_top.inject('product_info', 'before');
					prev_highlight = $(obj.highlight);
					
					$('ajax_loader_img').set('html', '');
					//alert(obj.color_code);
					if(obj.pimg){
					
						if(obj.details_pimg){
							$('product_dimage_link').inject('product_image_loader', 'top');
							$('product_dimage_link').set('html','<img id=product_image src="'+obj.pimg+'" />');
							$('product_dimage_link').set('href',obj.details_pimg);
							$('product_dimage_link').store('title', obj.pname);
							try{$('txt_image_enlarge').set('html','&lt;&nbsp;Click image to enlarge');}catch(erxx){ }
						}
						else
						{
							$('product_dimage_link').set('html', '');
							$('product_dimage_link').inject('product_dimage_link_con', 'top');
							$('product_image_loader').set('html', '<img id=product_image src="'+obj.pimg+'" />');
							try{$('txt_image_enlarge').set('html','');}catch(erxxx){ }
						}
						//POPUP link shift to desc
						if(obj.pfulldescr){
						  
              	$('product_description').set('html', obj.pdescr);
              	$('pmore_info_con').set('style', 'visibility:true;');
                $('pmore_info').set('style', 'visibility:true;float:right;');
                $('pmore_info').inject('product_color_label', 'after');
                $('pmore_info_link').set('href','popup_pinfo.php?pid='+obj.ppid);
                $('pmore_info_link').set('style', 'visibility:true;float:right;color: #336699;');
                
            }
            else
            {
                 $('product_description').set('html', obj.pdescr);
                 $('pmore_info_con').set('style', 'visibility:hidden;');
                 $('pmore_info').set('style', 'visibility:hidden;');
                
            }
            			
						
						if(obj.technical_name!="")
            $('product_name').set('html', obj.technical_name);
            else
            $('product_name').set('html', obj.pname);
            
						$('lbl_product_wd_price').set('html','White Desert Price');
					
						if(obj.product_type=="offline"){
							$('product_wd_price').set('html', 'N/A');
							$('top_buy_link').set('html','<img src="'+img_not_for_sell+'" />');
							$('top_buy_link').set('style','cursor:text');
						}
						else{
							$$('div.order_top').setProperty('id', top_buy_id);
							$('top_buy_link').set('html','<img src="'+img_buy_now+'" />');
							$('top_buy_link').set('style','cursor:pointer');
							$('product_wd_price').set('html', obj.list_price);
						}

						$$('div.top_nav_container').inject('product_wd_price', 'after');
						$$('div.order_top').inject('top_nav_container', 'top');
						//if(obj.product_type!="offline")
						//$$('div.order_top').setProperty('style','width:141px');

						
						if(get_id<total_pro_count && get_id!=total_pro_count){
						    $('view_next_item').set('html','NEXT&nbsp;&gt;');
							$$('div.top_next_item').setProperty('id', pro_list[get_id]);
							//$$('div.top_prev_item').set('style','width:0px');
						}
						else{
							$('view_next_item').set('html', '');
						}
					    if(get_id>1){
							$$('div.top_prev_item').set('style','width:62px');
							$('view_prev_item').set('html', '&lt;&nbsp;PREVIOUS');
							$$('div.top_prev_item').set('id', pro_list[get_id-1]);
						}
		    			else{
							$$('div.top_prev_item').set('style','width:0px');
							$('view_prev_item').set('html', '');
							//$('view_next_item').focus(); 
						}
					
									
					//dynamic color div generation
					
					if(obj.color_code)
						{
              
							for( intIndex = 0; intIndex < max_last_color_div; intIndex++ )
							{
								//div_gen_str=div_gen_str+"<div class='product_color' style='background-color:"+ obj.color_code[intIndex]+"'></div>";
								color_pos=intIndex+1;
								pcolor_dv_id='pcolor'+color_pos;
								pcolor_dv_prev_id='pcolor'+intIndex;
								//alert(pcolor_dv_id);
								$(pcolor_dv_id).set('class','product_color');
								
								if(obj.color_code[intIndex]){
									
									//find color optin id start
										if(obj.optionid)
										{ hidden_col_opt_id='';
											for( intIndex2 = 0; intIndex2 <obj.optionid.length; intIndex2++ )
											{
											
												
												if (obj.color_opt_name[intIndex2]==obj.color_name[intIndex]&&obj.color_opt_name[intIndex2]!=''&&obj.color_name[intIndex]!=''){
												
													//alert(obj.color_name[intIndex]);
													if(obj.optionid[intIndex2]){
													hidden_col_opt_id='pcolor'+color_pos+'_optid';
													//$(hidden_col_opt_id).set('value',obj.color_opt_name[intIndex2]);
													strp=obj.optionid[intIndex2]+'pid'+target_pid[1];
													//alert(obj.color_name[intIndex]);
													if(hidden_col_opt_id)
													$(hidden_col_opt_id).set('value',strp);
										
													}
													
												}
												
											}
										}
									//find color option id end
					
									if(obj.color_code[intIndex]=='#FFFFFF'){ 
    								  //$(pcolor_dv_id).set('style','background-color:'+obj.color_code[intIndex]);
    								  $(pcolor_dv_id).set('style','border:1px solid #cccccc;width:18px;	cursor:pointer;');
    								  
								  }
								  else
								  {
									 $(pcolor_dv_id).set('style','cursor:pointer;background-color:'+obj.color_code[intIndex]);
								  }
								}
								else
									$(pcolor_dv_id).set('style','');
								
								if(color_pos>1)
									$(pcolor_dv_id).inject(pcolor_dv_prev_id,'after');
								else
									$(pcolor_dv_id).inject('product_color_chooser','top');
								set_click=1;
								
							}
							
						}
						else if(obj.color_code=='')
						{
							chk_no_class=1;
							$('product_color_chooser').set('html','');
							$('product_color_label').set('html','');
							
						}
						else
						{
							
						}
						if(chk_no_class==0){
							//$('product_color_chooser').set('html',div_gen_str);
							$('product_color_label').set('html','AVAILABLE COLOURS');
							div_gen_str='';
							
						}
						chk_no_class=0;
						//$('pcolor_container').set('html','');
							
					}

               	 },
          		 onFailure: function(headerName, value) {
			 	 }
		 });
		 $(target).send(); 
    
		///////
		sc.toTop(); 
		});
});

//////top banner next item//////////
$$('div.top_next_item').each(function(el){
	
	el.addEvent('click', function(){ 
	 var found=0;
	 var next_item_id='';
	 var cur_pro_id=this.get('id');
     $('view_next_item').set('html','');
	 $('view_prev_item').set('html','');
	 prev_id=cur_pro_id;
	 get_id=get_id+1;
		
					
		target=pro_list[get_id];
		click_track=click_track+1;
		target_pid=target.split("product_");
	
		///FUNCTION TO LOAD PINFO/////
		params='?pid='+target_pid[1];
		
		if($('cat_selected').value=='249')
		{
   	   		header_img='http://www.white-desert.com/shop/skin1/images/KitList_MEN_still-1.jpg';
		}
		else if ($('cat_selected').value=='250')
		{
			 header_img='http://www.white-desert.com/shop/skin1/images/KitList_WOMEN_still-1.jpg';
		}
		
		cur_req_url='load_kit_pinfo.php'+params;
			
		//remove flash with pinfo div
		if(click_track==1){
		
			
			$('flashcontent').set('html', '');
			var head_img  = new Element('img', {'src':header_img,'id':'head_img','width':'801','height':'358'});
			var product_info  = new Element('div', {'id':'product_info'});
			head_img.inject('header', 'top');
			product_info.inject('head_img', 'after');
			var product_name  = new Element('h1', {'id':'product_name'});
			product_name.inject('product_info', 'top');

			var product_description  = new Element('p', {'id':'product_description'});
			product_description.inject('product_name', 'after');
			
			var product_image_loader  = new Element('div', {'id':'product_image_loader'});
			product_image_loader.inject('product_description', 'after');
			
			var product_image  = new Element('img', {'id':'product_image'});
			product_image.inject('product_image_loader', 'top');
			
			var ajax_loader_img  = new Element('div', {'id':'ajax_loader_img'});
			ajax_loader_img.inject('product_image_loader', 'after');
			
			var product_price  = new Element('div', {'id':'product_price'});
			product_price.inject('ajax_loader_img', 'after');
			
			var lbl_product_wd_price  = new Element('label', {'for':'product_wd_price','id':'lbl_product_wd_price','html':'White Desert Price'});
			lbl_product_wd_price.inject('product_price', 'top');
			
			var product_wd_price  = new Element('div', {'id':'product_wd_price'});
			product_wd_price.inject('lbl_product_wd_price', 'after');
			
			var product_details  = new Element('div', {'id':'product_details'});
			product_details.inject('product_price', 'after');

			var product_color_label  = new Element('div', {'id':'product_color_label'});
			product_color_label.inject('product_details', 'top');
			
			var product_color_chooser  = new Element('div', {'id':'product_color_chooser'});
			product_color_chooser.inject('product_color_label', 'after');
       		
	   }
	   //remove flash with pinfo div
		//AJAX LOADER
		$('txt_image_enlarge').set('html','');
		$('product_dimage_link').set('html', '');
		$('product_dimage_link').inject('product_dimage_link_con', 'top');
		$('product_image_loader').set('html','' );
		
		$('product_name').set('html', '');
	  // shift POPup links to save
    $('pmore_info').inject('pmore_info_con', 'bottom');
    
		$('product_description').set('html', '');
		
		$('top_buy_link').set('html','');
		//$('product_color_chooser').set('html','');
		$('product_color_label').set('html','');
		$('product_wd_price').set('html', '');
		$('product_color_label').set('html','');
		$('lbl_product_wd_price').set('html','');

		$('ajax_loader_img').set('html', loader_img);
		var top_buy_id='top_'+target_pid[1];
		//restore pcolor divs to pcolor_container start
					if(set_click==1){
						set_click=0;
						$('pcolor_container').set('html','');
		
						for( pcolor_index = 0; pcolor_index < max_last_color_div; pcolor_index++ )
						{
							pcolor_index_prev='pcolor'+pcolor_index;
							color_pos1=pcolor_index+1;
							pcolor_dv_id1='pcolor'+color_pos1;
							hidden_col_opt_id1='pcolor'+color_pos1+'_optid';
							$(hidden_col_opt_id1).set('value','0');
							
							if(color_pos1>1)
								$(pcolor_dv_id1).inject(pcolor_index_prev, 'after');
							else
								$(pcolor_dv_id1).inject('pcolor_container', 'top');
							
							
							$(pcolor_dv_id1).set('class','');
							$(pcolor_dv_id1).set('style','');
						}
					$('product_color_chooser').set('html','');	
					}
		//restore pcolor divs to pcolor_container end
    	//AJAX LOADER
		$(target).set('send', {
   			     method: 'post',url: cur_req_url,
     		     onSuccess: function(responseText, responseXML) {
					 //response_str=responseText.split("|");
					obj=JSON.decode(responseText);
					$('ajax_loader_img').set('html', '');
					//alert(obj.color_code);
					if(obj.pimg){
						
						if(obj.details_pimg){
						  
							$('product_dimage_link').inject('product_image_loader', 'top');
							$('product_dimage_link').set('html','<img id=product_image src="'+obj.pimg+'" />');
							$('product_dimage_link').set('href',obj.details_pimg);
					    $('product_dimage_link').store('title', obj.pname);
							$('txt_image_enlarge').set('html','&lt;&nbsp;Click image to enlarge');
							}
						
						else
						{
							
              $('txt_image_enlarge').set('html','');
							$('product_dimage_link').set('html', '');
							$('product_dimage_link').inject('product_dimage_link_con', 'top');
							$('product_image_loader').set('html', '<img id=product_image src="'+obj.pimg+'" />');
						}
						
            //POPUP
						if(obj.pfulldescr){
						  	$('product_description').set('html', obj.pdescr);
              	$('pmore_info_con').set('style', 'visibility:true;');
                $('pmore_info').set('style', 'visibility:true;float:right;');
                $('pmore_info').inject('product_color_label', 'after');
                $('pmore_info_link').set('href','popup_pinfo.php?pid='+obj.ppid);
                $('pmore_info_link').set('style', 'visibility:true;float:right;color: #336699;');
            }
            else
            {
                 $('product_description').set('html', obj.pdescr);
                 $('pmore_info_con').set('style', 'visibility:hidden;');
                 $('pmore_info').set('style', 'visibility:hidden;');
            }
            
						
            if(obj.technical_name!="")
            $('product_name').set('html', obj.technical_name);
            else
            $('product_name').set('html', obj.pname);
            
						$('lbl_product_wd_price').set('html','White Desert Price');
					
						if(obj.product_type=="offline"){
							$('product_wd_price').set('html', 'N/A');
							$('top_buy_link').set('html','<img src="'+img_not_for_sell+'" />');
							$('top_buy_link').set('style','cursor:text');
						}
						else{
							$$('div.order_top').setProperty('id', top_buy_id);
							$('top_buy_link').set('html','<img src="'+img_buy_now+'" />');
							$('top_buy_link').set('style','cursor:pointer');
							$('product_wd_price').set('html', obj.list_price);
						}
					
						$$('div.top_nav_container').inject('product_wd_price', 'after');
						$$('div.order_top').inject('top_nav_container', 'top');
						
						if(get_id<total_pro_count){
							$$('div.top_next_item').setProperty('id', pro_list[get_id]);
							$('view_next_item').set('html','NEXT&nbsp;&gt;');
						}
						else{
							$('view_next_item').set('html', '');
							$('view_prev_item').focus(); 
						}
						if(get_id>1){
							$$('div.top_prev_item').setProperty('id', pro_list[get_id-1]);
							$$('div.top_prev_item').setProperty('style','width:62px');
							$('view_prev_item').set('html', '&lt;&nbsp;PREVIOUS');
						}
						$$('div.top_nav_container').inject('product_wd_price', 'after');
	
						//dynamic color div generation
						
						if(obj.color_code)
						{
							for( intIndex = 0; intIndex < max_last_color_div; intIndex++ )
							{
								//div_gen_str=div_gen_str+"<div class='product_color' style='background-color:"+ obj.color_code[intIndex]+"'></div>";
								color_pos=intIndex+1;
								pcolor_dv_id='pcolor'+color_pos;
								pcolor_dv_prev_id='pcolor'+intIndex;
								//alert(pcolor_dv_id);
								$(pcolor_dv_id).set('class','product_color');
								
								if(obj.color_code[intIndex]){
								
								//find color optin id start
										if(obj.optionid)
										{ 
										hidden_col_opt_id='';
											for( intIndex2 = 0; intIndex2 <obj.optionid.length; intIndex2++ )
											{
											
												
												if (obj.color_opt_name[intIndex2]==obj.color_name[intIndex]&&obj.color_opt_name[intIndex2]!=''&&obj.color_name[intIndex]!=''){
												
													//alert(obj.color_name[intIndex]);
													if(obj.optionid[intIndex2]){
													//pointer=pointer+1;
													hidden_col_opt_id='pcolor'+color_pos+'_optid';
													//$(hidden_col_opt_id).set('value',obj.color_opt_name[intIndex2]);
													strp=obj.optionid[intIndex2]+'pid'+target_pid[1];
													//alert(obj.color_name[intIndex]);
													if(hidden_col_opt_id)
													$(hidden_col_opt_id).set('value',strp);
										
													}
													
												}
												
											}
										}
									//find color option id end
					      
                if(obj.color_code[intIndex]=='#FFFFFF'){ 
								  //$(pcolor_dv_id).set('style','background-color:'+obj.color_code[intIndex]);
								  $(pcolor_dv_id).set('style','border:1px solid #cccccc;width:18px;cursor:pointer;');
									}
								else{
                
								  $(pcolor_dv_id).set('style','cursor:pointer;background-color:'+obj.color_code[intIndex]);
								}
                  
								}
								else
									$(pcolor_dv_id).set('style','');
								
								if(color_pos>1)
									$(pcolor_dv_id).inject(pcolor_dv_prev_id,'after');
								else
									$(pcolor_dv_id).inject('product_color_chooser','top');
								set_click=1;
							
							}
							
						}
						else if(obj.color_code=='')
						{
							chk_no_class=1;
							$('product_color_chooser').set('html','');
							$('product_color_label').set('html','');
							
						}
						else
						{
							
						}
						if(chk_no_class==0){
							//$('product_color_chooser').set('html',div_gen_str);
							$('product_color_label').set('html','AVAILABLE COLOURS');
							div_gen_str='';
							
						}
						chk_no_class=0;
						//$('pcolor_container').set('html','');
							
					}

               	 },
          		 onFailure: function(headerName, value) {
			 	 }
		 });
		 $(target).send(); 
    
		///////
		sc.toTop(); 
		});
});
//////top banner next item/////
//P///
$$('div.top_prev_item').each(function(el){
	
	el.addEvent('click', function(){ 
	  //var s=this.getNext();
	  //alert(s.get('id'));
	 var found=0;
	 var next_item_id='';
	 var cur_pro_id=this.get('id');
		get_id=get_id-1;
		 $('view_next_item').set('html','');
		 $('view_prev_item').set('html','');
		
		target=pro_list[get_id];
		click_track=click_track+1;
		target_pid=target.split("product_");
	
		///FUNCTION TO LOAD PINFO/////
		params='?pid='+target_pid[1];
		
		if($('cat_selected').value=='249')
		{
   	   		header_img='http://www.white-desert.com/shop/skin1/images/KitList_MEN_still-1.jpg';
		}
		else if ($('cat_selected').value=='250')
		{
			 header_img='http://www.white-desert.com/shop/skin1/images/KitList_WOMEN_still-1.jpg';
		}
		
		cur_req_url='load_kit_pinfo.php'+params;
			
		//remove flash with pinfo div
		if(click_track==1){
		
			//$('test').set('html', '');
			$('flashcontent').set('html', '');
			//$('flashcontent').setStyle('bgcolor', '#FFFFFF');
			var head_img  = new Element('img', {'src':header_img,'id':'head_img','width':'801','height':'358'});
			var product_info  = new Element('div', {'id':'product_info'});
			head_img.inject('header', 'top');
			product_info.inject('head_img', 'after');
			var product_name  = new Element('h1', {'id':'product_name'});
			product_name.inject('product_info', 'top');

			var product_description  = new Element('p', {'id':'product_description'});
			product_description.inject('product_name', 'after');
			
			var product_image_loader  = new Element('div', {'id':'product_image_loader'});
			product_image_loader.inject('product_description', 'after');
			
			var product_image  = new Element('img', {'id':'product_image'});
			product_image.inject('product_image_loader', 'top');
			
			var ajax_loader_img  = new Element('div', {'id':'ajax_loader_img'});
			ajax_loader_img.inject('product_image_loader', 'after');
			
			var product_price  = new Element('div', {'id':'product_price'});
			product_price.inject('ajax_loader_img', 'after');
			
			var lbl_product_wd_price  = new Element('label', {'for':'product_wd_price','id':'lbl_product_wd_price','html':'White Desert Price'});
			lbl_product_wd_price.inject('product_price', 'top');
			
			var product_wd_price  = new Element('div', {'id':'product_wd_price'});
			product_wd_price.inject('lbl_product_wd_price', 'after');
			
			var product_details  = new Element('div', {'id':'product_details'});
			product_details.inject('product_price', 'after');

			var product_color_label  = new Element('div', {'id':'product_color_label'});
			product_color_label.inject('product_details', 'top');
			
			var product_color_chooser  = new Element('div', {'id':'product_color_chooser'});
			product_color_chooser.inject('product_color_label', 'after');
       		
	   }
	   //remove flash with pinfo div
		//AJAX LOADER
		$('txt_image_enlarge').set('html','');
		$('product_dimage_link').set('html', '');
		$('product_dimage_link').inject('product_dimage_link_con', 'top');
		
		$('product_image_loader').set('html','' );
		
		$('product_name').set('html', '');
		// shift POPup links to save
    $('pmore_info').inject('pmore_info_con', 'bottom');
    
		$('product_description').set('html', '');
		
		$('top_buy_link').set('html','');
		//$('product_color_chooser').set('html','');
		$('product_color_label').set('html','');
		$('product_wd_price').set('html', '');
		$('product_color_label').set('html','');
		$('lbl_product_wd_price').set('html','');

		$('ajax_loader_img').set('html', loader_img);
		var top_buy_id='top_'+target_pid[1];
		//restore pcolor divs to pcolor_container start
					if(set_click==1){
						set_click=0;
						$('pcolor_container').set('html','');
		
						for( pcolor_index = 0; pcolor_index < max_last_color_div; pcolor_index++ )
						{
							pcolor_index_prev='pcolor'+pcolor_index;
							color_pos1=pcolor_index+1;
							pcolor_dv_id1='pcolor'+color_pos1;
							hidden_col_opt_id1='pcolor'+color_pos1+'_optid';
							$(hidden_col_opt_id1).set('value','0');
							if(color_pos1>1)
								$(pcolor_dv_id1).inject(pcolor_index_prev, 'after');
							else
								$(pcolor_dv_id1).inject('pcolor_container', 'top');
							
							
							$(pcolor_dv_id1).set('class','');
							$(pcolor_dv_id1).set('style','');
						}
					$('product_color_chooser').set('html','');	
					}
		//restore pcolor divs to pcolor_container end
    	//AJAX LOADER
		$(target).set('send', {
   			     method: 'post',url: cur_req_url,
     		     onSuccess: function(responseText, responseXML) {
					 //response_str=responseText.split("|");
					obj=JSON.decode(responseText);
					$('ajax_loader_img').set('html', '');
					//alert(obj.color_code);
					if(obj.pimg){
						if(obj.details_pimg){
							
							$('product_dimage_link').inject('product_image_loader', 'top');
							$('product_dimage_link').set('html','<img id=product_image src="'+obj.pimg+'" />');
							$('product_dimage_link').set('href',obj.details_pimg);
							$('product_dimage_link').store('title', obj.pname);
							$('txt_image_enlarge').set('html','&lt;&nbsp;Click image to enlarge');
						}
						
						else
						{
							$('txt_image_enlarge').set('html','');
							$('product_dimage_link').set('html', '');
							$('product_dimage_link').inject('product_dimage_link_con', 'top');
							$('product_image_loader').set('html', '<img id=product_image src="'+obj.pimg+'" />');
						}
						
            //POPUP
						if(obj.pfulldescr){
						  	$('product_description').set('html', obj.pdescr);
              	$('pmore_info_con').set('style', 'visibility:true;');
                $('pmore_info').set('style', 'visibility:true;float:right;');
                $('pmore_info').inject('product_color_label', 'after');
                $('pmore_info_link').set('href','popup_pinfo.php?pid='+obj.ppid);
                $('pmore_info_link').set('style', 'visibility:true;float:right;color: #336699;');
            }
            else
            {
                 $('product_description').set('html', obj.pdescr);
                 $('pmore_info_con').set('style', 'visibility:hidden;');
                 $('pmore_info').set('style', 'visibility:hidden;');
            }
						
            if(obj.technical_name!="")
            $('product_name').set('html', obj.technical_name);
            else
            $('product_name').set('html', obj.pname);
            
						$('lbl_product_wd_price').set('html','White Desert Price');
					
						if(obj.product_type=="offline"){
							$('product_wd_price').set('html', 'N/A');
							$('top_buy_link').set('html','<img src="'+img_not_for_sell+'" />');
							$('top_buy_link').set('style','cursor:text');
						}
						else{
							$$('div.order_top').setProperty('id', top_buy_id);
							$('top_buy_link').set('html','<img src="'+img_buy_now+'" />');
							$('top_buy_link').set('style','cursor:pointer');
							$('product_wd_price').set('html', obj.list_price);
						}
   						$$('div.top_nav_container').inject('product_wd_price', 'after');
						$$('div.order_top').inject('top_nav_container', 'top');
						
						
						if(get_id<total_pro_count && get_id!=total_pro_count){
						    $('view_next_item').set('html','NEXT&nbsp;&gt;');
							$$('div.top_next_item').setProperty('id', pro_list[get_id+1]);
						}
						if(get_id>1){
							$$('div.top_prev_item').setProperty('id', pro_list[get_id]);
						    $$('div.top_prev_item').setProperty('style','width:62px');
							$('view_prev_item').set('html', '&lt;&nbsp;PREVIOUS');
						}
						else{
							$('view_prev_item').set('html','');
							$$('div.top_prev_item').setProperty('style','width:0px');
							$('view_next_item').focus(); 
						}
	
						//dynamic color div generation
							
						if(obj.color_code)
						{
							for( intIndex = 0; intIndex < max_last_color_div; intIndex++ )
							{
								//div_gen_str=div_gen_str+"<div class='product_color' style='background-color:"+ obj.color_code[intIndex]+"'></div>";
								color_pos=intIndex+1;
								pcolor_dv_id='pcolor'+color_pos;
								pcolor_dv_prev_id='pcolor'+intIndex;
								//alert(pcolor_dv_id);
								$(pcolor_dv_id).set('class','product_color');
								
								if(obj.color_code[intIndex]){
								//find color optin id start
										if(obj.optionid)
										{ 
                     
                      hidden_col_opt_id='';
											for( intIndex2 = 0; intIndex2 <obj.optionid.length; intIndex2++ )
											{
										    //alert(obj.obj.color_name[intIndex]);													
												if (obj.color_opt_name[intIndex2]==obj.color_name[intIndex]&&obj.color_opt_name[intIndex2]!=''&&obj.color_name[intIndex]!=''){
												
													//alert(obj.color_name[intIndex]);
													if(obj.optionid[intIndex2]){
													//pointer=pointer+1;
													hidden_col_opt_id='pcolor'+color_pos+'_optid';
													//$(hidden_col_opt_id).set('value',obj.color_opt_name[intIndex2]);
													strp=obj.optionid[intIndex2]+'pid'+target_pid[1];
													//alert(strp);
													if(hidden_col_opt_id)
													$(hidden_col_opt_id).set('value',strp);
										
													}
													
												}
												
											}
										}
									//find color option id end
						      if(obj.color_code[intIndex]=='#FFFFFF'){ 
    							    //$(pcolor_dv_id).set('style','background-color:'+obj.color_code[intIndex]);
    								  $(pcolor_dv_id).set('style','border:1px solid #cccccc;cursor:pointer;width:18px;');
    								  
								  }
								  else{
								    $(pcolor_dv_id).set('style','cursor:pointer;background-color:'+obj.color_code[intIndex]);
								  }  
								}
								else
									$(pcolor_dv_id).set('style','');
								
								if(color_pos>1)
									$(pcolor_dv_id).inject(pcolor_dv_prev_id,'after');
								else
									$(pcolor_dv_id).inject('product_color_chooser','top');
								set_click=1;
							
							}
							
						}
						else if(obj.color_code=='')
						{
							chk_no_class=1;
							$('product_color_chooser').set('html','');
							$('product_color_label').set('html','');
							
						}
						else
						{
						}
						if(chk_no_class==0){
							//$('product_color_chooser').set('html',div_gen_str);
							$('product_color_label').set('html','AVAILABLE COLOURS');
							div_gen_str='';
							
						}
						chk_no_class=0;
						//dynamic color div generation
										
					}
					
               	 },
          		 onFailure: function(headerName, value) {
			 	 }
		 });
		 $(target).send(); 
    
		///////
		sc.toTop(); 
		});
});

// color event start
$$('div.product_color').each(function(e1){
	
	//e1.addEvent('click', function(){ 
	e1.addEvent('mouseover', function(){
	color_opt_id=this.get('id').split("pcolor");
	send_reg=this.get('id');
 
	target_hidden_col_opt='pcolor'+color_opt_id[1]+'_optid';
  
	hidden_opt_id3=$(target_hidden_col_opt).value.split("pid");
	
	if(hidden_opt_id3[0]!=0){
	
	// send req for color images start
		opt_reg_url='load_option_color_img.php'
		params='?pid='+hidden_opt_id3[1]+'&poptionid='+hidden_opt_id3[0];
		
		$('product_dimage_link').inject('product_dimage_link_con', 'top');
		$('product_dimage_link').set('html','<img id=loader src="'+'http://www.white-desert.com/shop/skin1/images/ajax-loader.gif'+'" />');
		$('product_image_loader').set('html', '');
		$('product_dimage_link').inject('product_image_loader', 'top');
		//$('product_dimage_link').set('html', '');
		
	

		$(send_reg).set('send', {
   			     method: 'post',url: opt_reg_url+params,
     		     onSuccess: function(responseText, responseXML) {
				      obj=JSON.decode(responseText);
				 
				 if(obj.details_pimg){
												
							$('product_dimage_link').set('html','<img id=product_image src="'+obj.pimg+'" />');
							$('product_dimage_link').set('href',obj.details_pimg);
							$('product_dimage_link').store('title', obj.pname);
							$('txt_image_enlarge').set('html','&lt;&nbsp;Click image to enlarge');
							
						}
						else
						{
							$('product_dimage_link').set('html', '');
							$('product_dimage_link').inject('product_dimage_link_con', 'top');
							$('product_image_loader').set('html', '<img id=product_image src="'+obj.pimg+'" />');
							$('txt_image_enlarge').set('html','');
							
						}
						
				//
				 },
          		 onFailure: function(headerName, value) {
			 	
				}
		 });
		 $(send_reg).send(); 

	// send req for color images end
	}
	

});
});
// color event end							  



//top banner PAUL and SHAHED

});
