$(document).ready(function() { 
	$('.hasCheckfield input[type=text], .hasCheckfield input[type=password], .hasCheckfield input[type=checkbox], .hasCheckfield select, .hasCheckfield textarea').each(function(){
		var hasSpan = 0;
		if(!$(this).hasClass('noCheck')){
			$(this).parent().find('span.checkfield').each(function(){
				hasSpan++;
			});
			if(!hasSpan){
				$('<span class="checkfield"></span>').insertAfter(this);
			}
		}
	});
	//$('<span class="checkfield"></span>').insertAfter('.hasCheckfield input[type=text], .hasCheckfield input[type=password], .hasCheckfield select, .hasCheckfield textarea')
	$('.hasCheckfield input, .hasCheckfield select, .hasCheckfield textarea').blur(function(){ checkfield(this); }).change(function(){ checkfield(this); });
});

function friendly_url_encode(tekst){
	tekst = tekst.toLowerCase();
	tekst = tekst.replace(/%/g, '');
	tekst = tekst.replace(/ &amp; /g, '-en-');
	tekst = tekst.replace(/&amp;/g, '-en-');
	tekst = tekst.replace(/ & /g, '-en-');
	tekst = tekst.replace(/&/g, '-en-');
	tekst = tekst.replace(/ \/ /g, '\\');
	tekst = tekst.replace(/\//g, '\\');
	tekst = tekst.replace(/ /g, '-');
	return(tekst);
}

function submitZoek(f)
{
	f.action = f.action + friendly_url_encode($('#search').val());
}

var flashDebug = false;
var load = true;
function hideLoading(){
//document.getElementById("loadingMsg").style.display = "none";
}


function loadWidget(id,lang){

	var flashDebug = true;
	var url = document.location.href;
		
    if (url.indexOf('share=true') != -1) {
      // user came via share toolkit. Send them to widget page on the main site
      document.location.href="http://www.wimbledon.org/en_GB/widgets/index.html?promo=widgetshare";
    }
	var load = true;
	var flashvars = {};
	//flashvars.base = "http://www.rolandgarros.com";
	flashvars.config = "widget_config.xml";
	flashvars.lang = 'en';
	flashvars.debug = flashDebug;
	flashvars.start = "rg";
	//flashvars.eventsDebug = "/en_FR/xml/man/widget/widget_config.xml";
	
	var params = {};
	params.base = ".";
	var attributes = {};
	swfobject.embedSWF("http://grandslamwidget.edgesuite.net/widget.swf", "widgetBox", "300", "254", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
	
}


function old_loadWidget(id,lang){
//document.getElementById("loadingMsg").style.display = "block";
var flashvars = {};
flashvars.base = "http://2010.australianopen.com";
flashvars.config = "/en_AU/xml/man/widget/widget_config.xml";
flashvars.lang = lang;
flashvars.debug = flashDebug;
var params = {};
params.base = ".";
var attributes = {};
//swfobject.embedSWF("/aus/flash/widget.swf", "widgetContent2", "100%", "100%", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
if(!load){
var measureURL = "/en_AU/widget/language_switch_"+lang+".html";
//measureClick(measureURL);
}
load = false;
var widgetCode = "";
if (isIE){
widgetCode += '<object width="298" height="243" type="application/x-shockwave-flash" quality="high" id="W' + id + '">';
widgetCode += '<param value="http://widgets.clearspring.com/o/' + id + '/-/-/-" name="movie"/>';
}
else{
widgetCode += '<object width="298" height="243" type="application/x-shockwave-flash" id="W' + id + '" data="http://widgets.clearspring.com/o/' + id + '/-/-/-">';
}
widgetCode += '<param name="wmode" value="transparent"/>';
widgetCode += '<param name="allowScriptAccess" value="always"/>';
widgetCode += '<param name="allowNetworking" value="all"/>';
widgetCode += '</object>';
widgetCode += '<script type="text/javascript" src= "http://widgets.clearspring.com/o/' + id + '/-/-/-/widget.js"></scr'+'ipt>';
document.getElementById("widgetBox").innerHTML = widgetCode;
setTimeout("hideLoading()", 2000);
}


