		
$(document).ready(function() {


//---------------------------

    $(window).load(function () {
		document.textecardprev.SetVariable("Place", $("#FEFplace").val());
		document.textecardprev.SetVariable("Head", $("#FEFhead").val());
		document.textecardprev.SetVariable("Body", $("#FEFbodytext").val());
		document.textecardprev.SetVariable("Expression", $("#FEFexpression").val());						
		document.textecardprev.SetVariable("Signature", $("#FEFsignature").val());								
//		document.textecardprev.TCallFrame("TypographyLoader", 6);
		document.textecardprev.TCallFrame("/",8);				
    });	

	$("#FEFplace").keyup( function() { 
		document.textecardprev.SetVariable("Place", $(this).val());
//		document.textecardprev.TCallFrame("TypographyLoader", 6);
		document.textecardprev.TCallFrame("/",8);		
	});
	$("#FEFhead").keyup( function() { 
		document.textecardprev.SetVariable("Head", $(this).val());
//		document.textecardprev.TCallFrame("TypographyLoader", 6);
		document.textecardprev.TCallFrame("/",8);				
	});		
	$("#FEFbodytext").keyup( function() { 
		document.textecardprev.SetVariable("Body", $(this).val());
//		document.textecardprev.TCallFrame("TypographyLoader", 6);
		document.textecardprev.TCallFrame("/",8);		
	});	
	$("#FEFsignature").keyup( function() { 
		document.textecardprev.SetVariable("Signature", $(this).val());
//		document.textecardprev.TCallFrame("TypographyLoader", 6);
		document.textecardprev.TCallFrame("/",8);				
	});
	$("#FEFexpression").keyup( function() { 
		document.textecardprev.SetVariable("Expression", $(this).val());
//		document.textecardprev.TCallFrame("TypographyLoader", 6);
		document.textecardprev.TCallFrame("/",8);		
	});		
	
	$("#EFFtypography").change( function() {
		document.textecardprev.SetVariable("TypoModel", $("#EFFtypography").val());
		//document.textecardprev.TCallFrame("TypographyLoader", 1);
		document.textecardprev.TGotoFrame("/",4);
	});	
	
	
//  odblokowanie formularza wysylkowego
	$("#EFFsendtypeS").focus( function() { 
			$("#EFFsubmit").val('Wy?lij z automatu');
			$("#EFFsubmit").removeAttr("disabled");
			$("#EFFtimesend").show();	
			$("#EFFnotifyofsend").removeAttr("disabled");
	});
	$("#EFFsendtypeL").focus( function() { 		
			$("#EFFsubmit").val('Wygeneruj link(i) do kartki');
			$("#EFFsubmit").removeAttr("disabled");
			$("#EFFtimesend").hide();
			$("#EFFnotifyofsend").attr("disabled","disabled");			
	});			
	
//----------------------

	$("h2.FEcontent").click( function() {
		$("h2.FEcontent").removeClass('ActiveArea');							
		$("fieldset.FEset").hide('slow');	
		$("fieldset.FEstationery").hide('slow');
		$("fieldset.FEaddress").hide('slow');					
		$("fieldset.FEcontent").show('slow');
		$("h2.FEset").addClass('ActiveArea');			
		$("h2.FEstationery").addClass('ActiveArea');	
		$("h2.FEaddress").addClass('ActiveArea');							
	});
	
	$("h2.FEstationery").click( function() {					
		$("h2.FEstationery").removeClass('ActiveArea');				
		$("fieldset.FEset").hide('slow');	
		$("fieldset.FEcontent").hide('slow');
		$("fieldset.FEaddress").hide('slow');							
		$("fieldset.FEstationery").show('slow');
		$("h2.FEset").addClass('ActiveArea');					
		$("h2.FEcontent").addClass('ActiveArea');	
		$("h2.FEaddress").addClass('ActiveArea');												
	});	
	
	$("h2.FEaddress").click( function() {					
		$("h2.FEaddress").removeClass('ActiveArea');				
		$("fieldset.FEset").hide('slow');	
		$("fieldset.FEcontent").hide('slow');
		$("fieldset.FEstationery").hide('slow');		
		$("fieldset.FEaddress").show('slow');	
		$("h2.FEset").addClass('ActiveArea');					
		$("h2.FEcontent").addClass('ActiveArea');	
		$("h2.FEstationery").addClass('ActiveArea');						
	});		
	
	$("h2.FEset").click( function() {
		$("h2.FEset").removeClass('ActiveArea');												
		$("fieldset.FEstationery").hide('slow');
		$("fieldset.FEcontent").hide('slow');	
		$("fieldset.FEaddress").hide('slow');			
		$("fieldset.FEset").show('slow');
		$("h2.FEcontent").addClass('ActiveArea');	
		$("h2.FEstationery").addClass('ActiveArea');
		$("h2.FEaddress").addClass('ActiveArea');				
	});	


//----------------------	

	$("#LinkToEcard").click( function() { 
		$("#LinkToEcard").select()
	});	
	
	$("#confirmation").removeAttr('checked'); 
	
	$(".FillEcardButton").click( function() { 
		location = BASE_URL + 'myaccount/fill_ecard/' + this.id;
	});	
	
	$("#EcardsLists").change( function() { 
		location=BASE_URL+'myaccount/ecards/' + this.value;
	});		
	
	$("#NTFfile").change( function() { 
		$("#NTFpath").val($("#NTFfile").val());
		$("#NTFpath").show("fast");
	});		
	
	$("#AddNewTags").click( function() { 
		$("#NewThemeTagsForm").show('fast');
		return false;
	});		
	
	$("#EFFdeliverytypeMail").click( function() { 
		$("#EFFdatesend").show();
		$("#EFFsubmit").val('Submit');
		$("#EFFnotifyofsend").removeAttr('disabled');				
	});		
	
	$("#EFFdeliverytypeLink").click( function() { 
		$("#EFFdatesend").val('0');
		$("#EFFdatesend").hide();
		$("#EFFsubmit").val('Create');	
		$("#EFFnotifyofsend").removeAttr('checked');
		$("#EFFnotifyofsend").attr('disabled','disabled');			
	});		
	
	$("#EFFdeliverytypeMail").load( function() { 
		if($("#EFFdeliverytypeMail").attr('checked')=='checked'){
			alert('aaa');
		}
	});	
	
	if($("#EFFdeliverytypeMail").attr('checked')==true){
		$("#EFFsubmit").val('Submit');
		$("#EFFdatesend").show();
	}
	
	if($("#EFFdeliverytypeLink").attr('checked')==true){
		$("#EFFsubmit").val('Create');
	}		
		
	 
});


