var url=location.href,shareNmore,externalLinks,strFlashImg="",arrRefListWidth=[530,360,530,360,870,530,530,700,530,870,700,700,870,870,870],referenceTextBtn,refItem;
jQuery(document).ready(function(){
	/*DW NewsV2 START*/
	if(url.indexOf("&M=NewsV2")>-1) location.replace(url.replace("&M=NewsV2",""));
	/*DW NewsV2 SLUT*/
	var refList=jQuery(".refList");
	refList.css("width",arrRefListWidth[refList.find("ul li").length-1]+"px");
        //jQuery(document).pngFix();
	externalLinks=jQuery("a[href^=http]").click(function(){
		window.open(this.href,'','');
		return false;
	});
	jQuery(".newsList a").click(function(){
		location.href=this.href.replace("&M=NewsV2","");
		return false;
	});
	initCollectionSlide();
        showReferenceText();
});
function showReferenceText(){
  referenceTextBtn = jQuery(".refItem dl dt");
  refItem = referenceTextBtn.parent().parent();
  referenceTextBtn.css("cursor","pointer").click(function(){
    refItem.animate({
      width: (refItem.width()=="530"?"890":"530")+"px"
      }, 500);
  });
}
/*SlideBoxes START*/
var listBoxes,slidingBoxesNudge = 10,slidingBoxesAdjustment = 10,slidingBoxesIsScrolling = false;
function initCollectionSlide(){
  listBoxes = jQuery(".collection ul");
  var boxItems = listBoxes.children("li");
  listBoxes.css("width",boxItems.length*boxItems.outerWidth(true)+"px");
  if(boxItems.length>1){
    jQuery("#arrowLeft").click(function(){
      if(jQuery(this).css("cursor")!="pointer") return;
      var nudge=slidingBoxesNudge*-1;
      var left=listBoxes.position().left+listBoxes.parent().width()+slidingBoxesAdjustment;
      slideTheBoxes(nudge,left);
    }).css("display","block");
    jQuery("#arrowRight").click(function(){
      if(jQuery(this).css("cursor")!="pointer") return;
      var nudge=slidingBoxesNudge;
      var left=listBoxes.position().left+(listBoxes.parent().width()*-1)-slidingBoxesAdjustment;
      slideTheBoxes(nudge,left);
    }).css("display","block");
    handleArrows();
  }
}
function slideTheBoxes(nudge,left){
  if(slidingBoxesIsScrolling) return;
  toggleIsScrolling();
  listBoxes.animate({
    left: listBoxes.position().left+nudge+"px"
    }, 100,
    function(){listBoxes.animate({
      left: left+"px"
      }, 500,
      function(){toggleIsScrolling();handleArrows();}
      );
    }
  );
}
function handleArrows(){
  var left=listBoxes.position().left;
  if(left>=0){ jQuery("#arrowLeft").css("cursor","auto").animate({left:"-50px"},100); }
  else{ jQuery("#arrowLeft").css("cursor","pointer").animate({left:"-10px"},200); }
  if(left*-1>=listBoxes.width()-listBoxes.parent().width()-slidingBoxesAdjustment){ jQuery("#arrowRight").css("cursor","auto").animate({right:"-50px"},100); }
  else{ jQuery("#arrowRight").css("cursor","pointer").animate({right:"-10px"},200); }
}
function toggleIsScrolling(){
  slidingBoxesIsScrolling = !slidingBoxesIsScrolling;
}
/*SlideBoxes SLUT*/
function onPaperLoad(){return;}
function getURLParam(strParamName){
	return getParameterFromLink(strParamName, window.location.href);
}
function getParameterFromLink(strParamName, link){
	var strReturn = "";
	var strHref = link;
	if(strHref.indexOf("?") > -1){
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		for(var iParam = 0; iParam < aQueryString.length; iParam++){
			if(aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1){
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
			}
		}
	}
	return unescape(strReturn);
}
