// JavaScript Document

var preloaderArr = Array();
//preloader('progress', '/images/preloader.gif');

function preloader(position, images) 
{
	preloaderArr[position] = new Image();
	preloaderArr[position].src = images;
}

/*function getImage(position) {

	if (typeof preloaderArr[position] != 'undefined') {

		return preloaderArr[position].src;

	}

}*/

function getElement( element_id )
{

	if( document.getElementById( element_id ) )
	{
		return document.getElementById( element_id );
	}
	else return null;
}

function validate_email(address) 
{
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(address) == false) 
   {
   		return false;
   }
   else
   {
	   return true;
   }
}

function changeMenuItemSRC( menuItem, src )
{
	if ( src.length > 0 )
	{
		menuItem.src = src;
	}
}

function showSubMenu( menuItem, imageItem, imageSRC )
{
	var subItem = getElement( menuItem );
	subItem.style.visibility = 'visible';

	if ( imageItem.length > 0 && imageSRC.length > 0 )
	{
		var currImageItem = getElement( imageItem );
		currImageItem.src = imageSRC;
	}
}

function hideSubMenu( menuItem, imageItem, imageSRC )
{
	var subItem = getElement( menuItem );
	subItem.style.visibility = 'hidden';

	if ( imageItem.length > 0 && imageSRC.length > 0 )
	{
		var currImageItem = getElement( imageItem );
		currImageItem.src = imageSRC;
	}
}

function showSubSubMenu( menuItem )
{
	var subItem = getElement( menuItem );
	subItem.style.visibility = 'visible';
}

function hideSubSubMenu( menuItem )
{
	var subItem = getElement( menuItem );
	subItem.style.visibility = 'hidden';
}

