function headerLoad() {
	document.open();
	document.write('<meta name="format-detection" content="telephone=no">');
	document.write('<meta name="keywords" content="Processing, Processing.js">');
	document.write('<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">');
	
	document.write('<script type="text/javascript">');
	
	document.write("var _gaq = _gaq || [];");
	document.write("_gaq.push(['_setAccount', 'UA-24108729-1']);");
	document.write("_gaq.push(['_trackPageview']);");
	
	document.write("(function() {");
	document.write("var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;");
	document.write("ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';");
	document.write("var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);");
	document.write("})();");
	
	document.write("</script>");
				   
	document.close();
}

function headMenu() {
	document.open();
	document.write('<h1><a class="a1" href="http://basicwerk.com">Basic Werk</a>  |  <a class="a1" href="http://basicwerk.com/works.html">Works</a>  |  <a class="a1" href="http://basicwerk.com/blog/">Blog</a>  |  <a class="a1" href="http://basicwerk.com/contact.html">Contact</a></h1>');
	document.close();
}

function putIcon(url,png,title) {
	var str = '<a href="' + url + '" alt="' + title + '"><img class="icon" src="' + png + '" title="' + title + '"></a>';
	return str;	
}

function contentsBasicDesign() {
	document.open();
	document.write(putIcon("./processing/typography2.html","./processing/foto/SN_P5_Typography2_201161912505.png","Typography (Rotate)"));
	document.write(putIcon("./processing/rotateRect.html","./processing/foto/SN_P5_RotateRect_2011619112043.png","Rotate Rect"));
	document.write(putIcon("./processing/ajiro.html","./processing/foto/SN_P5_ajiro_2011611133924.png","Ajiro Asa No Ha"));		
	document.write(putIcon("./processing/sayagata.html","./processing/foto/SN_P5_sayagata_201163185212.png","Sayagata (Japanese Classic Pattern)"));	
	document.write(putIcon("./processing/talkingArc.html","./processing/foto/SN_P5_arc_201164115655.png","Talking Arc"));	
	document.write(putIcon("./processing/falling2.html","./processing/foto/SN_P5_Falling2_201162111555.png","Falling2"));	
	document.write(putIcon("./processing/cylinders.html","./processing/foto/SN_P5_Cylinder_201161161617.png","Cylinders"));	
	document.write(putIcon("./processing/brokenAndReversed.html","./processing/foto/SN_P5_brokenAndReversed2011530225134.png","Broken And Reversed"));	
	document.write(putIcon("./processing/scaleLesson1.html","./processing/foto/SN_P5_scaleLesson1_2011511231319.png","Scale Lesson 1"));	
	document.write(putIcon("./processing/linesMakeACircle.html","./processing/foto/SN_P5_LinesMakeACircle_2011530172947.png","Lines Make A Circle"));	
	document.write(putIcon("./processing/sinWave.html","./processing/foto/SN_P5_sinWave_201153016026.png","Sin Wave"));	
	document.write(putIcon("./processing/dotMoving.html","./processing/foto/SN_P5_dotMoving_2011530155542.png","dotMoving"));	
	document.write(putIcon("./processing/ox.html","./processing/foto/SN_P5_ox_201153015401.png","OX game"));	
	document.write(putIcon("./processing/circle122.html","./processing/foto/SN_P5_Circle122_2011530153410.png","Circle122"));	
	document.write(putIcon("./processing/line81.html","./processing/foto/SN_P5_Line81_2011530152838.png","Line81"));	
	document.write(putIcon("./processing/line79.html","./processing/foto/SN_P5_Line792011530152338.png","Line79"));	
	document.write(putIcon("./processing/memos.html","./processing/foto/SN_P5_memos_2011523172121.png","memos"));	
	document.write(putIcon("./processing/moveRect7.html","./processing/foto/SN_P5_moveRect7_2011526112615.png","moveRect7"));	
	document.write(putIcon("./processing/drawCircle.html","./processing/foto/SN_P5_drawCircle201152922711.png","drawCircle"));	
	document.write(putIcon("./processing/bezier.html","./processing/foto/SN_P5_Bezier2011530124053.png","Bezier"));	
	document.write(putIcon("./processing/2dSphere.html","./processing/foto/SN_P5_2D_Sphere201153016535.png","2D Sphere"));
	document.close();
}

