/* Gjokica Zafirovski SVGOPEN 2009 PAPER
 * "Rich Media Advertising with SVG and JavaScript"
 * gzafirovski@google.com */

/** expand and colapse functions **/

function expandCreative() {
	var clipPaths = document.getElementsByTagName("clipPath");
	for (var i = 0; i < clipPaths.length; i++) {
		var myRects = clipPaths[i].getElementsByTagName("rect");
	    myRects[0].setAttribute("height","270");
	    if(clipPaths[i].id =="clipPath7796"){
		  myRects[0].setAttribute("height","300");
	    }
	}
}

function collapseCreative() {
	var clipPaths = document.getElementsByTagName("clipPath");
	for (var i = 0; i < clipPaths.length; i++) {
		var myRects = clipPaths[i].getElementsByTagName("rect");
	    myRects[0].setAttribute("height","90");
		if(clipPaths[i].id =="clipPath7812"){
		  myRects[0].setAttribute("height","26");
	    }
	}
}

/** initialize behaviour on SVG document load **/

function init(){
  /** animate the clouds **/
  var clouds = document.getElementById("clouds");
  var clouds2 = document.getElementById("clouds2");
  var moveClouds = 0;
  var moveCloudsTwo = 200;
  var moveCloudsOneInterval = window.setInterval(function () {
	clouds.setAttribute("transform", "scale(3.5) translate("+ moveClouds +",-40)");
	clouds2.setAttribute("transform", "scale(3.5) translate(-"+ moveCloudsTwo +",-40)");
    moveClouds++;
    moveCloudsTwo--;
    if(moveCloudsTwo == 0){
	  moveClouds = 0;
      moveCloudsTwo = 200; 
	  //clearInterval(moveCloudsOneInterval);
	  clouds.setAttribute("transform", "scale(3.5) translate(0,-40)");
	  clouds2.setAttribute("transform", "scale(3.5) translate(-200,-40)");
	}
  },30);
}

