$(document).ready(function(){
	codeGenerator();
	$("#select1").change(function(){
		codeGenerator(null, false);
	});
	$("#select2").change(function(){
		codeGenerator(null, false);
	});

});
function codeGenerator(where, pre){
	
	te=frameGenerator();
	if(pre)
		return te;
	else{
		$("#textarea1").val(" ");
		$("#textarea1").val(te);
	}
}
function preview(){
	$("#pre").html(" ");
	$("#pre1").html(" ");
	if($("#select1").val()>3)
		$("#pre1").html(frameGenerator());
	else
		$("#pre").html(frameGenerator());
	
}
function getWidth(){
	res=100;
	var val=$("#select1").val();
	if(val==1)
		res=180;
	else
		if(val==2)
			res=320;
		else
			if(val==3)
				res=356;
			else
				res=770;
	return res;
}
function getHeight(){
	res=100;
	var val=$("#select1").val();
	if(val==1)
		res=620;
	else
		if(val==2)
			res=270;
		else
			if(val==3)
				res=300;
			else
				res=200;
	return res;
}

function frameGenerator(){
	var te="<iframe width=\""+getWidth()+"\" height=\""+getHeight()+"\" frameborder=\"0\" src=\""+$("#my_url").val()+"widget?size="+$("#select1").val()+"&b="+$("#select2").val()+"\">";
	te+="Przepraszamy, Twoja przeglądarka nie obsługuje ramek</iframe>";
return te;
}

function getAudioBaner(id, where, which){
if(parseInt(id)==null || parseInt(id)=="")
	id=1;
if(where==null)
	where="audiosync";
if(which==null)
	which=0;
var url = $("#my_url").val()+"widget?size="+id+"&b="+which;
		      if (typeof XMLHttpRequest == "undefined")
			    XMLHttpRequest = function() {
		          try { return new ActiveXObject("Msxml2.XMLHTTP.6.0");} catch(e) {}
	              try { return new ActiveXObject("Msxml2.XMLHTTP.3.0");} catch(e) {}
	              try { return new ActiveXObject("Msxml2.XMLHTTP");} catch(e) {}
	              try { return new ActiveXObject("Microsoft.XMLHTTP");} catch(e) {}
	              throw new Error( "This browser does not support XMLHttpRequest.");
	          };
		      var http = new XMLHttpRequest();
		      http.onreadystatechange = function () {
		        if(http.readyState == 4 && http.status == 200) {
		          document.getElementById(where).innerHTML = http.responseText;
		        }
		      };
		      http.open("GET", url);
		      http.send(null);
}


