function openImageUploadWindow(UID){
	window.open('extra/image_open.php?UID='+UID, 'uploadwin', 'width=305, height=250, top=200, left=200');
}

function openHelpWindow(id){
	var help = '';
	switch(id) {
		case 0:
			help = 'layout';
			break;
		case 1:
			help = 'image';
			break;
		case 2:
			help = 'text';
			break;
		case 3:
			help = 'order';
			break;
		case 4:
			help = 'gift';
			break;
	}
	var f = window.open('help/help_'+help + '.html', 'helpwin', 'width=305, height=250, top=200, left=200, scrollbars=yes');
	f.focus();
}

function fileWasUploaded(fn){
/*	var mov = findMovie('mainmovie');
	if (mov != null) {
		mov.SetVariable('imageNameToLoad', fn);
	}*/
	setMovieVar(builderMovieName, 'imageNameToLoad', fn, 'gateway.swf');
	//prompt("Your uploaded image name:", fn);
}

function submitUploadForm(){
	alert("Your file will be uploaded to our server!\nPlease don't click the 'Upload image' button again\nwhile the data is uploading!");
	setMovieVar(loaderMovieName, loaderMovieSetVarName, loaderMovieSetVarValue, 'gateway.swf');
/*	var mov = findMovie('loadingmovie');
	if (mov != null) {
		mov.SetVariable('run', 1);
		mov.GotoFrame(1);
		mov.Play();
	}*/
	return false;
}

/*
function findMovie(movieName){

	var byID = document.getElementById(movieName);
	if (byID != null) {
		var byIDType = new String(byID).toUpperCase();
		var idxO = byIDType.indexOf('OBJECT');
		var idxC = byIDType.indexOf('COLLECTION');
		if ((idxO >= 0) && (idxC < 0)) {
			//alert('Found by getID');
			return byID;
		}
	}
	
	
	var byDoc = document[movieName];
	if (byDoc != null) {
		var byDocType = new String(byDoc).toUpperCase();
		var idxO = byDocType.indexOf('OBJECT');
		var idxC = byDocType.indexOf('COLLECTION');
		if ((idxO >= 0) && (idxC < 0)) {
			//alert('Found by document');
			return byDoc;
		}
	}

	var byWDoc = window.document[movieName];
	if (byWDoc != null) {
		var byWDocType = new String(byWDoc).toUpperCase();
		var idxO = byWDocType.indexOf('OBJECT');
		var idxC = byWDocType.indexOf('COLLECTION');
		if ((idxO >= 0) && (idxC < 0)) {
			//alert('Found by window.document');
			return byWDoc;
		}
	}
	

	
	return null;
}

*/

var ua        = navigator.userAgent.toLowerCase(); 
var is_pc_ie  = ( (ua.indexOf('msie') != -1 ) && ( ua.indexOf('win') != -1 ) && ( ua.indexOf('opera') == -1 ) && ( ua.indexOf('webtv') == -1 ) );

function setMovieVar(movieid, varName, varValue, movieSource){
	//is_pc_ie = false;
	if(is_pc_ie){
		//alert("is_pc_ie");
		document[movieid].SetVariable(varName,varValue);
	}else{
		//alert("NON ie");
		var divcontainer = "flash_setvariables_"+movieid;
		if(!document.getElementById(divcontainer)){
			var divholder = document.createElement("div");
			divholder.id = divcontainer;
			document.body.appendChild(divholder);
		}
		document.getElementById(divcontainer).innerHTML = "";
		var divinfo = "<embed src='" + movieSource + "' FlashVars='sendToConnectionName="+movieid+"&variableName="+escape(varName)+"&variableValue="+escape(varValue)+"' width='0' height='0' type='application/x-shockwave-flash'></embed>";
		document.getElementById(divcontainer).innerHTML = divinfo;
	}
}