function MakeScriptTag(object) {
	var returnString = ''
		+ '<script src="http://chasikov.net.ru/sistem/clock/js/emgen.js"></script>'
		+ '<script type="text/javascript" language="JavaScript">'
		+ MakeScript( object )
		+ '</script>';
	
	return returnString;
}

function MakeScript(object) {
	var returnString = ''
		+ 'obj = new Object;'
		+ 'obj.clockfile = "' + object.clockfile + '";'
		+ 'obj.Poyas = "' + object.Poyas + '";'
		+ 'obj.width = ' + object.width + ';'
		+ 'obj.height = ' + object.height + ';'
		+ _getObjProp(object)
		+ 'obj.wmode = "transparent";'
		+ 'showClock(obj);';
	
	return returnString;
}

function _getObjProp(obj){
	var str="";
	for( prop in obj ) {
		if( 'clockfile' == prop 
			|| 'Poyas' == prop
			|| 'width' == prop
			|| 'height' == prop
			|| 'wmode' == prop
			|| 'type' == prop
		) continue;
		str += 'obj.' + prop + ' = ' + '"' + obj[prop] + '";';
	}
	return str;
}

function getEmbedTag(obj){
	var str = '<embed src="http://chasikov.net.ru/sistem/clock/002/'
		+ obj.clockfile;
	str += "?";
		
	for( prop in obj ) {
		if( 'clockfile' == prop 
			|| 'width' == prop
			|| 'height' == prop
			|| 'wmode' == prop
			|| 'type' == prop
		) continue;
		str += ( prop + "=" + _escape(obj[prop]) + "&" );
	}
	str += '" ';
	str += ' width="' + obj.width + '"';
	str += ' height="' + obj.height + '"';
	str += ' wmode="transparent"';
	str += ' type="application/x-shockwave-flash">';
	
	return str;
}

function _escape(str){
	if(str == undefined) return '';
	str = str.replace(/ /g, '+');
	str = str.replace(/%/g, '%25');
	str = str.replace(/\?/, '%3F');
	str = str.replace(/&/, '%26');
	return str;
}