// JavaScript Document
//对联广告代码:两边一样,需要jquery
//调用方法例子:
//$(document).ready(function(){
//couplet_ad_start('images/ad/jpjd02.gif','images/ad/jpjd01.jpg','#',139,30,113);
//});
var couplet_ad_start= function(pic1,pic2,linkto,top,pic_width,pic2_width){
	couplet_ad(pic1,pic2,linkto,top,pic_width,pic2_width);
	$(window).resize(function(){$('.couplet_ad_r').css('left',$(window).width()-30+'px')});
}
var  couplet_ad=function(pic1,pic2,linkto,top,pic_width,pic2_width){
	var output='<div class="couplet_ad_l"><a href="'+linkto+'"><img  src="'+pic1+'" /></a></div>';
	output +='<div class="couplet_ad_r"><a href="'+linkto+'"><img  src="'+pic1+'" /></a></div>';
	$('body').append(output);
	win_w=$(window).width();
	left = win_w-pic_width;
	$('.couplet_ad_l').css({'top':top+'px','position': 'absolute','cursor':'pointer'});
	$('.couplet_ad_r').css({'top':top+'px','left':left+"px",'position': 'absolute','cursor':'pointer'});
	$('.couplet_ad_l img').bind('mouseover',function(){change_pic(pic2,pic2_width)});
	$('.couplet_ad_r img').bind('mouseover',function(){change_pic(pic2,pic2_width)});
	$('.couplet_ad_l img').bind('mouseout',function(){change_pic(pic1,pic_width)});
	$('.couplet_ad_r img').bind('mouseout',function(){change_pic(pic1,pic_width)});
}
var change_pic=function(img,img_width){
	var left=$(window).width()-img_width;
	$('.couplet_ad_l a img').attr('src',img);
	$('.couplet_ad_r a img').attr('src',img);
	$('.couplet_ad_l a img').css('width',img_width+'px');
	$('.couplet_ad_r a img').css('width',img_width+'px');
	$('.couplet_ad_r').css('left',left+'px');
}