function showProductImageGallery( bigImage, productID )
{
	window.open( siteWebPath + 'galerie/?product_id=' + productID + '&big_image=' + bigImage, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=680,width=814' );
}


function showProductImageGallery2( sm_product_id )
{
	window.open( siteWebPath + 'galerie_2/?sm_product_id=' + sm_product_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=680,width=814' );
}

function setGalleryBigImage( imageSrc )
{
	var bigImage = getElement( 'bigImage' );
	bigImage.src = imageSrc;

	var div_content = document.getElementById( 'bigImageBox' );
	var div_sm_content = document.getElementById( 'sur_mesure_mode' );

	div_content.style.display = "block";
	div_sm_content.style.display = "none";
}



function showReferenceBigImage( bigImage )
{
	dimmer.enableClose = true;
	dimmer.dimmer.onclick 		= function (e) { hideReferenceBigImage(); }
	dimmer.show();
	mainPopup.setText( '<div style=\"padding: 0 5px;\"><img src=\"' + bigImage + '\" alt=\"\" onload=\"mainPopup.reCenter();\" onclick=\"hideReferenceBigImage();\" /></div>' );
	mainPopup.display({centered:true});
	mainPopup.reCenter();
}

function hideReferenceBigImage()
{
	dimmer.hide(); 
	mainPopup.hide();
}

function showGooglePage()
{
	window.open( siteWebPath + 'google_video/', '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=290,width=378' );
}

function showConditionsPage()
{
	window.open( siteWebPath + 'conditions_popup/', '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=0,height=500,width=600' );
}

function showCartToEmailPopup()
{
	var form_html = '<div style="text-align: right; padding: 0 5px 0 0; margin: 0; color: red;"><img src="/images/icons/close.png" style="cursor: pointer;" class="transparent" width="16" height="16" onclick="mainPopup.hide();" /></div>';
	form_html += '<div style="padding: 0 20px;"><table cellpadding="5">';
	form_html += '<tr><td colspan="2" align="center" style="font-size: 13px; font-weight: bold; color: #860001; padding: 0 10px 10px 10px;">Recevez une copie de votre panier par mail</td></tr>';
	form_html += '<tr><td align="right" style="font-size: 11px; font-weight: bold; color: #808080;">Votre adresse mail : </td><td align="left"><input type="text" class="box" id="client_email" name="client_email" /></td></tr>';
	form_html += '<tr><td colspan="2" align="center"><img src="/images/buttons/validate_transparent.png"  style="cursor: pointer;" class="transparent" width="78" height="29" alt="Valider" title="Valider" onclick="sendCartEmail();" /></td></tr>';
	form_html += '</table><div>';
	mainPopup.setText( form_html );
	mainPopup.display({centered:true});
	mainPopup.reCenter();
}

function sendPDFtoEmailPopup()
{
	var form_html = '<div style="text-align: right; padding: 0 5px 0 0; margin: 0; color: red;"><img src="/images/icons/close.png" style="cursor: pointer;" class="transparent" width="16" height="16" onclick="mainPopup.hide();" /></div>';
	form_html += '<div style="padding: 0 20px;"><table cellpadding="5">';
	form_html += '<tr><td colspan="2" align="center" style="font-size: 13px; font-weight: bold; color: #860001; padding: 0 10px 10px 10px;">Recevoir cette fiche produit par mail</td></tr>';
	form_html += '<tr><td align="right" style="font-size: 11px; font-weight: bold; color: #808080;">Votre adresse mail : </td><td align="left"><input type="text" class="box" id="client_email" name="client_email" /></td></tr>';
	form_html += '<tr><td colspan="2" align="center"><img src="/images/buttons/validate_transparent.png"  style="cursor: pointer;" class="transparent" width="78" height="29" alt="Valider" title="Valider" onclick="SendPDFEmail(); pageTracker._trackPageview(\'/pdf_produit_OK\');" /></td></tr>';
	form_html += '</table><div>';
	mainPopup.setText( form_html );
	mainPopup.display({centered:true});
	mainPopup.reCenter();
}


function popupCustomerDemand()
{
	var cnt = document.getElementsByClassName('box_value').length;
	for ( i = 0; i < cnt; i++ )
	{
		var value_box = document.getElementById( 'value_' + i ).value;
		if ( value_box == "" )
		{
			alert( 'Pour obtenir un devis veuillez completer les dimensions que vous souhaitez pour ce meuble.' );	
			return false;			
		}
	}
	
	var browser=navigator.appName;
	if (browser=="Microsoft Internet Explorer")
	{
		var ua = navigator.userAgent;
		var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
		{
			rv = parseFloat(RegExp.$1);
			if(rv == 8)
			{
				var left = '370px'
			}
			else
			{
				var left = '0';
			}
		}
		else
		{
			var left = '0';
		}
	}
	else var left = '370px';

	// old height is height:150px; you can put it again when you want to uncomment the promo code field
	var form_html = '<div style="text-align: right; padding: 0 5px 0 0; margin: 0; color: red; width: 400px; height:120px;"><div style="position:relative; width:80px;"><img src="/images/icons/close.png" style="cursor: pointer; position:absolute; top:0; left:' + left + '; z-index:9998;" class="transparent" width="16" height="16" onclick="mainPopup.hide({hideDimmer:true});"   /></div>';
	form_html += '<div style="padding: 0 20px;"><table cellpadding="5">';
	form_html += '<tr><td colspan="2" style="text-align: center; font-size: 13px; font-weight: bold; color: #860001; padding: 5px 10px 10px 10px;">Recevoir un devis par mail</td></tr>';
	form_html += '<tr><td style="text-align: right; font-size: 11px; font-weight: bold; color: #808080;">Votre adresse mail </td><td align="left" style="width: 200px;"><div style="position:relative;"><input type="text" class="box" id="client_email" name="client_email" style="position: absolute; z-index: 9999; top: -10px; left: 0; width:150px" /></div></td></tr>';
	form_html += '<tr><td style="text-align: right; font-size: 11px; font-weight: bold; color: #808080;">Votre téléphone </td><td align="left" style="width: 200px;"><div style="position:relative;"><input type="text" class="box" id="client_phone" name="client_phone" style="position: absolute; z-index: 9999; top: -10px; left: 0; width:150px" /></div></td></tr>';
	//form_html += '<tr><td align="left" style="font-size: 11px; ; color: #808080;">Si vous avez un code promo merci de le rentrer ici </td><td align="left" style="width: 200px;"><div style="position:relative;"><input type="text" class="box" id="promo_code" name="promo_code" style="width:100px" /></div></td></tr>';
	form_html += '<tr><td colspan="2" align="center"><div style="position:relative; width:150px;"><img src="/images/buttons/validate_transparent.png"  style="cursor: pointer;" class="transparent" width="78" height="29" alt="Valider" title="Valider" onclick="sendCustomerDemand();" style="position:absolute; top:0; left:0; z-index:9998;" /></td></tr>';
	form_html += '</table><div>';
	mainPopup.setText( form_html );		
	mainPopup.display({centered:true, dimmer:true});
	mainPopup.mouseDetach();
	mainPopup.reCenter();	
}

function sendCartEmail()
{
	var client_email = getElement('client_email').value;
	if ( validate_email( client_email ) == false )
	{
		alert("Votre adresse mail est incorrecte");
		return;
	}
	mainPopup.hide();

	var form_html = '<div style="padding: 0 20px;"><table cellpadding="5">';
	form_html += '<tr><td align="center" style="font-size: 13px; font-weight: bold; color: #046604; padding: 0 10px 10px 10px;">Votre demande a ete prise en compte !</td></tr>';
	form_html += '<tr><td align="center"><img src="/images/buttons/continue_transparent_green.png"  style="cursor: pointer;" class="transparent" width="93" height="29" alt="Valider" title="Valider" onclick="mainPopup.hide();" /></td></tr>';
	form_html += '</table><div>';

	mainPopup.setText( form_html );
	mainPopup.display({centered:true});
	mainPopup.reCenter();
	var url = siteWebPath + "send_shopping_cart_to_email/?email=" + client_email; 
	new Ajax.Request( url, {method: 'get', onSuccess: sendCartEmailSuccess});
}

function SendPDFEmail()
{
	var product_id = document.getElementById('products_id').value;
	var client_email = getElement('client_email').value;
	if ( validate_email( client_email ) == false )
	{
		alert("Votre adresse mail est incorrecte");
		return;
	}
	mainPopup.hide();

	var form_html = '<div style="padding: 0 20px;"><table cellpadding="5">';
	form_html += '<tr><td align="center" style="font-size: 13px; font-weight: bold; color: #046604; padding: 0 10px 10px 10px;">Votre demande a ete prise en compte !</td></tr>';
	form_html += '<tr><td align="center"><img src="/images/buttons/continue_transparent_green.png"  style="cursor: pointer;" class="transparent" width="93" height="29" alt="Valider" title="Valider" onclick="mainPopup.hide();" /></td></tr>';
	form_html += '</table><div>';

	mainPopup.setText( form_html );
	mainPopup.display({centered:true});
	mainPopup.reCenter();
	
	var url = siteWebPath + "send_pdf_to_mail_new/?email=" + client_email + "&product_id=" + product_id; 
	new Ajax.Request( url, {method: 'get', onSuccess: sendPDFEmailSuccess});
}


function confirmMessage()
{
	var form_html = '<div style="padding: 0 20px;"><table cellpadding="5">';
	form_html += '<tr><td align="center" style="font-size: 13px; font-weight: bold; color: #046604; padding: 0 10px 10px 10px;">Votre demande a ete prise en compte !</td></tr>';
	form_html += '<tr><td align="center"><img src="/images/buttons/continue_transparent_green.png"  style="cursor: pointer;" class="transparent" width="93" height="29" alt="Valider" title="Valider" onclick="mainPopup.hide();" /></td></tr>';
	form_html += '</table><div>';

	mainPopup.setText( form_html );
	mainPopup.display({centered:true});
	mainPopup.reCenter();
}


function sendCustomerDemand()
{
	//valider_recrutement(this);
	pageTracker._trackPageview ('/demande_devis_ok');
	
	var comment = '';
	var sm_products_id = document.getElementById('sm_products_id').value;
	var sm_categories_id = document.getElementById('sm_categories_id').value;
	var sm_finitions_id = document.getElementById('sm_finitions_id').value;
	var sm_colors_id = document.getElementById('sm_colors_id').value;
	var sm_parasol = document.getElementById('parasol_check');
	var sm_serrures = document.getElementById('serrures_check');	
	var sm_handles = document.getElementById('sm_handles_id');
	var sm_handles_name = sm_handles.options[sm_handles.selectedIndex].text;
	var sm_handles_id = sm_handles.value;
	var sm_doors = document.getElementById('sm_doors_id');
	var sm_doors_name = sm_doors.options[sm_doors.selectedIndex].text;
	var sm_doors_id = sm_doors.value;
	var sm_leathers = document.getElementById('sm_leathers_id');
	var sm_leathers_id = sm_leathers.value;
	var sm_marble = document.getElementById('sm_marble_id');
	var sm_marble_id = sm_marble.value;
	var parasol_block = document.getElementById('add_parasol');
	var serrures_block = document.getElementById('add_serrures');
	var comments = document.getElementById('comment').value;
	var devis_comm = document.getElementById('devis_comm').style.display;
	var real_id = document.getElementById('real_products_id').value;
	
	if ( document.getElementById('colors_row').style.display == 'block' && !( sm_colors_id > 0 ) )
	{
		sm_colors_id = 9;
	}
	else if ( document.getElementById('colors_row').style.display == 'none' && !( sm_colors_id > 0 ) )
	{
		sm_colors_id = 0;
	}
	
	if ( !( sm_finitions_id > 0 ) && document.getElementById('finitions_row').style.display == 'block' )
		sm_finitions_id = 1;
		
	if ( sm_parasol.checked == true && parasol_block.style.display == 'block' )
		sm_parasol = 1;
	else if ( sm_parasol.checked == false && parasol_block.style.display == 'block' )
		sm_parasol = 0;
	else
		sm_parasol = false;
		
	if ( sm_serrures.checked == true && serrures_block.style.display == 'block' )
		sm_serrures = 1;
	else if ( sm_serrures.checked == false && serrures_block.style.display == 'block' )
		sm_serrures = 0;
	else
		sm_serrures = false;		

	if ( sm_handles.style.display == 'none' && !( sm_colors_id > 0 ) )
	{
		sm_handles_id = 0;
		sm_handles_name = '';
	}		if ( sm_doors.style.display == 'none' && !( sm_colors_id > 0 ) )	{		sm_doors_id = 0;		sm_doors_name = '';	}
	if ( comments.length == 0 || devis_comm == 'none' )
	{
		comment = '';
	}
	else
	{
		comment = 'Commentaires du client : ' + comments;
	}
	devis_comm = 'none';
	var client_email = getElement('client_email').value;
	var client_phone = getElement('client_phone').value;
	var promo_code = ( getElement('promo_code') != null ) ? getElement('promo_code').value : '';

	if ( validate_email( client_email ) == false )
	{
		alert("Votre adresse mail est incorrecte");
		return;
	}
	
	if ( client_phone.length < 10 )
	{
		alert("Votre téléphone est incorrect");
		return;
	}
	
	EA_button('devis_sur_mesure');
	
	var cnt_labels = document.getElementById('cnt_labels').value;
	var labels_pars = '';
	for ( i = 0; i < cnt_labels; i++ )
	{
		var val = document.getElementById('value_' + i + '').value;
		labels_pars += val + '|&';
	}

	mainPopup.hide();

	var form_html = '<div style="padding: 0 20px;"><table cellpadding="5">';
	form_html += '<tr><td align="center" style="font-size: 13px; font-weight: bold; color: #046604; padding: 0 10px 10px 10px;">Votre demande a ete prise en compte !</td></tr>';
	form_html += '<tr><td align="center"><img src="/images/buttons/continue_transparent_green.png"  style="cursor: pointer;" class="transparent" width="93" height="29" alt="Valider" title="Valider" onclick="mainPopup.hide({hideDimmer:true});" /></td></tr>';
	form_html += '</table><div>';

	mainPopup.setText( form_html );
	mainPopup.display({centered:true});
	mainPopup.reCenter();
	var url = siteWebPath + "sur_mesure_ajax.php/?action=send_customer_demand"; 
	new Ajax.Request( url, {method: 'post', parameters: { 'label_vals' : labels_pars, 'email': client_email, 'phone': client_phone, 'promo_code': promo_code, 'sm_products_id': sm_products_id, 'sm_categories_id': sm_categories_id, 'sm_finitions_id': sm_finitions_id, 'sm_colors_id': sm_colors_id, 'sm_parasol': sm_parasol, 'sm_handles_id': sm_handles_id, 'sm_handles_name': sm_handles_name, 'sm_doors_id': sm_doors_id, 'sm_doors_name': sm_doors_name, 'comment': comment, 'sm_serrures': sm_serrures, 'sm_leathers_id': sm_leathers_id, 'real_id': real_id , 'sm_marble_id': sm_marble_id } });

	document.getElementById('comment').value = '';
	for ( i = 0; i < cnt_labels; i++ )
	{
		document.getElementById('value_' + i + '').value = '';
	}}

	var sendCartEmailSuccess = function (t) {

	/*var client_email = getElement('client_email').value;

	var form_html = '<div style="text-align: right; padding: 0 5px 0 0; margin: 0; color: red;"><img src="/images/icons/close.png" style="cursor: pointer;" class="transparent" width="16" height="16" onclick="mainPopup.hide();" /></div>';

	form_html += '<div style="padding: 0 20px;"><table cellpadding="5">';

	form_html += '<tr><td align="center" style="font-size: 13px; font-weight: bold; color: #860001; padding: 0 10px 10px 10px;">Le contenu de votre panier a ete envoye par mail a ' + client_email + '</td></tr>';

	form_html += '<tr><td align="center"><img src="/images/buttons/continue_transparent.png"  style="cursor: pointer;" class="transparent" width="93" height="29" alt="Valider" title="Valider" onclick="mainPopup.hide();" /></td></tr>';

	form_html += '</table><div>';

	mainPopup.setText( form_html );

	mainPopup.display({centered:true});

	mainPopup.reCenter();

	*/

}

var sendPDFEmailSuccess = function (t) {

	/*var client_email = getElement('client_email').value;

	var form_html = '<div style="text-align: right; padding: 0 5px 0 0; margin: 0; color: red;"><img src="/images/icons/close.png" style="cursor: pointer;" class="transparent" width="16" height="16" onclick="mainPopup.hide();" /></div>';

	form_html += '<div style="padding: 0 20px;"><table cellpadding="5">';

	form_html += '<tr><td align="center" style="font-size: 13px; font-weight: bold; color: #860001; padding: 0 10px 10px 10px;">Le contenu de votre panier a ete envoye par mail a ' + client_email + '</td></tr>';

	form_html += '<tr><td align="center"><img src="/images/buttons/continue_transparent.png"  style="cursor: pointer;" class="transparent" width="93" height="29" alt="Valider" title="Valider" onclick="mainPopup.hide();" /></td></tr>';

	form_html += '</table><div>';

	mainPopup.setText( form_html );

	mainPopup.display({centered:true});

	mainPopup.reCenter();

	*/
}

function expandLeftMenu( categories_id )
{
	var child = getElement( 'child_' + categories_id );
	var icon = getElement( 'status_icon_' + categories_id );
	if ( child != null )
		child.style.display = 'block';
	if ( icon != null )
	{
		icon.style.display = 'block';
		icon.src = '/images/icons/minus.gif';
	}
}



function collapseLeftMenu( categories_id )
{
	var child = getElement( 'child_' + categories_id );
	var icon = getElement( 'status_icon_' + categories_id );
	if ( child != null )
		child.style.display = 'none';

	if ( icon != null )
	{
		icon.style.display = 'none';
		icon.src = '/images/icons/plus.gif';
	}
}

function expandOrCollapseLeftMenu( icon, categories_id )
{
	if ( icon.src.match( 'minus' ) != null )
	{
		collapseLeftMenu( categories_id );
	}
	else
	{
		expandLeftMenu( categories_id );
	}
}

function showHandlesPopup()
{
	var curr_handle = getElement( 'sm_handles_id' );
	var curr_product = getElement( 'sm_products_id' );

	var sm_handles_id = 0;
	var sm_products_id = 0;

	if ( curr_handle != null )
		sm_handles_id = curr_handle.value;
	if ( curr_product != null )
		sm_products_id = curr_product.value;
		
	window.open( siteWebPath + 'sm_handles_popup/?sm_handles_id=' + sm_handles_id + '&sm_products_id=' + sm_products_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=520,width=980' );
}

function showDoorsPopup()
{
	var curr_door = getElement( 'sm_doors_id' );
	var sm_doors_id = 0;

	if ( curr_door != null )
		sm_doors_id = curr_door.value;
	window.open( siteWebPath + 'sm_doors_popup/?sm_doors_id=' + sm_doors_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=526,width=950' );
}

function showDrawersPopup()
{
	var curr_drawer = getElement( 'sm_drawers_id' );
	var sm_drawers_id = 0;

	if ( curr_drawer != null )
		sm_drawers_id = curr_drawer.value;

	window.open( siteWebPath + 'sm_drawers_popup/?sm_drawers_id=' + sm_drawers_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=526,width=902' );
}

function showColorsPopup()
{
	var curr_color = getElement( 'sm_colors_id' );
	var sm_colors_id = 0;

	if ( curr_color != null )
		sm_colors_id = curr_color.value;

	window.open( siteWebPath + 'sm_colors_popup/?sm_colors_id=' + sm_colors_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=526,width=932' );
}

//	About SUR_MESURE Form  - Popup window option + color details
function showColorsPopup2()
{
	var curr_color = getElement( 'sm_colors_bois_id' );
	var sm_colors_id = 0;
	if ( curr_color != null )
		sm_colors_id = curr_color.value;
	window.open( siteWebPath + 'sm_colors_popup2/?sm_colors_id=' + sm_colors_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=526,width=932' );
}

function showProfilesPopup()
{
	var curr_profile = getElement( 'sm_profiles_id' );
	var sm_profiles_id = 0;
	if ( curr_profile != null )
		sm_profiles_id = curr_profile.value;

	window.open( siteWebPath + 'sm_profiles_popup/?sm_profiles_id=' + sm_profiles_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=520,width=950' );
}


function showFinitionsPopup()
{	
	var curr_finition = getElement( 'sm_finitions_id' );
	var sm_finitions_id = 0;
	if ( sm_finitions_id != null )
		sm_finitions_id = curr_finition.value;
		
	window.open( siteWebPath + 'sm_finitions_popup/?sm_finitions_id=' + sm_finitions_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=320,width=600' );
}

function removeSubproduct( subproduct_id )
{
	var subproduct_delete = getElement( 'subproduct_' + subproduct_id );
	subproduct_delete.value = '1';
	document.cart_quantity.submit();
}

function showCutPopup( products_id )
{
	window.open( siteWebPath + 'popups/?popup=cut&products_id=' + products_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=230,width=420' );
}

function showVoilesPopup( products_id )
{
	window.open( siteWebPath + 'popups/?popup=voiles_popup&products_id=' + products_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=290,width=420' );
}

function showVasquesEnMarbrePopup( products_id )
{
	window.open( siteWebPath + 'popups/?popup=vasques_en_marbre_popup&products_id=' + products_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=290,width=420' );
}

function showPlanDeTravailEnChenePopup( products_id )
{
	window.open( siteWebPath + 'popups/?popup=plan_de_travail_en_chene&products_id=' + products_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=325,width=420' );
}

function showPlanDeTravailEnHetrePopup( products_id )
{
	window.open( siteWebPath + 'popups/?popup=plan_de_travail_en_hetre&products_id=' + products_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=325,width=420' );
}

function showDevisDePosePopup( products_id )
{
	window.open( siteWebPath + 'popups/?popup=devis_de_pose&products_id=' + products_id, '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=405,width=420' );
}

function checkLivePerson( page )
{
	var home_page_img = getElement( 'homepage_live_chat_img' );
	var left_menu_img = getElement( 'leftmenu_live_chat_img' );
	if ( home_page_img != null )
	{ //alert('home');
		home_page_img.src = 'http://server.iad.liveperson.net/hc/29511913/?cmd=repstate&site=29511913&channel=web&&ver=1&imageUrl=http://www.tekimport.fr/images/home_page/live_tchat';
	}

	if ( left_menu_img != null )
	{ //alert('menu');
		left_menu_img.src = 'http://server.iad.liveperson.net/hc/29511913/?cmd=repstate&site=29511913&channel=web&&ver=1&imageUrl=http://www.tekimport.fr/images/left_menu/live_tchat';
	}	
}

function roundProductQuantity( field )
{
	var quantity = field.value;
	quantity = quantity.replace( ',', '.' );
	var dot_pos = quantity.indexOf( '.' );
	
	if ( field.id == "buyqty_37" )
	{
		var num = parseFloat( quantity );
		if ( num < 1 )
		{
			field.value = "1";
		}
		else
		{
			if ( quantity.substr( ( quantity.length - 1 ), quantity.length ) != "." && dot_pos != -1  )
			{
				var num = parseInt( quantity.substring( 0, dot_pos ) );
				var decimal = quantity.substr( dot_pos + 1, 1 );
				field.value = num + "." + decimal;
			}
		}
	}
	else if ( dot_pos != -1 )
	{
		var num = parseInt( quantity.substring( 0, dot_pos ) );
		var decimal = quantity.substr( dot_pos + 1, 1 );
		if ( decimal == '' )
			return;
		if ( parseInt( decimal ) > 0 )
			num = num + 1;
		field.value = num;
	}
}

function showServicesIconInfo( id )
{
	var info_text = getElement( id );
	if ( info_text == null )
		return;
	mainPopup.setText( info_text.innerHTML );
	mainPopup.display();
	mainPopup.mouseAttach();
}

function hideServicesIconInfo()
{
	mainPopup.hide();
}

function showSatisfactionText()
{
	var text = '<div style="width: 200px; font-size: 11px; padding: 0 5px; color: #666666; text-align: justify; font-family: Arial, Helvetica, sans-serif;">Si vous n\'etiez pas satisfait de votre achat vous pouvez nous le signaler sous 7 jours. Vous etes integralement rembourse sous 8 jours des reception de votre commande a notre depot.</div>';
	mainPopup.setText( text );
	mainPopup.display();
	mainPopup.mouseAttach();
}

function hideSatisfactionText()
{
	mainPopup.hide();
}

function showHideFAQ( el_id )
{
	var currFAQ = document.getElementById( el_id );
	if ( currFAQ.style.display == 'block' )
	{
		currFAQ.style.display = 'none';
	}
	else
	{
		currFAQ.style.display = 'block';
	}
}

function popupcalc( montant )
{ //8994
	var win2 = window.open("https://secure.kwixo.com/credit/calculator.htm?merchantId=3620&amount=" + montant,'popup','height=645,width=570,status=yes,scrollbars=yes,menubar=no,resizable=yes');
}

function popuprnp3x(){
	var win2 = window.open('http://www.kwixo.com/static/payflow/html/popup-3x.htm','popup','height=905,width=800,status=yes,scrollbars=yes,menubar=no,resizable=yes');

}

function popuprnp1xrnp(){
	var win2 = window.open('http://www.kwixo.com/static/payflow/html/popup-1x-rnp.htm','popup','height=705,width=615,status=yes,scrollbars=yes,menubar=no,resizable=yes');
}

function showCoolTagTitle( id )
{
	var el = getElement( id );
	if ( el == null ) return;
	var text = '<div style="width: 200px; font-size: 11px; padding: 0 5px; color: #666666; text-align: justify; font-family: Arial, Helvetica, sans-serif;">' + el.innerHTML + '</div>';
	mainPopup.setText( text );
	mainPopup.display();
	mainPopup.mouseAttach();
}

function hideCoolTagTitle()
{
	mainPopup.hide();
}

function showCryptoText()
{
	var text = '<div style="width: 200px; font-size: 11px; padding: 0 5px; color: #666666; text-align: justify; font-family: Arial, Helvetica, sans-serif;">Il s\'agit des 3 derniers chiffres imprimes dans le champ de signature sur le dos de la carte. La saisie de ce code est desormais necessaire pour valider la transaction d\'achat. Il permet de vous proteger d\'une utilisation frauduleuse de votre carte.</div>';
	mainPopup.setText( text );
	mainPopup.display();
	mainPopup.mouseAttach();
}

function hideCryptoText()
{
	mainPopup.hide();
}

function showLoader( parent_id )
{

	var parent = getElement( parent_id );
	var width = parent.offsetWidth;
	var height = parent.offsetHeight;
	//alert( width + '-' + height );
	parent.style.position = 'relative';

	var loader = getElement( 'loader' );
	if ( loader == null )
		loader = document.createElement('img');
	loader.src = '/images/popup/indicator_square.gif';
	loader.style.position = 'absolute';
	loader.style.top = ( ( height/2 ) - 20 ) + 'px';
	loader.style.left = ( ( width/2 ) - 20 ) + 'px';
	loader.id = 'loader';
	loader.style.display = 'block';

	parent.appendChild( loader );
}

function hideLoader()
{
	var loader = getElement( 'loader' );
	if ( loader != null )
		loader.style.display = 'none';
}

function fixIEPng( id )
{
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
	if (itsAllGood) 
	{
		if( document.getElementById( id ) )
		{
			var obj = document.getElementById( id );
			var bg = obj.currentStyle.backgroundImage;
			var img = document.getElementById( id );
			if (bg && bg.match(/\.png/i) != null) 
			{
				var img = bg.substring(5,bg.length-2);
				var offset = obj.style["background-position"];
				obj.style.filter =

				"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img+"', sizingMethod='crop')";
				obj.style.backgroundImage = "url('/js/blank.gif')";
				obj.style["background-position"] = offset; // reapply
			} 
			else if (img && img.src.match(/\.png$/i) != null) 
			{
				var src = img.src;
				img.style.width = img.width + "px";
				img.style.height = img.height + "px";
				img.style.filter =
				"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='crop')"
				img.src = "/js/blank.gif";
			}
		}
	}
}


function showEncheresPopup( div )
{
	mainPopup.setText( div );
	mainPopup.display();
	mainPopup.mouseAttach();
}

function updateEncheresPopupInfofunction( div )
{
	mainPopup.setText( div );
}

function hideEncheresPopup()
{
	mainPopup.hide();
}

function showExtraInfo(image, id, name, e, cntr)
{
	var div = $("gal_popup");
	var posx = 0;
	var posy = 0;
	var popX = 0;
	var popY = 0;
	
	if (e.pageX || e.pageY) 	
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	
	{
		posx = e.clientX; 
		posy = e.clientY;
	}

	var cngY = Math.floor((posy - 125) / 180);
	var cngX = Math.floor(posx / 202);
	
	var top = ((cngY*180) + 100 );
	var left = ((cngX*202) - 75 );
	if(left <0)
	{
		left = 0;
	}
	else if (left > 458)
	{
		left = 458;
	}
	
	if(top > 380)
	{
		top = 380;
	}
	
	div.style.top = top + 'px';
	div.style.left = left + 'px';
	
	var url = '/ajax?ajax_action=get_image_info&id=' + id + '&nmb=' + cntr + '&name=' + name ;
	var myAjax = new Ajax.Request(
		url, 
		{
			method: 'get',
			onComplete: function(data) {
				if(data.responseText.length > 0)
				{
					div.style.display = "block";
					div.innerHTML = data.responseText;
				}
				else
				{
					div.style.display = "none";
				}
			}
		}
	);

}

function showExtraInfo2(image, id, name, e, cntr)
{
	var div = $("gal_popup");
	
	var posx = 0;
	var posy = 0;
	
	var popX = 0;
	var popY = 0;
	
	if (e.pageX || e.pageY) 	
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	
	{
		posx = e.clientX; 
		posy = e.clientY;
	}

	var cngY = Math.floor((posy - 15) / 162);
	var cngX = Math.floor((posx - 160) / 180);
	
	var top = ((cngY*162) + 15 - 100 );
	var left = ((cngX*180) + 160 - 90 );

	if (left > 550)
	{
		left = 550;
	}
	
	if(top <0)
	{
		top = 0;
	}
	else if(top > 380)
	{
		top = 380;
	}

	div.style.top = top + "px";
	div.style.left = left + "px";
	
	var url = '/ajax?ajax_action=get_image_info&id=' + id + '&col=false&nmb=' + cntr + '&name=' + name ;
	var myAjax = new Ajax.Request(
		url, 
		{
			method: 'get',
			onComplete: function(data) {
				if(data.responseText.length > 0)
				{
					div.style.display = "block";
					div.innerHTML = data.responseText;
				}
				else
				{
					div.style.display = "none";
				}
			}
		}
	);
	
}

function hideExtraInfo1(nmb)
{
	var div = $("gal_popup");
	div.innerHTML = "";
	div.style.display = "none";
	imageLoaded[nmb] == false;
}


function hideExtraInfo2(nmb)
{
	if(imageLoaded[nmb] == true)
	{
		var div = $("gal_popup");
		div.innerHTML = "";
		div.style.display = "none";
	}
	imageLoaded[nmb] == false;
}

function movePopupOnLoad(img, col, nmb)
{
	var div = $("gal_popup");
	var divTop = div.style.top;
	var popYraw = divTop.split('p');
	var popY = parseInt(popYraw[0]);
	
	var newImg = new Image();
	newImg.src = img.src;
	var height = newImg.height + Math.round(newImg.height * 0.08);

	if(height > 200 && popY > 370 && !col)
	{
		popY = popY - Math.round( (height - 190) );
	}
	else if (height > 200 && popY > 200 && col == true)
	{
		popY = popY - Math.round( (height - 190) );
	}
	
	div.style.top = popY + "px";
}

function closeThisPopup()
{
	if(!window.opener)
	{
		window.close();
	}
	else
	{
		window.opener.focus();
		window.close();
	}
}

function showPageEar()
{
	if ( document.getElementById( "bigDiv" ) )
		document.getElementById( "bigDiv" ).style.display = "block";
	if (document.getElementById( "thumbDiv" ) )
		document.getElementById( "thumbDiv" ).style.display = "block";
}

function hidePageEar()
{
	if ( document.getElementById( "bigDiv" ) )
		document.getElementById( "bigDiv" ).style.display = "none";
	if (document.getElementById( "thumbDiv" ) )
		document.getElementById( "thumbDiv" ).style.display = "none";
}

function popupNewsletterTekImport()
{
	//hidePageEar();
	
	var browser=navigator.appName;
	if (browser=="Microsoft Internet Explorer")
	{
		var ua = navigator.userAgent;
		var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
		{
			rv = parseFloat(RegExp.$1);
			if(rv == 8)
			{
				var left = '370px'
			}
			else
			{
				var left = '0';
			}
		}
		else
		{
			var left = '0';
		}
	}
	else var left = '370px';

	var form_html = '<div style="text-align: right; padding: 0 5px 0 0; margin: 0; color: red; width: 400px; height:100px;"><div style="position:relative; width:80px;"><img src="/images/icons/close.png" style="cursor: pointer; position:absolute; top:0; left:' + left + '; z-index:9998;" class="transparent" width="16" height="16" onclick="mainPopup.hide({hideDimmer:true});"   /></div>';

	form_html += '<div style="padding: 0 20px;"><table cellpadding="5">';

	form_html += '<tr><td colspan="2" align="center" style="font-size: 13px; font-weight: bold; color: #860001; padding: 5px 10px 10px 10px;">Renseignez ici votre adresse mail pour recevoir notre Newsletter</td></tr>';

	form_html += '<tr><td align="right" style="font-size: 11px; font-weight: bold; color: #808080; width: 140px;">Votre adresse mail : </td><td align="left" style="width: 160px;"><div style="position:relative;"><input type="text" class="box" id="client_email" name="client_email" style="position: absolute; z-index: 9999; top: -10px; left: 0; width:150px" /></div></td></tr>';

	form_html += '<tr><td colspan="2" align="center"><div style="position:relative; width:150px;"><img src="/images/buttons/validate_transparent.png"  style="cursor: pointer;" class="transparent" width="78" height="29" alt="Valider" title="Valider" onclick="subscribeNewsletterTekImport();" style="position:absolute; top:0; left:0; z-index:9998;" /></td></tr>';

	form_html += '</table><div>';

	mainPopup.setText( form_html );		
	mainPopup.display({centered:true, dimmer:true});
	mainPopup.mouseDetach();
	mainPopup.reCenter();	

}

function subscribeNewsletterTekImport()
{
	var client_email =  document.getElementById( "client_email" ).value;
		
	var result = validate_email( client_email ); 
	
	if( result == false ) 
	{
		alert( 'Votre mail comporte une erreur !' );
	}
	else
	{
					
		//document.getElementById('newsletter_form').submit();
		var url = '/newsletter_subscribe';
		var myAjax = new Ajax.Request(url,
		{
			method: 'post',
			parameters: { email: client_email },
			onComplete: function( data ) 
			{
				//alert(data.responseText);
				if ( data.responseText == "success" )
				{
					mainPopup.mouseDetach();
					mainPopup.setText( '<div class=\"flashmsg success\"><img src=\"/images/popup/icon_success.png\" alt=\"\" align=\"absmiddle\" class=\"flashmsg-icon\" />&nbsp;Vous êtes inscrit à la newsletter Tek Import.<div class="button"><img src="/images/popup/ok_btn.png" alt="OK" width="48" height="30" onclick="mainPopup.hide({hideDimmer:true});" /></div></div>' );
					mainPopup.display({centered:true});
					
					//showPageEar();
				}
				else if ( data.responseText == "already_subscribed" )
				{
					mainPopup.mouseDetach();
					mainPopup.setText( '<div class=\"flashmsg warning\"><img src=\"/images/popup/icon_warning.png\" alt=\"\" align=\"absmiddle\" class=\"flashmsg-icon\" />&nbsp;Vous êtes déjà inscrit à notre newsletter !<div class="button"><img src="/images/popup/ok_btn.png" alt="OK" width="48" height="30" onclick="mainPopup.hide({hideDimmer:true});" /></div></div>' );
					mainPopup.display({centered:true});
				}
				else
				{
					alert( 'Il ya eu une erreur système. S\'il vous plaît essayez de nouveau !' );
				}
			}
		} );
		
	}
}

function checkForQtyPerBoxAndSubmit( product_id )
{
	/*if ( document.getElementById( 'qty_per_box_' + product_id ) )
	{
		var qty_per_box = document.getElementById( 'qty_per_box_' + product_id ).value;
		if ( qty_per_box > 0 )
		{
			var qty = document.getElementById( 'buyqty_' + product_id ).value;
			if ( qty == 0 ) 
			{
				alert( 'Merci de choisir la surface que vous souhaitez.' );
				return false;
			}
			var product_unit = document.getElementById( 'product_unit_' + product_id ).innerHTML;
			var x_int = parseInt( qty / qty_per_box );
			var x_float = qty / qty_per_box;
			if ( x_int != x_float )
			{
				var k_1 = x_int;
				var k_2 = x_int + 1;
				var t_1 = ( k_1 * qty_per_box ).toFixed( 3 );
				var t_2 = ( k_2 * qty_per_box ).toFixed( 3 );
				
				var html_code = '<div class="box-block">';
						html_code += '<div class="box-text">Chaque colis contient ' + qty_per_box + ' ' + product_unit + '. Merci de choisir la surface que vous souhaitez :</div>';
						html_code += '<table cellspacing="0" cellpadding="0" border="0" align="center">';
							html_code += '<tr>';
								html_code += '<td align="center">' + t_1 + ' ' + product_unit + '<br />(' + k_1 + ' colis)</td>';
								html_code += '<td align="left" valign="middle"><img src="/images/buttons/ok_red.png" style="cursor: pointer;" onclick="setNewQtyAndSubmit( ' + product_id + ', ' + t_1 + ' );" /></td>';
								html_code += '<td>&nbsp;</td>';
								html_code += '<td align="center">' + t_2 + ' ' + product_unit + '<br />(' + k_2 + ' colis)</td>';
								html_code += '<td align="left" valign="middle"><img src="/images/buttons/ok_red.png" style="cursor: pointer;" onclick="setNewQtyAndSubmit( ' + product_id + ', ' + t_2 + ' );" /></td>';
							html_code += '</tr>';
						html_code += '</table>';
					html_code += '</div>';
				
				var qty_box = document.getElementById( 'choose_qty_per_box_' + product_id );
				qty_box.innerHTML = html_code;
				qty_box.style.display = "block";
				//alert ( k_1 * qty_per_box );
				//alert ( k_2 * qty_per_box );
				return false;
			}
			else
			{
				document.getElementById( 'buy_now_form_' + product_id ).submit();
				return true;
			}
		}
		else
		{
			document.getElementById( 'buy_now_form_' + product_id ).submit();
			return true;
		}
	}
	else
	{
		document.getElementById( 'buy_now_form_' + product_id ).submit();
		return true;
	}*/
	document.getElementById( 'buy_now_form_' + product_id ).submit();
	return true;
}

function setNewQtyAndSubmit( product_id, qty )
{
	document.getElementById( 'buyqty_' + product_id ).value = qty;
	document.getElementById( 'buy_now_form_' + product_id ).submit();
}

function checkForQtyPerBox( product_id )
{
	if ( document.getElementById( 'qty_per_box_' + product_id ) )
	{
		var qty_per_box = document.getElementById( 'qty_per_box_' + product_id ).value;
		if ( qty_per_box > 0 )
		{
			var qty = document.getElementById( 'qty_' + product_id ).value;
			if ( qty == 0 ) 
			{
				//alert( 'Merci de choisir la surface que vous souhaitez.' );
				//return;
			}
			var product_unit = document.getElementById( 'product_unit_' + product_id ).value;
			var x_int = parseInt( qty / qty_per_box );
			var x_float = qty / qty_per_box;
			if ( qty == 0 || x_int != x_float )
			{
				var k_1 = x_int;
				var k_2 = x_int + 1;
				
				if ( k_1 == 0 )
				{
					k_1 = 1;
					k_2 = 2;
				}
				
				var t_1 = ( k_1 * qty_per_box ).toFixed( 3 );
				var t_2 = ( k_2 * qty_per_box ).toFixed( 3 );
				
				var html_code = '<div class="box-block">';
						html_code += '<div class="box-text">Chaque colis contient ' + qty_per_box + ' ' + product_unit + '. Merci de choisir la surface que vous souhaitez :</div>';
						html_code += '<table cellspacing="0" cellpadding="0" border="0" align="center">';
							html_code += '<tr>';
								html_code += '<td align="center">' + t_1 + ' ' + product_unit + '<br />(' + k_1 + ' colis)</td>';
								html_code += '<td align="left" valign="middle"><img src="/images/buttons/ok_red.png" style="cursor: pointer;" onclick="setNewQty( ' + product_id + ', ' + t_1 + ' );" /></td>';
								html_code += '<td>&nbsp;</td>';
								html_code += '<td align="center">' + t_2 + ' ' + product_unit + '<br />(' + k_2 + ' colis)</td>';
								html_code += '<td align="left" valign="middle"><img src="/images/buttons/ok_red.png" style="cursor: pointer;" onclick="setNewQty( ' + product_id + ', ' + t_2 + ' );" /></td>';
							html_code += '</tr>';
						html_code += '</table>';
					html_code += '</div>';
				
				var qty_box = document.getElementById( 'choose_qty_per_box_' + product_id );
				qty_box.innerHTML = html_code;
				qty_box.style.display = "block";
				//alert ( k_1 * qty_per_box );
				//alert ( k_2 * qty_per_box );
				return false;
			}
		}
	}
	return true;
}

function setNewQty( product_id, qty )
{
	document.getElementById( 'qty_' + product_id ).value = qty;
	
	var product_unit = document.getElementById( 'product_unit_' + product_id ).value;
	document.getElementById( 'product_qty_and_unit_' + product_id ).innerHTML = '(' + qty + ' ' + product_unit + ')';
	
	var qty_box = document.getElementById( 'choose_qty_per_box_' + product_id );
	qty_box.style.display = "none";
}

function checkForQtyPerBoxShoppingCart()
{
	var products = document.getElementById( 'cart_quantity' );
	
	for ( i = 0; i < products.elements.length; i ++ )
	{
		if ( products.elements[i].name == 'products_id[]' )
		{
			if ( checkForQtyPerBox( products.elements[i].value ) == false )
			{
				document.getElementById( 'qty_' + products.elements[i].value ).focus();
				return false;
			}
		}
	}
	return true;
}

function showProduct360View( productID )
{
	window.open( siteWebPath + 'galerie/?product_id=' + productID + '&action=flash', '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=680,width=814' );
}

function closeCartPopup()
{
	document.getElementById( "cart_popup" ).style.display = "none";
}

function popupAddToCart( products_id, action )
{
	document.getElementById( "form_products_id" ).value = products_id;
	document.getElementById( "form_action" ).value = action;
	var form_action = "/?action=" + action + "&products_id=" + products_id;
	var form_obj = document.getElementById( "popup_form" );
	form_obj.setAttribute( "action", form_action );
	form_obj.submit();
}

var curr_row = 1;
function relatedShowMore( max_rows )
{
	var last = curr_row;
	if ( curr_row == max_rows )
	{
		last = max_rows;
		curr_row = 0;
	}	
		
	var next = curr_row + 1;
	document.getElementById( "row_" + last ).style.display = "none";
	document.getElementById( "row_" + next ).style.display = "block";
	curr_row = next;
}

function showExtraInfoCustomer( image, e )
{
	var div = $("gal_popup");
	var posx = 0;
	var posy = 0;
	var popX = 0;
	var popY = 0;
	
	if (e.pageX || e.pageY) 	
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	
	{
		posx = e.clientX; 
		posy = e.clientY;
	}

	var cngY = Math.floor((posy - 125) / 180);
	var cngX = Math.floor(posx / 202);
	
	var top = ((cngY*180) + 100 );
	var left = ((cngX*202) - 75 );
	if(left <0)
	{
		left = 0;
	}
	else if (left > 458)
	{
		left = 458;
	}
	
	if(top > 380)
	{
		top = 380;
	}
	
	div.style.top = top + 'px';
	div.style.left = left + 'px';
	
	var url = '/ajax?ajax_action=get_image_info_customer&image=' + image ;
	
	var myAjax = new Ajax.Request(
		url, 
		{
			method: 'get',
			onComplete: function(data) {
				if(data.responseText.length > 0)
				{
					div.style.display = "block";
					div.innerHTML = data.responseText;
				}
				else
				{
					div.style.display = "none";
				}
			}
		}
	);
}

function getPhotosClients()
{
	var div = $("photos_conatiner");
	var id = $("photos_category").value;
	
	var url = '/ajax?ajax_action=get_photos_clients&category=' + id ;
	
	var myAjax = new Ajax.Request(
		url, 
		{
			method: 'get',
			onComplete: function(data) {
				if(data.responseText.length > 0)
				{
					div.style.display = "block";
					div.innerHTML = data.responseText;
					$("more_pictures_button").style.display = "none";
					
				}
				else
				{
					div.style.display = "none";
				}
			}
		}
	);
}

function showMorePictures()
{
	var url = '/ajax?ajax_action=get_more_photos_clients';
	
	var myAjax = new Ajax.Request(
		url, 
		{
			method: 'get',
			onComplete: function(data) {
				if(data.responseText.length > 0)
				{
					//var inner = $("photos_conatiner").innerHTML;
					
					//inner = inner + data.responseText;
					//alert(inner);
					//$("photos_conatiner").innerHTML = inner;
					
					$("photos_conatiner").insert( {'bottom':data.responseText} );
					
				}
				else
				{
					div.style.display = "none";
				}
			}
		}
	);
}

function showPersonnalisationPopup( productID )
{
	window.open( siteWebPath + 'personnalisation/?product_id=' + productID , '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=600,width=800' );
}

function showInsuranceInfoPopup()
{
	window.open( siteWebPath + 'popup_insurance_info.htm' , '_blank', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0,height=420,width=600' );
}

function buyFromPopupGallery(product_id)
{
	if ( $( 'qty_per_box_' + product_id ) != null)
	{
		$( 'buyqty_' + product_id ).value = $('qty_per_box_' + product_id).value;
		checkForQtyPerBoxAndSubmit(product_id);
	}
	else
	{
		if($( 'buyqty_' + product_id ) != null)
			$( 'buyqty_' + product_id ).value = 1;
		submitBuyFormPopup(product_id);
	}
	
}

function submitBuyFormPopup( product_id )
{
    if ( checkForQtyPerBoxAndSubmit( product_id ) )
        document.getElementById('buy_now_form_' + product_id).submit();
    else
        return false;
        
}
