var TotalFontTexte;
FontTexte = new Array();




function AlertLicence(etat)
{
	document.getElementById('TextLicence').innerHTML = '<span class="red">PLEASE SELECT THE NUMBER OF LICENSES</span>';
}

function LoadFontText()
{
	for (i=0;i<TotalFontTexte;i++) showHideSelect("ZoneTexte_" + i);
}

function ShowCheckStep2(img_checkbox,id_type){
	Checked_image='images/checkbox_checked.png';
	Unchecked_image='images/checkbox_unchecked.png';
	
	var eula_agree = 0;
	var img = new String();
	img = document.images['img_checkbox'].src
	if (img.indexOf(Unchecked_image) != -1) {
		eula_agree = 1;	
		document.images['img_checkbox'].src=Checked_image;
	}
	else document.images['img_checkbox'].src=Unchecked_image;
	
	if (id_type == 1) executerOperation("Rcontent",'includes/EndEula.php?eula_agree=' + eula_agree,'');
	if (id_type == 2) {
		showHideSelect('ZBillingAdr');
		if (document.getElementById('ZBillingAdr').style.display=='none') document.getElementById('billing_adr').value='0';
		else document.getElementById('billing_adr').value='1';

	}
}

function GoStep(etape)
{
	if (etape != 5) {
		switch(etape) {
			case 1 : etape = "ViewCart";
			  	   break;
			case 2 : etape = "Eula";
				  	   break;
			case 3 : etape = "ContactInformation";
				  	   break;
			case 4 : etape = "BillingInformation";
				  	   break;
			case 5 : etape = "FinalConfirmation";
				  	   break;			
		}
		document.getElementById('Form').action = "Purchase_" + etape + ".html";
	}
	else {
		if (document.Form.PaymentMethod[1].checked) {
			document.Form.amount.value=document.Form.amountp.value;
			document.getElementById('Form').action = "https://www.paypal.com/cgi-bin/webscr";
		}
		
		if (document.Form.PaymentMethod[0].checked) {
			document.getElementById('Form').action = "https://payment.datatrans.biz/upp/jsp/upStartIso.jsp";
			
		}
		
		if (document.Form.PaymentMethod[2]) {
			if (document.Form.PaymentMethod[2].checked) {
				document.getElementById('Form').action = "UpdateCommandeManuel.php";
			}
		}			
	}
	
	document.getElementById('Form').submit();

}

function go_conversion(url)
{
	newrub = window.open(url,'conversion','scrollbars=1,top=0,left=0,status=0,location=0, menubar=0,toolbar=0,resizable=1,width=650,height=300');

}

function showHideSelect(select)
		{
			var objSelect = document.getElementById(select);
			objSelect.style.display = (objSelect.style.display == 'block') ? 'none' : 'block';
		}
		
function validAndHide(txt, obj, input, select)
{
	document.getElementById(input).value = txt;
	obj.parentNode.parentNode.style.display = 'none';	
	document.getElementById(select).innerHTML = obj.innerHTML;
	
}
		
function SelectBloc(bloc,bloc2,couleur,classe)
{

	if (document.getElementById('AddCaddy_' + bloc)) document.getElementById('AddCaddy_' + bloc).className = classe;
	if (document.getElementById('RemoveCaddy_' + bloc)) document.getElementById('RemoveCaddy_' + bloc).className = classe + "_caddy";
	
	if (bloc2!= "") {
		if (document.getElementById('LiStyleName_' + bloc2)) {
			document.getElementById('LiStyleName_' + bloc2).className = classe;
		
		}
	}
	else {
		document.getElementById('LiStyleName_' + bloc).className = classe;
		
	}
	
	if ((classe != "red2") && (classe != "remove")) {
	
		document.getElementById('Titre_' + bloc).style.backgroundColor = '#' + couleur;
		document.getElementById('Bloc_' + bloc).style.backgroundColor = '#' + couleur;
	}
}

function AddCaddy(id_typeface,id_style,package,retour)
{
	zone = "AddCaddy_" + id_typeface + "_" + id_style + "_" + package;
	url = "includes/AddCaddy.php?id_style=" + id_style + "&package=" + package;
	//retour = "typefaces.php?id_typeface=" + id_typeface + "&id_module=" + id_module;
	
	ScrollTop = $(window).scrollTop(); 
	retour = retour.replace(".html","_" + ScrollTop + ".html");
	executerOperation(zone,url,retour);
	
	/*document.images["Ibadge_" + id_typeface + "_" + id_style].src = "images/ValidBadge.png";
	document.getElementById("StyleName_" + id_typeface + "_" + id_style).className = 'green';*/
}

