function loadWidget(game_id, cellSize, divName){
	var parentDiv = document.getElementById(divName);
	var iframe = document.createElement('iframe');
	iframe.style.width = (parseInt(parentDiv.style.width) + 40) + "px";
	iframe.style.height = parentDiv.style.height;
	iframe.setAttribute('src', 'http://hashtagart.com/games/dynamicwidget/' + game_id + "/" + cellSize + window.location.search);
	iframe.setAttribute('scrolling', 'no');
	iframe.setAttribute('frameBorder', 0);
	iframe.setAttribute("allowTransparency","true");
        iframe.setAttribute("name", "hashtagartiframe");
	
	iframe.style.position = "relative";
	iframe.style.left = "-20px";
	
	var hiddenImg = document.createElement('div');
	
	var currentDate = new Date();
	var day = currentDate.getDate();
	var month = currentDate.getMonth();
	var hours = currentDate.getHours();

	hiddenImg.innerHTML = '<img style="display: none;" src="' + 'http://hashtagart.com/games/getLatestSnapshot/small/' + game_id + "?rand=" + day + month + hours + '" />';
	 
	parentDiv.appendChild(iframe);
	parentDiv.appendChild(hiddenImg);
}

function loadWidgetRoute(route_id, cellSize, divName, ftocall){
	var parentDiv = document.getElementById(divName);
	var iframe = document.createElement('iframe');
	iframe.style.width = (parseInt(parentDiv.style.width) + 40) + "px";
	iframe.style.height = parentDiv.style.height;
	
	/* set the default value for function */
	ftocall = typeof(ftocall) != 'undefined' ? ftocall : "dynamicwidgetroute";
	iframe.setAttribute('src', 'http://hashtagart.com/games/'+ ftocall +'/' + route_id + "/" + cellSize + window.location.search);
	iframe.setAttribute('scrolling', 'no');
	iframe.setAttribute('frameBorder', 0);
	iframe.setAttribute("allowTransparency","true");
	
	iframe.style.position = "relative";
	iframe.style.left = "-20px";
	
	var hiddenImg = document.createElement('div');
		
	var currentDate = new Date();
	var day = currentDate.getDate();
	var month = currentDate.getMonth();
	var hours = currentDate.getHours();
	
	hiddenImg.innerHTML = '<img style="display: none;" src="' + 'http://hashtagart.com/games/getLatestSnapshotRoute/small/' + route_id + "?rand=" + day + month + hours + '" />';

	parentDiv.appendChild(iframe);
	parentDiv.appendChild(hiddenImg);
}

function loadWidgetRoute2(route_id, cellSize, divName){
	var parentDiv = document.getElementById(divName);
	var iframe = document.createElement('iframe');
	iframe.style.width = parseInt(parentDiv.style.width) + "px";
	iframe.style.height = parentDiv.style.height;
        
	iframe.setAttribute('src', 'http://hashtagart.com/games/dynamicwidgetroute2/' + route_id + "/" + cellSize + window.location.search);
	iframe.setAttribute('scrolling', 'no');
	iframe.setAttribute('frameBorder', 0);
	iframe.setAttribute("allowTransparency", "true");

	var hiddenImg = document.createElement('div');

	var currentDate = new Date();
	var day = currentDate.getDate();
	var month = currentDate.getMonth();
	var hours = currentDate.getHours();

	hiddenImg.innerHTML = '<img style="display: none;" src="' + 'http://hashtagart.com/games/getLatestSnapshotRoute/small/' + route_id + "?rand=" + day + month + hours + '" />';

	parentDiv.appendChild(iframe);
	parentDiv.appendChild(hiddenImg);
}


function loadImageFadeWidgetRoute(route_id, cellSize, divName) {
	loadWidgetRoute(route_id, cellSize, divName, 'imagefadewidgetroute');
	
}

function loadWidget2(game_id, cellSize, divName){
	var parentDiv = document.getElementById(divName);
	var iframe = document.createElement('iframe');
	iframe.style.width = parseInt(parentDiv.style.width) + "px";
	iframe.style.height = parentDiv.style.height;
	iframe.setAttribute('src', 'http://hashtagart.com/games/dynamicwidget2/' + game_id + "/" + cellSize + window.location.search);
	iframe.setAttribute('scrolling', 'no');
	iframe.setAttribute('frameBorder', 0);
	iframe.setAttribute("allowTransparency","true");
        iframe.setAttribute("name", "hashtagartiframe");

	var hiddenImg = document.createElement('div');

	var currentDate = new Date();
	var day = currentDate.getDate();
	var month = currentDate.getMonth();
	var hours = currentDate.getHours();

	hiddenImg.innerHTML = '<img style="display: none;" src="' + 'http://hashtagart.com/games/getLatestSnapshot/small/' + game_id + "?rand=" + day + month + hours + '" />';

	parentDiv.appendChild(iframe);
	parentDiv.appendChild(hiddenImg);
}
