jQuery(document).ready(function(){

// Main Banner of page
//getBillBoard();

// Right Small Banner 1
getRightBanner1();

// Right Small Banner 2
getRightBanner2();

// Landing Page settings, only for landing and promo page
getLanding();

function getBillBoard()
{
	$url = "http://"+top.location.host + "/ais/billboard.php";
	//alert($url);
	$.ajax({
		type: "GET",
		url: $url,
		dataType: "xml",
		success: function(xml) {
			jQuery(xml).find('ad').each(function(){				
	
				 // $id = jQuery(this).find('id').text();
				 // $title = jQuery(this).find('title').text();
				  
				  $img = jQuery(this).find('img').text();
				  $code = jQuery(this).find('code').text();
				  $url = 'http://'+top.location.host+'/go.php?vt='+$code;
				 
				  $imgString = '<a href = "'+$url+'"><img src = "'+$img+'" border = "0" /></a>';
				 //alert($imgString);
  				  jQuery("#billboard_ad").hide(1);
				  
				 
				  jQuery("#billboard_ad").removeAttr("style");
				  jQuery("#content_navi").css("margin-left","0");
				  jQuery("#content_navi").html($imgString);
				  //jQuery("#billboard_ad").html($imgString)
				  jQuery("#billboard_ad").show(1);
	
				 // $link = '<a href = "'+$url+'">'+$title+'</a>';
			  	 	
				}); // end each
		}
		

	});
		
}	

function getRightBanner1()
{
	$url = "http://"+top.location.host + "/ais/rightbanner1.php";
	$.ajax({
		type: "GET",
		url: $url,
		dataType: "xml",
		success: function(xml) {
			jQuery(xml).find('ad').each(function(){				
	
				 // $id = jQuery(this).find('id').text();
				 // $title = jQuery(this).find('title').text();
				  
				  $img = jQuery(this).find('img').text();
				  $code = jQuery(this).find('code').text();
				  $url = 'http://'+top.location.host+'/go.php?vt='+$code;
				 
				  $imgString = '<a href = "'+$url+'"><img src = "'+$img+'" border = "0" width="160" height="105" /></a>';
				 //alert($imgString);
  				  jQuery("#Promo1").hide(1);
				  jQuery("#Promo1").html($imgString);
				  jQuery("#Promo1").show(1);

				 // $link = '<a href = "'+$url+'">'+$title+'</a>';
			  	 	
				}); // end each
		}
		

	});
		
}	

function getRightBanner2()
{
	$url = "http://"+top.location.host + "/ais/rightbanner2.php";
	$.ajax({
		type: "GET",
		url: $url,
		dataType: "xml",
		success: function(xml) {
			jQuery(xml).find('ad').each(function(){				
	
				 // $id = jQuery(this).find('id').text();
				 // $title = jQuery(this).find('title').text();
				  
				  $img = jQuery(this).find('img').text();
				  $code = jQuery(this).find('code').text();
				  $url = 'http://'+top.location.host+'/go.php?vt='+$code;
				 
				  $imgString = '<a href = "'+$url+'"><img src = "'+$img+'" width="160" height="105" border = "0" vspace="10"  /></a>';
				 //alert($imgString);
  				  jQuery("#Promo2").hide(1);
				  jQuery("#Promo2").html($imgString);
				  jQuery("#Promo2").show(1);

				 // $link = '<a href = "'+$url+'">'+$title+'</a>';
			  	 	
				}); // end each
		}
		

	});
		
}	

function getLanding()
{
	$url = "http://"+top.location.host + "/ais/landing.php";
	$currentBoard = 0;
	$.ajax({
		type: "GET",
		url: $url,
		dataType: "xml",
		success: function(xml) {
			jQuery(xml).find('ad').each(function(){				

				 // $id = jQuery(this).find('id').text();
				 // $title = jQuery(this).find('title').text();
				  $currentBoard++;
				  $imgID = 'img'+$currentBoard;
				  $img = jQuery(this).find('img').text();
				  $code = jQuery(this).find('code').text();
				  $url = 'http://'+top.location.host+'/go.php?vt='+$code;
				  
				  $imgString = '<a href = "'+$url+'"><img id = "'+$imgID+'" src = "'+$img+'" border = "0" /></a>';
				  switch ($currentBoard)
				  {
					  case 1 :
					    $board = jQuery("#billboard1");
						//$imgID = jQuery("#img1");
					    break;
					  case 2 :
					    $board = jQuery("#billboard2");
						//$imgID = jQuery("#img2");
					    break;
				      case 3 :
					    $board = jQuery("#billboard3");
						//$imgID = jQuery("#img3");
					    break;
				  }
				  
				  
  				  $board.hide(1);
				  $board.html($imgString);
				 // $board.toggleClass('png');
				  //alert('hi');
				  if ($.browser.msie)
				  {
					  //$board.show(1);
					  $board.fadeIn(2000);
				  }
				  else
				  {
					  $board.fadeIn(2000);
				  }				  

				
				
				 // $link = '<a href = "'+$url+'">'+$title+'</a>';
			  	 	
				}); // end each
		}
		

	});
		
}

function addJavascript(jsname,pos) {

var th = document.getElementsByTagName(pos)[0];
var s = document.createElement('script');
s.setAttribute('type','text/javascript');
s.setAttribute('src',jsname);
th.appendChild(s);

} 

});