var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);

function show(banner){
	var  ret = '';
	switch (banner.type){
		case 'swf_expand':
			ret = template_swf(banner);
			ret ='<div id="ado_expand_holder_'+banner.name+'" style="width: '+ banner.width_c +'px; height: '+  banner.height_c  +'px;display:block;" ><div id="ado_expand_holder_in_'+banner.name+'" style="position: absolute; width: '+ banner.width +'px; height: '+ banner.height +'px;z-index:8">'+ret;
			ret = ret+'</div></div>';
			
		break;
		case 'swf':
			ret = template_swf(banner);		
		break;

		case 'image':
			ret = template_image(banner);	
		break;
		
		case 'pixel_transparent':
			ret = template_transparent_pixel(banner);	
		break;
	}
	
	document.getElementById(banner.div_holder).style.display = 'block';
	document.getElementById(banner.div_holder).innerHTML =ret;	
	if (banner.stiky){
		make_stiky (banner)	
	}
	if (banner.type=='swf_expand'){
		create_swf_fscomman(banner);
		if (banner.start_open){
			banner.expand_banner();
		}else{
			banner.close_banner();
		}	
	}
	
}


function show_ads_ado_b(banner){
	var  ret = '';
	switch (banner.type){
		case 'swf_expand':
			ret = template_swf(banner);
			ret ='<div id="ado_expand_holder_'+banner.name+'" style="width: '+ banner.width_c +'px; height: '+  banner.height_c  +'px;display:block;" ><div id="ado_expand_holder_in_'+banner.name+'" style="position: absolute; width: '+ banner.width +'px; height: '+ banner.height +'px;z-index:8">'+ret;
			ret = ret+'</div></div>';
			
		break;
		case 'swf':
			ret = template_swf(banner);		
		break;

		case 'image':
			ret = template_image(banner);	
		break;
		
		case 'pixel_transparent':
			ret = template_transparent_pixel(banner);	
		break;
		
		case 'cod':
			ret = template_cod(banner);	
		break;
	}
	
	document.getElementById(banner.div_holder).style.display = 'block';
	document.getElementById(banner.div_holder).innerHTML =ret;	
	if (banner.stiky){
		make_stiky (banner)	
	}
	if (banner.type=='swf_expand'){
		create_swf_fscomman(banner);
		if (banner.start_open){
			banner.expand_banner();
		}else{
			banner.close_banner();
		}	
	}
	
}

function insertAfter(a, b, referenceNode) {
  a.insertBefore(b, referenceNode.nextSibling);
}


function make_stiky(banner){
	if (!isIE6){
		document.getElementById(banner.div_holder).style.position= 'fixed';
	}else{
		document.getElementById(banner.div_holder).style.position= 'absolute';
	}
}

function template_transparent_pixel(banner){
	template = '<a target="_blank" href="'+banner.url+'"><img width="'+banner.width+'" height="'+banner.height+'" src="http://storage.icorp.ro/storage/sic/___/pxt.gif" border="0" alt="ado_banner" /></a>';	
	return template;
}

function template_cod(banner){
	template = banner.src;	
	return template;
}


function template_swf (banner){
	template = '<object id="'+banner.name+banner.unique+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ banner.width +'" height="'+ banner.height +'"><param name="allowScriptAccess" value="always" /><param name="movie" value="'+ banner.src +'?clickTag='+ escape(banner.url) +'" /> <param name="quality" value="high" /><param name="wmode" value="transparent" /><embed wmode="transparent" name="'+banner.name+banner.unique+'" src="'+ banner.src +'?clickTag='+ escape(banner.url) +'" quality="high" swLiveConnect="true" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ banner.width +'" height="'+ banner.height +'" allowScriptAccess="always"> </embed></object>';
	return template;
}
function template_image(banner){
	if (banner.url!='#'){
		template = '<a target="_blank" href="'+banner.url+'"><img src="'+banner.src+'" border="0" alt="ado_banner" /></a>';
	}	
	else{
		template = '<img src="'+banner.src+'" border="0" alt="ado_banner" />';
	} 
		
	return template;
}


function create_swf_fscomman (banner){
	if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
			document.write('<SCR'+'IPT LANGUAGE=VBScript> \n');
			document.write('on error resume next \n');
			document.write('Sub '+banner.name+banner.unique+'_FSCommand(ByVal command, ByVal args)\n');
			document.write('call '+banner.name+banner.unique+'_DoFSCommand(command, args)\n');
			document.write('end sub\n');
			document.write('</SCR'+'IPT> \n');
	}
	document.write('<scr'+'ipt type="text/javascript">');
	document.write('function '+banner.name+banner.unique+'_DoFSCommand(command, args) {if (command == \'open\') '+banner.name+'.expand_banner(); if (command==\'close\') '+banner.name+'.close_banner(); }');
	document.write('</scr'+'ipt>');
}

function create_swf_fscommand_custom (banner,custom_code){
	if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
			document.write('<SCR'+'IPT LANGUAGE=VBScript> \n');
			document.write('on error resume next \n');
			document.write('Sub '+banner.name+banner.unique+'_FSCommand(ByVal command, ByVal args)\n');
			document.write('call '+banner.name+banner.unique+'_DoFSCommand(command, args)\n');
			document.write('end sub\n');
			document.write('</SCR'+'IPT> \n');
	}
	document.write('<scr'+'ipt type="text/javascript">');
	document.write('function '+banner.name+banner.unique+'_DoFSCommand(command, args) {'+custom_code+'}');
	document.write('</scr'+'ipt>');
}