function contentsSoundOfMusic() {
	document.open();
	document.write(putIcon("./sounds/tc.html","./sounds/data/tc/tc_cover_100.png","Transparency Composition"));	
	document.close();
}	

function drawCanvas(myTitle, pjs, w, h, comment) {
	var myP = myPrev(pjs);
	var myN = myNext(pjs);
	document.open();
	document.write('<h2>');
	document.write('<a class="a1" href="http://basicwerk.com/works.html">Works</a>::' + myTitle);
	document.write('</h2>');
	document.write('<center>');
	if (pjs == "talkingArc.pjs") {
		document.write('<canvas class="c1" width="' + w + '" height="' + h + '"></canvas>');
	} else {
		document.write('<canvas class="c1" datasrc="./' + pjs + '" width="' + w + '" height="' + h + '"></canvas>');
	}
	document.write('<br />');
	if (myP != "") {
		document.write('<a id="prev" href="./' + myP + '" ><img id="prevImg" src="../image/prev.gif" title="Prev" ></a>');
	}
	if (myN != "") {
		document.write('<a id="next" href="./' + myN + '" ><img id="nextImg" src="../image/next.gif" title="Next" ></a>');
	}	
	document.write('</center>');
	document.write('<p><br /></p>');
	if (comment != "") {
		document.write('<p>' + comment + '</p>');
		document.write('<p><br /></p>');
	}
	document.write('<p>Source code: <a href="./' + pjs + '" target="_blank">' + pjs + '</a></p>');
	document.close();
}

function myPrev(pjs) {
	var p;
	if (pjs == "2dSphere.pjs")				{ p = "bezier.html"; }
	if (pjs == "bezier.pjs")				{ p = "drawCircle.html"; }
	if (pjs == "drawCircle.pjs")			{ p = "moveRect7.html"; }
	if (pjs == "moveRect7.pjs")				{ p = "memos.html"; }
	if (pjs == "memos.pjs")					{ p = "line79.html"; }
	if (pjs == "line79.pjs")				{ p = "line81.html"; }
	if (pjs == "line81.pjs")				{ p = "circle122.html"; }
	if (pjs == "circle122.pjs")				{ p = "ox.html"; }
	if (pjs == "ox.pjs")					{ p = "dotMoving.html"; }
	if (pjs == "dotMoving.pjs")				{ p = "sinWave.html"; }
	if (pjs == "sinWave.pjs")				{ p = "linesMakeACircle.html"; }
	if (pjs == "linesMakeACircle.pjs")		{ p = "scaleLesson1.html"; }
	if (pjs == "scaleLesson1.pjs")			{ p = "brokenAndReversed.html"; }
	if (pjs == "brokenAndReversed.pjs")		{ p = "cylinders.html"; }
	if (pjs == "cylinders.pjs")				{ p = "falling2.html"; }
	if (pjs == "falling2.pjs")				{ p = "talkingArc.html"; }
	if (pjs == "talkingArc.pjs")			{ p = "sayagata.html"; }
	if (pjs == "sayagata.pjs")				{ p = "ajiro.html"; }
	if (pjs == "ajiro.pjs")					{ p = "rotateRect.html"; }
	if (pjs == "rotateRect.pjs")			{ p = "typography2.html"; }
	if (pjs == "typography2.pjs")			{ p = ""; }
	return p;
}

