	function convert_size(input, engine) { 
		
		var bytes = new Array('B', 'KB', 'MB','GB','TB'); 
		
		/*
		if (engine == "15")
			var bytes = new Array('B', 'KB', 'MB','GB','TB'); 
		else
			var bytes = new Array('MB','GB','TB');
		*/
		
		for(val in bytes) { 
			if(input > 1024) input = input / 1024; else break; 
		} 
		
		return Math.round(input*100)/100+" "+bytes[val]; 
	}


    function getlinkschecked(all) {
    	
    	var res;
    	
    	
        window.setTimeout(function() {

        		$.ajax({
                    type: "GET",
                    url: "http://www.filechaos.com/s",
                    data: "s=rs&f=" + encodeURIComponent(all[0])+"&fn=" + encodeURIComponent(all[1]),
                    
                    // or all.join('\n') is good also
                    success: function(result) {
                        res = eval('('+result+')');
                        
                        dataForLinks(res, "RS");
                        
                        } // senting links to database

                });
        },
        1);
    } //---
    
    function getlinkffchecked(allff) {
    	
    	var res;
    	
    	
        window.setTimeout(function() {

        		$.ajax({
                    type: "GET",
                    url: "http://www.filechaos.com/s",
                    data: "s=ff&f=" + encodeURIComponent(allff),
                    
                    // or all.join('\n') is good also
                    success: function(result) {
                        res = eval('('+result+')');
                        
                        dataForLinks(res, "FF");
                        
                        } // senting links to database

                });
        },
        1);
    } //---    
    
	function dataForLinks(links, serv) {
	
		var state = [];
		
		state[0] = "adead_link";
		state[1] = "alive_link";
		
		var fileState = 0;
		
		for (link in links)	{
			
			
			if (links[link] == 0) {
				
				$("."+serv+link).attr("target", "");
				//$("."+serv+link).attr("href", "#");
				
				fileState = 0;
				
			} else {
				
				fileState = 1;
				
				if (links[link] != 1) {
					$("."+serv+link).attr("title", "Is Online!! Size: " + convert_size(links[link]) + " See Details for found all the parts.");
					$("."+serv+link).text($("."+serv+link).text() + " (Is Online! Size: " + convert_size(links[link]) + ")");
				} else {
					$("."+serv+link).attr("title", "Is Online!! See Details for found all the parts.");
					$("."+serv+link).text($("."+serv+link).text() + " (Is Online!)");
				}
				
			}
			
			$("."+serv+link).addClass(state[fileState]);
			
			
			$("."+serv+link).removeClass(serv+link);			
		}
    	
    }

	if (numberofrslinks > 0) {
	    getlinkschecked(all);
	}
	
	
	if (numberoffflinks > 0) {
	    getlinkffchecked(allff);
	}	
	