//on page load (as soon as its ready) 
$(document).ready(JT_init);

/*
 * JTip
 * By Cody Lindley (http://www.codylindley.com)
 * Under an Attribution, Share Alike License
 * JTip is built on top of the very light weight jquery library.
 */
function JT_init(){
	    $("a.jTip").hover(function(){	
			JT_show(this.href, this.id, this.name);
		},function(){
			$('#JT').remove();
		});	 
}

function set_time(start){
var Start=start+1;
setTimeout("set_time("+Start+")",1000)
return Start;
}

function JT_show(url,linkId,title){
	var title=title;
	var de = document.documentElement;
	var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var hasArea = w - getAbsoluteLeft(linkId);
	var params =  linkId.split("-");
	var themeid = params['0'];
	var hash = params['1'];
	var orientation = params['2'];

	if(orientation == 'l') {		
		var bg = 'background:#fff;';
		var yOffset = -85;
		var XROffset = 0;
		var XLOffset = 20;
		if(params['width'] === undefined){params['width'] = 260};
		if(params['height'] === undefined){params['height'] = 200};		
	}
	else if (orientation == 'p'){
		var bg = 'background:#fff;';
		var yOffset = -90;
		var XROffset = 0;
		var XLOffset = 20;
		if(params['width'] === undefined){params['width'] = 180};
		if(params['height'] === undefined){params['height'] = 280};		
	}		
			
	var clickElementy = getAbsoluteTop(linkId)+yOffset ; //set y position
	if(hasArea>((params['width']*1)+200)){
		$("body").append("<div id='JT' style='height:"+params['height']*1+"px;width:"+params['width']*1+"px;"+bg+"'><div style='padding:0 0 6px 0;'>'"+title+"'</div><div id='JT_copy'><div class='JT_loader'><div><img src=\""+BASE_URL+"ethm/prv/"+themeid+"_"+hash+".jpg\" /></div></div>");//right side
		var arrowOffset = getElementWidth(linkId) - XROffset;
		var clickElementx = getAbsoluteLeft(linkId) + arrowOffset; //set x position
	}else{
		$("body").append("<div id='JT' style='height:"+params['height']*1+"px;width:"+params['width']*1+"px;"+bg+"'><div style='padding:0 0 6px 0;'>'"+title+"'</div><div id='JT_copy'><div class='JT_loader'><div><img src=\""+BASE_URL+"ethm/prv/"+themeid+"_"+hash+".jpg\" /></div></div>");//left side
		var clickElementx = getAbsoluteLeft(linkId) - ((params['width']*1) + XLOffset); //set x position
	}
	
	$('#JT').css({left: clickElementx+"px", top: clickElementy+"px"});
	$('#JT').show();
}

function getElementWidth(objectId) {
	x = document.getElementById(objectId);
	return x.offsetWidth;
}

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	o = document.getElementById(objectId)
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	return oLeft
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	return oTop
}

function blockEvents(evt) {
              if(evt.target){
              evt.preventDefault();
              }else{
              evt.returnValue = false;
              }
}