function RemoveCaddy(id_typeface,id_style,package,ligne,retour)
{
	zone = "RemoveCaddy_" + id_typeface + "_" + id_style + "_" + package;
	url = "includes/RemoveCaddy.php?id_style=" + id_style + "&ligne=" + ligne + "&package=" + package;
	retour = retour.replace(".html","_" + document.documentElement.scrollTop + ".html");
	executerOperation(zone,url,retour);
	
	/*document.images["Ibadge_" + id_typeface + "_" + id_style].src = "images/empty.gif";
	document.getElementById("StyleName_" + id_typeface + "_" + id_style).className = "";*/
}

function RemoveCaddyTypeFace(id_typeface,id_module)
{
	zone = "RemoveCaddyTypeFace" + id_typeface;
	url = "includes/RemoveCaddyTypeface.php?id_typeface=" + id_typeface;

	retour = "typefaces.html";
	executerOperation(zone,url,"reload");
	
	/*document.images["Ibadge_" + id_typeface + "_" + id_style].src = "images/empty.gif";
	document.getElementById("StyleName_" + id_typeface + "_" + id_style).className = "";*/
}

function executerOperation(zone,url,retour)
{ 
    var xhr; 
    try { xhr = new XMLHttpRequest(); }                 
    catch(e) 
    {    
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) {
              	if (document.all) eval(zone).innerHTML = xhr.responseText;
		else document.getElementById(zone).innerHTML  = xhr.responseText;
		
		if (retour != "") {
			if (retour == "reload") location.reload();
			else document.location=retour;
		}
              }
         }
    }; 
   xhr.open( "GET", url,  true); 
   xhr.send(null); 
} 

function setSelRange(inputEl, selStart, selEnd) { 
 if (inputEl.setSelectionRange) { 
  inputEl.focus(); 
  inputEl.setSelectionRange(selStart, selEnd); 
 } else if (inputEl.createTextRange) { 
  var range = inputEl.createTextRange(); 
  range.collapse(true); 
  range.moveEnd('character', selEnd); 
  range.moveStart('character', selStart); 
  range.select(); 
 } 
}

function ChangeSize(id,i)
{
	ChangeStyle('p24_' + i,'');ChangeStyle('p48_' + i,'');ChangeStyle('p72_' + i,'');ChangeStyle('p96_' + i,'');ChangeStyle('p112_' + i,'');
	ChangeStyle("p" + id + "_" + i,"taille_select");
	
	FontSize("TypeItText_" + i,id)
	
	executerOperation("Zone","includes/FontSize.php?ligne=" + i + "&FontSize=" + id,'');
}

function ChangeStyle(id,style)
{

	var btn = document.getElementById(id);
	btn.className= style; 
}

function FontSize(id,taille) {
	 document.getElementById(id).style.fontSize = taille + "px"; 
}


function InitTypeItFontSize(id) {
	
	 document.getElementById("TypeItText_" + id).style.color = "black"; 
	 if (document.getElementById("TypeItText_" + id).value == "Type it") document.getElementById("TypeItText_" + id).value = "";
	 executerOperation("Zone","includes/FontChange.php?ligne=" + id,'');
}

function setFocus(input) {
   var tValue = document.getElementById(input).value;
   document.getElementById(input).value = "";
   document.getElementById(input).focus();
   document.getElementById(input).value = tValue;
  
}

function setCursor(el,st,end) {
	el.focus();
	el.setSelectionRange(st,end);
}

function InitTypeItSpecimen(id) {
	 document.getElementById(id).style.color = "black";
	 if (document.getElementById(id).value == "Type It") document.getElementById(id).value = ""; 
}

	

function AddTypeIt(id) {

	//alert(document.FormTypeIt.typeit_focus.value)
	/* FormTypeIt*/
	 document.FormTypeIt.typeit_add.value = id; 
	 document.FormTypeIt.id_style.value = id;
	 document.FormTypeIt.submit();
}

function DelTypeIt(id) {
	document.FormTypeIt.typeit_del.value = id; 
	 document.FormTypeIt.submit()
}

function LoadFile(url_file)
{
	 document.getElementById('MessageFinal').innerHTML = "<span class=\"red\">Downloading...</span>";
	 setTimeout("SendLoadFile('" + url_file + "')",1000); 
}

function SendLoadFile(url_file)
{
	document.getElementById('MessageFinal').innerHTML = "<span class=\"red\">Thank you!</span>";
	document.location = url_file;
}

