
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//tiki begin
							  
/*				  function tikiAwb(idContent,idStart,idStop){
                         
                    statusAwb=setTimeout("tikiAwb('"+idContent+"',"+idStart+","+idStop+")",10000);
                    $.ajax({
                         url: "main.php",
                         type: "POST",
                         data: {cmd : "tiki",str : idStart,stp : idStop},
                         dataType: "text",
                         error:function (XMLHttpRequest, textStatus, errorThrown) {
                              alert("Save failed!"+textStatus);
                         } ,
                         success: function(restil){
                                   //alert(restil);
                                             resti=$.parseJSON(restil);
						 	 if(resti.success){
                                   
                                   for(i=0;i<resti.data.length;i++){
								   $("#"+idContent+" .tikih"+(i+1)).html("");
								   		//var tikish=resti.data[i][0].replace(" ","");
										var tikish=resti.data[i][0];
								   		
										//alert(idContent);
										//$("#"+idContent+" .tikia1").html("asdfghjkl");
										var conts=document.createElement("DIV");
                                        
										var orderText=document.createElement("span");
                                        //orderText.style.font-size="8px";
                                                  orderText.innerHTML="<b>#"+resti.data[i][1]+" </b>";
										conts.appendChild(orderText);
										

										var cityText=document.createElement("span");
                                        //cityText.style.font-size="8px";
                                        cityText.innerHTML=resti.data[i][2];
										conts.appendChild(cityText);
										
										var links1=document.createElement("a");
                                        
                                        links1.href="http://www.tikijne.co.id/index.php?mib=tracking.detail&awb="+tikish+"&awb_list="+tikish;				links1.target="_blank";
										
									
										var awbText=document.createElement("span");
                                        //awbText.style.font-size="8px";
										//awbText.style.margin-left="5px";
                                        awbText.innerHTML="<b>&nbsp;&nbsp;"+tikish+" </b>";
										links1.appendChild(awbText);
										conts.appendChild(links1);
										$("#"+idContent+" .tikih"+(i+1)).append(conts);
                                                  //alert(idContent);
								   }
							 
							 }else{
                                   alert(resti.message);
                              }
                          }
                    	});	   
						 
					}
						*/	  
							  
							  
							  
							  //tiki end*/
							  
							  
               //helper.parent = $('').hide().appendTo('body');"rand"
               var statusRandom= new Array()
			   var int = 0;
               statusRandom["contrand3"]=null;
               function randPro(idCont,numRow,codeCate,delay,command,page,pages){
				   
				   //alert(command);alert(numRow);alert(codeCate);alert(page);alert(pages);
				   //alert(command);
               		//alert(command+' '+numRow+' '+codeCate+' '+page+' '+pages);	
//					if(delay>0){
//                    statusRandom[idCont]=setTimeout("randPro('"+idCont+"',"+numRow+","+codeCate+","+delay+",'"+command+"')",delay);
//                    }
//                    else{
//                    clearTimeout(statusRandom[idCont]);     
//                    }
                    //statusRandom=this.statusRandom;
                    $.ajax({
                         url: "main.php",
                         type: "POST",
                         data: {cmd : command,row : numRow,cate:codeCate,page : page, pages:pages},
                         dataType: "text",
                         error:function (XMLHttpRequest, textStatus, errorThrown) {
                              alert("Save failed!"+textStatus);
                         } ,
                         success: function(resl){//alert('test');
							 int++;
                              res=$.parseJSON(resl);
                              //alert(res.success);
							 
                              if(res.success){
								   //alert(res.data.length);
								  //alert(res.tes);
                                   for(i=0;i<res.data.length;i++){
                                         //objPro = res.data[i];
                                         //alert(res.data[i]);
                                        
                                         $("#"+idCont+" .cellrand"+(i+1)).html("");
                                        //var subcont=document.createElement("DIV");
                                        //subcont.id="subcontent";
                                        //subcont.style.backgroundColor='#FFF00F';
                                        
                                        var cont=document.createElement("DIV");
                                        cont.style.border="0px solid #000000";
										$(cont).height(210);
                                        $(cont).width(180);
										cont.id="subcontent";
                                        cont.style.position="relative";
                                        cont.title=res.data[i].description;
                                       $(cont).tooltip();
                                        var cont1=document.createElement("DIV");
                                        var cont2=document.createElement("DIV");
                                        var cont3=document.createElement("DIV");
                                        var link1=document.createElement("a");
                                        
                                        link1.href="index.php?g=product&s=detail&id="+res.data[i].product_id;
                                        var imglink=document.createElement("IMG");
                                        //**********************************************************************
                                        imglink.src="images/pro_thumb/"+res.data[i].image;
										imglink.style.border="1px solid #CCCCCC";
										
                                        
                                        link1.appendChild(imglink);
                                        $(imglink).css({width:150,height:113});
                                        cont1.style.border="0px solid #FF0000";
										cont1.style.paddingRight="10px";
										//cont1.style.paddingLeft="7px";
										cont1.appendChild(link1);
                                        var link2=document.createElement("a");
                                        //$(link2).css("font-size","11px");
                                        
                                        //link2.style="font-size:10px";
                                        link2.href="index.php?g=product&s=detail&id="+res.data[i].product_id;
										var detail="index.php?g=product&s=detail&id="+res.data[i].product_id;
                                        link2.innerHTML=res.data[i].product_name;
                                        cont2.style.border="0px solid #00FF00";										
                                        cont2.appendChild(link2);
                                        cont2.style.textAlign="center"
                                        cont2.style.height="30px"
                                        cont2.style.overflowY = 'hidden';
										cont2.style.width = '180px';
										//cont2.style.marginLeft = '210px';
                                        //alert($(cont2).height());
                                        //$(link2).css("vertical-align","center");
                                        
                                        var btn=document.createElement("img");
                                        
                                        btn.src="images/orde.png";
                                        btn.value="order";
                                        btn.style.cursor="pointer";
                                        btn.style.styleFloat = "right";
                                        btn.style.position="absolute";
                                        btn.style.right="10px";
                                        btn.style.bottom="20px";
                                        btn.Obj=res.data[i];
                                        
                                        btn.onclick=function(){
                                             
                                             ObjVal=this.Obj;
                                             var cont=this.parentNode
                                             var s= $("<div></div>");
                                             s.width($(cont).width());    
                                             s.height($(cont).height());
                                             s.css({
                                                  left:$(cont).offset().left,
                                                  top:$(cont).offset().top
                                             });
                                             
                                             s.css({ position: "absolute",
                                                  background: "#999999",
                                                  border: "3px solid #000000",
                                                  opacity: 0.7,
                                                  zIndex: 1000000,
                                                  
                                                  top: $(cont).offset().top,
                                                  left: $(cont).offset().left
                                             });
                                             $("body").append(s);
                                             
                                             s.animate({
                                                   width:$("#menu-root").width(),
                                                   height:$("#menu-root").height(),
                                                   left:$("#menu-root").offset().left,
                                                   top:$("#menu-root").offset().top
                                                  }, {duration:1000,complete:function(){
                                                       order.add(ObjVal);
                                                       order.rander($("#randerorder"));
                                                       $(this).fadeOut("slow",function(){
                                                            if( !document.getElementById("mascot")){
                                                                 if(!$( "#menu" ).is( ":visible" )){
                                                                      $( "#menu" ).slideToggle("slow",function(){
                                                                           $( "#baloon2" ).css("top","-"+($("#menu").height()+$("#baloon2").height())+"px");
                                                                           $( "#baloon2" ).fadeIn("slow");
                                                                      });
                                                                 }
                                                            }
                                                            else{
                                                            $( "#baloon" ).fadeOut("slow", function(){
                                                                 $( "#gatotkaca" ).fadeOut("slow", function(){
                                                                      if(!$( "#menu" ).is( ":visible" )){
                                                                           $( "#menu" ).slideToggle("slow",function(){
//                                                                                alert("-"+($("#menu").height()+150)+"px");
                                                                                $( "#baloon2" ).css("top","-"+($("#menu").height()+$("#baloon2").height())+"px");
                                                                                $( "#baloon2" ).fadeIn("slow");
                                                                           });
                                                                      }
                                                                 });
                                                            });
                                                            }
                                                       });     
                                                  }} );
                                             //alert(this.statusRandom);
                                             clearTimeout(statusRandom[idCont]);
                                             
                                        }

//										var link3=document.createElement("a");
//                                        
//                                        link3.href="index.php?g=product&s=detail&id="+res.data[i].product_id;
										
										var btn2=document.createElement("img");
                                        
                                        btn2.src="images/deta.png";
                                        btn2.value="detail";
                                        btn2.style.cursor="pointer";
                                        btn2.style.styleFloat = "left";
                                        btn2.style.position="absolute";
                                        btn2.style.left="2px";
                                        btn2.style.bottom="20px";
                                        btn2.Obj=res.data[i];
										btn2.id="?g=product&s=detail&id="+res.data[i].product_id;;
										btn2.onclick=function(){//alert(this.id);
										window.location=this.id;}
//										link3.appendChild(btn2);
										
                                        
										var priceText=document.createElement("span");
                                        //priceText.style.float="center";
                                        if (res.tes > 0){priceText.innerHTML='S $'+res.data[i].gold_price+'.00';}
										else{
											priceText.innerHTML='S $'+res.data[i].market_price+'.00';}
                                        cont3.style.border="0px solid #0000FF";
                                        cont3.appendChild(priceText);
                                        //cont3.style.valign="middle";
                                        cont3.style.textAlign="center";
										cont3.style.height="1px";
										cont3.style.width = '180px';
                                        cont.appendChild(btn);
										cont.appendChild(btn2);
                                       	cont.appendChild(cont1);
                                        cont.appendChild(cont2);
                                        cont.appendChild(cont3);
                                        //subcont.appendChild(cont);
                                        $("#"+idCont+" .cellrand"+(i+1)).append(cont);
                                     	
										
										//check(int);   
                                   }
                                   $("#"+idCont).hide();
                                   $("#"+idCont).fadeIn("slow");
                              }
                              else{
                                   alert(res.message);
                              }
                         //alert(msg.success);
                         }
                    });

//                    alert(idCont);
                    
               }
/*function check(i)
{
	if(document.getElementById('subcontent'+i).innerHTML==''){
	alert('asd');}
}*/