function myNext(pjs) {
	var n;
	if (pjs == "2dSphere.pjs")				{ n = ""; }
	if (pjs == "bezier.pjs")				{ n = "2dSphere.html"; }
	if (pjs == "drawCircle.pjs")			{ n = "bezier.html"; }
	if (pjs == "moveRect7.pjs")				{ n = "drawCircle.html"; }
	if (pjs == "memos.pjs")					{ n = "moveRect7.html"; }
	if (pjs == "line79.pjs")				{ n = "memos.html"; }
	if (pjs == "line81.pjs")				{ n = "line79.html"; }
	if (pjs == "circle122.pjs")				{ n = "line81.html"; }
	if (pjs == "ox.pjs")					{ n = "circle122.html"; }
	if (pjs == "dotMoving.pjs")				{ n = "ox.html"; }
	if (pjs == "sinWave.pjs")				{ n = "dotMoving.html"; }
	if (pjs == "linesMakeACircle.pjs")		{ n = "sinWave.html"; }
	if (pjs == "scaleLesson1.pjs")			{ n = "linesMakeACircle.html"; }
	if (pjs == "brokenAndReversed.pjs")		{ n = "scaleLesson1.html"; }
	if (pjs == "cylinders.pjs")				{ n = "brokenAndReversed.html"; }
	if (pjs == "falling2.pjs")				{ n = "cylinders.html"; }
	if (pjs == "talkingArc.pjs")			{ n = "falling2.html"; }
	if (pjs == "sayagata.pjs")				{ n = "talkingArc.html"; }
	if (pjs == "ajiro.pjs")					{ n = "sayagata.html"; }
	if (pjs == "rotateRect.pjs")			{ n = "ajiro.html"; }
	if (pjs == "typography2.pjs")			{ n = "rotateRect.html"; }
	return n;
}


function builtP5Pjs() {
	document.open();	
	document.write('<p>Built with <a class="a1" href="http://processing.org" title="Processing.org" target="_blank">Processing</a> and <a class="a1" href="http://processingjs.org/" title="Processingjs.org" target="_blank">Processing.js</a></p>');
	document.close();
}

function copyRight() {
	document.open();
	document.write('<address><p class="copyright">&copy; 2008-2011 Basic Werk</p></address>');
	document.close();
}


$(document).ready(function() {
	$("#accHeaderBasicDesign").hover(function(){
					   $(this).css("cursor","pointer"); 
	},function(){
					   $(this).css("cursor","default"); 
	});
	$("#accContentsBasicDesign").hide();
	$("#accHeaderBasicDesign").click(function(){
					   $(this).next().toggle("slow");

							  if ($("#accImgBasicDesign").hasClass("Current")) {
								$("#accImgBasicDesign").attr("src",$("#accImgBasicDesign").attr("src").replace("minus.gif","plus.gif"));
								$("#accImgBasicDesign").removeClass("Current");
							  } else {
								$("#accImgBasicDesign").attr("src",$("#accImgBasicDesign").attr("src").replace("plus.gif","minus.gif"));
								$("#accImgBasicDesign").addClass("Current");
							  }						  
	});
				  
    $("#accHeaderSoundOfMusic").hover(function(){
				       $(this).css("cursor","pointer"); 
	},function(){
					   $(this).css("cursor","default"); 
	});
	$("#accContentsSoundOfMusic").hide();
    $("#accHeaderSoundOfMusic").click(function(){
						$(this).next().toggle("slow");
						
						if ($("#accImgSoundOfMusic").hasClass("Current")) {
						  $("#accImgSoundOfMusic").attr("src",$("#accImgSoundOfMusic").attr("src").replace("minus.gif","plus.gif"));
						  $("#accImgSoundOfMusic").removeClass("Current");
						} else {
						  $("#accImgSoundOfMusic").attr("src",$("#accImgSoundOfMusic").attr("src").replace("plus.gif","minus.gif"));
						  $("#accImgSoundOfMusic").addClass("Current");
						}						  
	});
				  
});
