//Infinity Dimensions Javascript v0.2
//Script by http://www.infinity-dimensions.com/

//Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-52672-1']);
_gaq.push(['_setDomainName', 'infinity-dimensions.com']);
_gaq.push(['_trackPageview']);
 (function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();



//UA Check YouTube Resize
function YoutubeChk(YtUrl,YtWd,YtAs){//URL,横幅,0=16:9/1=4:3
var yvw=yvh=0;
var ua=navigator.userAgent;
if(ua.indexOf("iPhone")>-1){
yvw=280;if(YtAs==1){yvh=235;}else{yvh=170;}
document.write('<object width="'+yvw+'" height="'+yvh+'"><param name="movie" value="http://www.youtube.com/v/'+YtUrl+'&hl=ja_JP"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+YtUrl+'&hl=ja_JP&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+yvw+'" height="'+yvh+'"></embed></object>');
}else if(ua.indexOf("Android")>-1){
yvw=280;if(YtAs==1){yvh=235;}else{yvh=170;}
document.write('<a href="http://www.youtube.com/watch?v='+YtUrl+'"><img alt="Youtube" src="http://img.youtube.com/vi/'+YtUrl+'/0.jpg" width="'+yvw+'" height="'+yvh+'"></a>');
}else{
yvw=YtWd;if(YtAs==1){yvh=YtWd*0.75+25;}else{yvh=YtWd*0.5625+25;}
document.write('<object width="'+yvw+'" height="'+yvh+'"><param name="movie" value="http://www.youtube.com/v/'+YtUrl+'&hl=ja_JP"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+YtUrl+'&hl=ja_JP&fs=1&rel=0&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+yvw+'" height="'+yvh+'"></embed></object>');
}
}

//UA Check IMG Resize
function imgRsz(imgSiz){
var ua=navigator.userAgent;
if(ua.indexOf("iPhone")>-1 || ua.indexOf("Android")>-1){
var imgObj=document.getElementsByTagName('img');
var imgCnt=imgObj.length;
for(var i=0;i<imgCnt;i++){
	var imgWid=imgObj[i].getAttribute("width");
	if(imgWid>imgSiz){
		imgObj[i].setAttribute("width",imgSiz);
		var imgHet=imgObj[i].getAttribute("height")*imgSiz/imgWid;
		imgObj[i].setAttribute("height",imgHet);
	}
}
}
}

//jQuery
$(function(){
var ua=navigator.userAgent;
if(ua.indexOf("iPhone")>-1 || ua.indexOf("Android")>-1){
//ID ImgResize
var imgSiz=280;
var imgObj=document.getElementsByTagName('img');
var imgCnt=imgObj.length;
for(var i=0;i<imgCnt;i++){
	var imgWid=imgObj[i].getAttribute("width");
	if(imgWid>imgSiz){
		imgObj[i].setAttribute("width",imgSiz);
		var imgHet=imgObj[i].getAttribute("height")*imgSiz/imgWid;
		imgObj[i].setAttribute("height",imgHet);
	}
}
//ID YoutubeView
var ytWidth=$(".YoutubeView object").attr("width");
var ytHeight=$(".YoutubeView object").attr("height");
if(ytWidth/(ytHeight-25)>1.4){ytHeight=118;}else{ytHeight=210;}
ytWidth=280;
$(".YoutubeView object").attr("width",ytWidth);
$(".YoutubeView object").attr("height",ytHeight);
$(".YoutubeView object embed").attr("width",ytWidth);
$(".YoutubeView object embed").attr("height",ytHeight);
//alert(ytWidth+ytHeight);
}
//ID Scroll
$(".scroll").click(function(){
$(this).blur();
$('html,body').animate({scrollTop:0},'slow');
return false;
});
//ieKill
if(ua.indexOf("MSIE")>-1){
ieKill();
}
});

