function getObject(objectId) {
     if(document.getElementById && document.getElementById(objectId)) {
    // W3C DOM
       return document.getElementById(objectId);
     }
     else if (document.all && document.all(objectId)) {
    // MSIE 4 DOM
       return document.all(objectId);
     }
     else if (document.layers && document.layers[objectId]) {
    // NN 4 DOM.. note: this won't find nested layers
       return document.layers[objectId];
     }
     else {
       return false;
    }
}

var responsecont;
var xmlHttp;
var contents;
var rank_type;
var page;
function CreateXMLHttpRequest(){
   // Initialize Mozilla XMLHttpRequest object
   if (window.XMLHttpRequest){
       xmlHttp = new XMLHttpRequest();
   }
   // Initialize for IE/Windows ActiveX version
   else if (window.ActiveXObject) {
       try{
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
       }
       catch (e){
            try{
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e){contents = "Loading rquest content fail, Please try it again latter...";}
       }
   }
}

function getcontents(type){
   var url = 'includes/modules/' + rank_type + '_products.php?page='+page;	
   var loadstatustext="<div>Loading request content, please wait...</div>";
   CreateXMLHttpRequest();  
   getObject(rank_type + '_conent').innerHTML = loadstatustext;
   xmlHttp.onreadystatechange = processRequestChange;
   xmlHttp.open("GET", url, true);
   xmlHttp.send(null); 
}

function processRequestChange(){
   // only if xmlHttp shows "complete"
   if (xmlHttp.readyState == 4){
      // only http 200 to process
      if (window.location.href.indexOf("http")==-1 || xmlHttp.status == 200){         
         contents= xmlHttp.responseText;
         //inject centent to tab-pane
        // alert(contents);
            showncontents(rank_type,contents);
      }
   }
}

function showncontents(type,contents){

    responsecont = getObject(rank_type + '_conent');
   
    responsecont.innerHTML = contents;

}


function IndexProducts(type,page_num){
			page = page_num;
		    rank_type = type;	
            getcontents(rank_type);             			
}

	       
function swapImage(img1,img2)  
{  
	var   img1,img2;  
	img1.src="images/"+img2;	
}