I need to convert a php parser I wrote into a javascript parser. Sadly I don't know javascript syntax, so I would appreciate any help/assistance you guys can give. Here is the PHP parser:


Code:
//Gallery Class 
class Gallery {
	
var $title;
var $story;
var $url;
var $name;
var $tmp;
var $timeout;

var $url2;
var $name2;



	//cache function
	function request_cache($url, $dest_file, $timeout=03000, $name) {
		
		if(!file_exists($dest_file) || filemtime($dest_file) < (time()-$timeout)) {
			$data = file_get_contents($url);
			
			if ($data === false) return false;
				
			$tmpf = tempnam('/tmp', $name);
			$fp = fopen($tmpf, 'w');
			fwrite($fp, $data);
			fclose($fp);
     	  		rename($tmpf, $dest_file);
			
	  		return $data;
		}
  
		else{
			return file_get_contents($dest_file);
		}
	}



	//Parse function
	function parse_gallery($tmp){
		//load file
		
		$xml = simplexml_load_file($tmp);
		
		//parse file
		
		echo '<div id="wgallery" class="wimg">';
		foreach($xml->children() as $child){
				foreach($child->item as $grandchild){
				
						$link = $grandchild->link;
						$image = $grandchild->description;
					
						
						echo '<div class="wcell" align="center"><a href="'. $link. '">'. $image. '</a></div>';  
					
					
				}
					
		}
		echo '<div style="clear:both"></div>';
		echo '</div></div>';
	
		
	}
	
	function parse_story($tmp2){
	$xml = simplexml_load_file($tmp2);
	
	foreach($xml->children() as $child){
				foreach($child->item as $grandchild){
						$title = $grandchild->title;
						$link = $grandchild->link;
						$story = $grandchild->description;
					
						
						echo '<div class="wtitle"><a href="'. $link. '">'. $title. '</a></div>'; 
						echo '<div class="wstory">'. $story. '</div>';
					
					
				}
					
		}
		
	
	}

}

//exchange http://savannahnow.com/taxonomy/term/322/0/feed/
$newt2 = new Gallery;
$newt2->url = 'http://pipes.yahoo.com/pipes/pipe.run?_id=Bvl2ZZTQ2xGqu1pomLokhQ&_render=rss';
$newt2->name = 'exchange';
$newt2->tmp = '/tmp/yws_pipe3_'.md5($newt2->url);
$newt2->timeout = 03000;

$newt2->url2 = 'http://pipes.yahoo.com/pipes/pipe.run?_id=EKGxRZXQ2xGMpf0Qb9T_aA&_render=rss';
$newt2->name2 = 'estory';
$newt2->tmp2 ='/tmp/yws_pipe3_2'.md5($newt2->url2);

$newt2->request_cache($newt2->url, $newt2->tmp, $newt2->timeout, $newt2->name);
$newt2->request_cache($newt2->url2, $newt2->tmp2, $newt2->timeout, $newt2->name2);

//sports http://savannahnow.com/taxonomy/term/187/0/feed/
$newt = new Gallery;
$newt->url = 'http://pipes.yahoo.com/pipes/pipe.run?_id=qLRxEUXL2xGH7Ola00qv4w&_render=rss';
$newt->name = 'test';
$newt->tmp = '/tmp/yws_pipe3_'.md5($newt->url);
$newt->timeout = 03000;

$newt->url2 = 'http://pipes.yahoo.com/pipes/pipe.run?_id=UGgkCV_O2xGkbqOlq_l4KA&_render=rss';
$newt->name2 = 'story';
$newt->tmp2 ='/tmp/yws_pipe3_2'.md5($newt->url2);

$newt->request_cache($newt->url, $newt->tmp, $newt->timeout, $newt->name);
$newt->request_cache($newt->url2, $newt->tmp2, $newt->timeout, $newt->name2);
//$newt->parse_story($newt->tmp2);
//$newt->parse_gallery($newt->tmp);