/*function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
};

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
};

function eraseCookie(name) {
	createCookie(name,"",-1);
};*/

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == '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 );
  }
  return rv;
}
function checkVersion()
{
  var msg = "You're not using Internet Explorer.";
  var ver = getInternetExplorerVersion();

  if ( ver > -1 )
  {
    if ( ver >= 8.0 ) 
      msg = "You're using a recent copy of Internet Explorer."
    else
      msg = "You should upgrade your copy of Internet Explorer.";
  }
  alert( msg );
};

function htmlentities(string, quote_style) {
	// Convert all applicable characters to HTML entities  
	// 
	// version: 1009.2513
	// discuss at: http://phpjs.org/functions/htmlentities    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: nobbler
	// +    tweaked by: Jack
	// +   bugfixed by: Onno Marsman    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +    bugfixed by: Brett Zamir (http://brett-zamir.me)
	// +      input by: Ratheous
	// -    depends on: get_html_translation_table
	// *     example 1: htmlentities('Kevin & van Zonneveld');    // *     returns 1: 'Kevin &amp; van Zonneveld'
	// *     example 2: htmlentities("foo'bar","ENT_QUOTES");
	// *     returns 2: 'foo&#039;bar'
	var hash_map = {}, symbol = '', tmp_str = '', entity = '';
	tmp_str = string.toString();    
	if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
		return false;
	}
	hash_map["'"] = '&#039;';    for (symbol in hash_map) {
		entity = hash_map[symbol];
		tmp_str = tmp_str.split(symbol).join(entity);
	}
		return tmp_str;
}


var MD5 = function (string) {

   function RotateLeft(lValue, iShiftBits) {
           return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
   }

   function AddUnsigned(lX,lY) {
           var lX4,lY4,lX8,lY8,lResult;
           lX8 = (lX & 0x80000000);
           lY8 = (lY & 0x80000000);
           lX4 = (lX & 0x40000000);
           lY4 = (lY & 0x40000000);
           lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
           if (lX4 & lY4) {
                   return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
           }
           if (lX4 | lY4) {
                   if (lResult & 0x40000000) {
                           return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
                   } else {
                           return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
                   }
           } else {
                   return (lResult ^ lX8 ^ lY8);
           }
   }

   function F(x,y,z) { return (x & y) | ((~x) & z); }
   function G(x,y,z) { return (x & z) | (y & (~z)); }
   function H(x,y,z) { return (x ^ y ^ z); }
   function I(x,y,z) { return (y ^ (x | (~z))); }

   function FF(a,b,c,d,x,s,ac) {
           a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
           return AddUnsigned(RotateLeft(a, s), b);
   };

   function GG(a,b,c,d,x,s,ac) {
           a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
           return AddUnsigned(RotateLeft(a, s), b);
   };

   function HH(a,b,c,d,x,s,ac) {
           a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
           return AddUnsigned(RotateLeft(a, s), b);
   };

   function II(a,b,c,d,x,s,ac) {
           a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
           return AddUnsigned(RotateLeft(a, s), b);
   };

   function ConvertToWordArray(string) {
           var lWordCount;
           var lMessageLength = string.length;
           var lNumberOfWords_temp1=lMessageLength + 8;
           var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
           var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
           var lWordArray=Array(lNumberOfWords-1);
           var lBytePosition = 0;
           var lByteCount = 0;
           while ( lByteCount < lMessageLength ) {
                   lWordCount = (lByteCount-(lByteCount % 4))/4;
                   lBytePosition = (lByteCount % 4)*8;
                   lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
                   lByteCount++;
           }
           lWordCount = (lByteCount-(lByteCount % 4))/4;
           lBytePosition = (lByteCount % 4)*8;
           lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
           lWordArray[lNumberOfWords-2] = lMessageLength<<3;
           lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
           return lWordArray;
   };

   function WordToHex(lValue) {
           var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
           for (lCount = 0;lCount<=3;lCount++) {
                   lByte = (lValue>>>(lCount*8)) & 255;
                   WordToHexValue_temp = "0" + lByte.toString(16);
                   WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
           }
           return WordToHexValue;
   };

   function Utf8Encode(string) {
           string = string.replace(/\r\n/g,"\n");
           var utftext = "";

           for (var n = 0; n < string.length; n++) {

                   var c = string.charCodeAt(n);

                   if (c < 128) {
                           utftext += String.fromCharCode(c);
                   }
                   else if((c > 127) && (c < 2048)) {
                           utftext += String.fromCharCode((c >> 6) | 192);
                           utftext += String.fromCharCode((c & 63) | 128);
                   }
                   else {
                           utftext += String.fromCharCode((c >> 12) | 224);
                           utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                           utftext += String.fromCharCode((c & 63) | 128);
                   }

           }

           return utftext;
   };

   var x=Array();
   var k,AA,BB,CC,DD,a,b,c,d;
   var S11=7, S12=12, S13=17, S14=22;
   var S21=5, S22=9 , S23=14, S24=20;
   var S31=4, S32=11, S33=16, S34=23;
   var S41=6, S42=10, S43=15, S44=21;

   string = Utf8Encode(string);

   x = ConvertToWordArray(string);

   a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;

   for (k=0;k<x.length;k+=16) {
           AA=a; BB=b; CC=c; DD=d;
           a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
           d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
           c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
           b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
           a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
           d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
           c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
           b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
           a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
           d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
           c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
           b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
           a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
           d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
           c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
           b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
           a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
           d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
           c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
           b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
           a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
           d=GG(d,a,b,c,x[k+10],S22,0x2441453);
           c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
           b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
           a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
           d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
           c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
           b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
           a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
           d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
           c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
           b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
           a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
           d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
           c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
           b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
           a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
           d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
           c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
           b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
           a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
           d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
           c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
           b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
           a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
           d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
           c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
           b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
           a=II(a,b,c,d,x[k+0], S41,0xF4292244);
           d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
           c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
           b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
           a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
           d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
           c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
           b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
           a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
           d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
           c=II(c,d,a,b,x[k+6], S43,0xA3014314);
           b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
           a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
           d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
           c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
           b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
           a=AddUnsigned(a,AA);
           b=AddUnsigned(b,BB);
           c=AddUnsigned(c,CC);
           d=AddUnsigned(d,DD);
                }

        var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);

        return temp.toLowerCase();
}


function get_html_translation_table (table, quote_style) {
    // Returns the internal translation table used by htmlspecialchars and htmlentities  
    // 
    // version: 1009.2513
    // discuss at: http://phpjs.org/functions/get_html_translation_table    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: noname
    // +   bugfixed by: Alex
    // +   bugfixed by: Marco    // +   bugfixed by: madipta
    // +   improved by: KELAN
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Frank Forte    // +   bugfixed by: T.Wild
    // +      input by: Ratheous
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js, meaning the constants are not
    // %          note: real constants, but strings instead. Integers are also supported if someone    // %          note: chooses to create the constants themselves.
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
    
    var entities = {}, hash_map = {}, decimal = 0, symbol = '';    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';    
	constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';
     useTable       = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
    useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
 
    if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
        throw new Error("Table: "+useTable+' not supported');        // return false;
    }
 
    entities['38'] = '&amp;';
    if (useTable === 'HTML_ENTITIES') {        
		entities['160'] = '&nbsp;';
        entities['161'] = '&iexcl;';
        entities['162'] = '&cent;';
        entities['163'] = '&pound;';
        entities['164'] = '&curren;';        
		entities['165'] = '&yen;';
        entities['166'] = '&brvbar;';
        entities['167'] = '&sect;';
        entities['168'] = '&uml;';
        entities['169'] = '&copy;';        
		entities['170'] = '&ordf;';
        entities['171'] = '&laquo;';
        entities['172'] = '&not;';
        entities['173'] = '&shy;';
        entities['174'] = '&reg;';        
		entities['175'] = '&macr;';
        entities['176'] = '&deg;';
        entities['177'] = '&plusmn;';
        entities['178'] = '&sup2;';
        entities['179'] = '&sup3;';        
		entities['180'] = '&acute;';
        entities['181'] = '&micro;';
        entities['182'] = '&para;';
        entities['183'] = '&middot;';
        entities['184'] = '&cedil;';        
		entities['185'] = '&sup1;';
        entities['186'] = '&ordm;';
        entities['187'] = '&raquo;';
        entities['188'] = '&frac14;';
        entities['189'] = '&frac12;';        
		entities['190'] = '&frac34;';
        entities['191'] = '&iquest;';
        entities['192'] = '&Agrave;';
        entities['193'] = '&Aacute;';
        entities['194'] = '&Acirc;';        
		entities['195'] = '&Atilde;';
        entities['196'] = '&Auml;';
        entities['197'] = '&Aring;';
        entities['198'] = '&AElig;';
        entities['199'] = '&Ccedil;';        
		entities['200'] = '&Egrave;';
        entities['201'] = '&Eacute;';
        entities['202'] = '&Ecirc;';
        entities['203'] = '&Euml;';
        entities['204'] = '&Igrave;';        
		entities['205'] = '&Iacute;';
        entities['206'] = '&Icirc;';
        entities['207'] = '&Iuml;';
        entities['208'] = '&ETH;';
        entities['209'] = '&Ntilde;';        
		entities['210'] = '&Ograve;';
        entities['211'] = '&Oacute;';
        entities['212'] = '&Ocirc;';
        entities['213'] = '&Otilde;';
        entities['214'] = '&Ouml;';        
		entities['215'] = '&times;';
        entities['216'] = '&Oslash;';
        entities['217'] = '&Ugrave;';
        entities['218'] = '&Uacute;';
        entities['219'] = '&Ucirc;';        
		entities['220'] = '&Uuml;';
        entities['221'] = '&Yacute;';
        entities['222'] = '&THORN;';
        entities['223'] = '&szlig;';
        entities['224'] = '&agrave;';        
		entities['225'] = '&aacute;';
        entities['226'] = '&acirc;';
        entities['227'] = '&atilde;';
        entities['228'] = '&auml;';
        entities['229'] = '&aring;';        
		entities['230'] = '&aelig;';
        entities['231'] = '&ccedil;';
        entities['232'] = '&egrave;';
        entities['233'] = '&eacute;';
        entities['234'] = '&ecirc;';        
		entities['235'] = '&euml;';
        entities['236'] = '&igrave;';
        entities['237'] = '&iacute;';
        entities['238'] = '&icirc;';
        entities['239'] = '&iuml;';        
		entities['240'] = '&eth;';
        entities['241'] = '&ntilde;';
        entities['242'] = '&ograve;';
        entities['243'] = '&oacute;';
        entities['244'] = '&ocirc;';        
		entities['245'] = '&otilde;';
        entities['246'] = '&ouml;';
        entities['247'] = '&divide;';
        entities['248'] = '&oslash;';
        entities['249'] = '&ugrave;';        
		entities['250'] = '&uacute;';
        entities['251'] = '&ucirc;';
        entities['252'] = '&uuml;';
        entities['253'] = '&yacute;';
        entities['254'] = '&thorn;';        
		entities['255'] = '&yuml;';
    }
 
    if (useQuoteStyle !== 'ENT_NOQUOTES') {
        entities['34'] = '&quot;';    }
    if (useQuoteStyle === 'ENT_QUOTES') {
        entities['39'] = '&#39;';
    }
    entities['60'] = '&lt;';    
	entities['62'] = '&gt;';
 
 
    // ascii decimals to real symbols
    for (decimal in entities) {        symbol = String.fromCharCode(decimal);
        hash_map[symbol] = entities[decimal];
    }
    
    return hash_map;
}


// JavaScript Document

function ErrorMessage(message)
{
	jAlert('<table><tr><td width="48"><img src="img/futurenet-theme/error.png"></td><td width="20"></td><td><strong>Une erreur s\'est produite.<br /><br /></strong>'+message+'</td></tr></table>', ['Erreur']);
}

function OkMessage(title, message)
{
	jAlert('<table><tr><td width="48"><img src="img/futurenet-theme/accept.png"></td><td width="20"></td><td><strong>'+title+'<br /><br /></strong>'+message+'</td></tr></table>', ['Erreur']);
}

function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
} 

function submitadvsearch()
{
    document.forms["advsearch"].submit();
}

function encode() {
 var obj = document.getElementById('dencoder');
 var unencoded = obj.value;
 obj.value = encodeURIComponent(unencoded);
}

function urldecode (str) 
{
    return decodeURIComponent((str + '').replace(/\+/g, '%20'));
}

function SetUpOrder(param, OrderNumber, value, cust)
{
	var cindex = $('#accordion').accordion('option', 'active');
	document.getElementById("GestCommID").innerHTML = '<center><span style="text-align:center; font-size:14px;">Veuillez patienter.</span><br /><img src="img/futurenet-theme/ajax-loader.gif"></center>';
	$('#accordion').accordion("destroy");
	$.get
	(
		'inc/modules/ajax-modules/order_maintenance.ajax.php',
		{param : param, OrderNumber : OrderNumber, value : value, cust: cust},
		function(resp)
		{
			document.getElementById("GestCommID").innerHTML = resp;
			$("#accordion").accordion({ autoHeight: false, collapsible: true, active: false  });
			$('#accordion').accordion('option', 'active', cindex);
		}
	);		  					
}



function order_current_combo(qty)
{
	//var combo_info = document.getElementById("combo_info").value.evalJSON(true);
	var combo_info =  $.evalJSON($("#combo_info").val());
	var Selected_cpu_id;
	var Selected_replacement_parts = [];
	for (var i = 0; i<combo_info.Combo_cpu.length; i++)
	{
		if (document.getElementById("cpu"+combo_info.Combo_cpu[i]).checked)
		{
			Selected_cpu_id = combo_info.Combo_cpu[i];
		}
		
	}
	for (var i = 0; i<combo_info.Combo_replacement_parts.length; i++)
	{
		if (document.getElementById("Opt_Item_"+combo_info.Combo_replacement_parts[i]).checked)
		{
			Selected_replacement_parts.push(combo_info.Combo_replacement_parts[i]);
		}
		
	}
	var PostData = 
	{
		action: 'ADD_COMBO',
		qty: qty,
		Selected_combo_id: combo_info.Combo_id,
		Selected_cpu_id: Selected_cpu_id,
		Selected_combo_replacement_Options: Selected_replacement_parts,
		Selected_acc: $("#Selected_options").val()
	};
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/ajax-cart.php',
		{JSON : PostJson},
		function(resp)
		{	
			UpdateCartPanel();		
			$.gritter.add({
				title: resp.Title,
				text:  resp.Text,
				image:  resp.Img,
				sticky: false, 
				time: 8000,
				class_name: 'my-class',
				before_open: function()
				{

				},
				after_open: function(e)
				{

				},
				before_close: function(e, manual_close)
				{

				},
				after_close: function()
				{

				}
				
			});	
		},
		"json"
	);		  					
}



function UpdateCartPanel()
{
	var PostData = 	{action: 'UPDATE_PANEL'};
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/ajax-cart.php',
		{JSON : PostJson},
		function(resp)
		{	
			$("#CartPanelPrice").html(resp.TotalPrice);
			$('#PanierDivElem').show('highlight');
			//$("#CartPanelTotalItem").innerHTML = "" + json.TotalItems;
		},
		"json"
	);
}

function AddOptionToCombo(option_id)
{
	option_id = option_id+'';
	if ($("#Selected_options").val() != '')
	{
		$CurrentOpt = $.evalJSON($("#Selected_options").val());
	} else var $CurrentOpt = new Array();
	
	if ($CurrentOpt[option_id] != null) 
	{
		$CurrentOpt[option_id] = $CurrentOpt[option_id]+1;
	} else $CurrentOpt[option_id] = 1;
	
	$("#Selected_options").val($.toJSON($CurrentOpt));
	refresh_combo_price();
}

function RemoveOptionFromCombo(option_id)
{
	option_id = option_id+'';
	if ($("#Selected_options").val() != '')
	{
		$CurrentOpt = $.evalJSON($("#Selected_options").val());
	}
	if ($CurrentOpt[option_id] != null)
	{
		$CurrentOpt[option_id] = $CurrentOpt[option_id]-1;
	} else $CurrentOpt[option_id] = null;
	$("#Selected_options").val($.toJSON($CurrentOpt));
	refresh_combo_price();
}

function PrintOptionSection()
{
	//$('#Acc_no_items').show();
	//$('#Accesories_review').html('');	
	var acc_ids = $("#Selected_options").val();
	//var PostData = 	{action: 'GET_ACC', acc_ids : acc_ids};
	//PostJson = $.toJSON(PostData);	
	/*$.ajaxSetup({async:false});*/
	$.post
	(
		'inc/modules/ajax-modules/combo.ajax.php',
		{JSON : acc_ids},
		function(resp)
		{	
			if (resp != 'ERROR')
			{
				//alert(resp);
				$('#Accesories_review').html(resp);
				
			} else return 'ERROR';
		},
		"html"
	); 

}

function RefreshInfoZones()
{
	$('.InfoZone').each(function() 
	{
		$(this).qtip("destroy");
	});
	$('.InfoZone').each(function() 
	{
		var messagename = $(this).data('messagename');
		var DataAl = $(this).data('align');
		if (DataAl == null) varal = 'left'; else varal = DataAl;
		if(($(this).data('messagename') != null) && ($(this).data('messagename') != '')){ var filename = $(this).data('messagename'); } else { return '';}					
		$(this).qtip({
			position:{my: 'top right', at: 'top right', target : $(window)},
			show:{effect: function(offset){$(this).slideDown(100);}},
			hide: { when: { event: 'inactive' }, delay: 500 },
			style: {classes : 'io-content-blue'},
			
			content:{text: 'Loading...', 
					 ajax:{url: 'inc/modules/help/'+messagename+'.html?rdn='+(Math.random()*111) ,type: 'GET', success: function(data, status){this.set('content.text',  data);}}
			}
		});
	});
}


function RefreshCartDiv()
{
	var PostData = 	{action: 'GET_CART_CONTENT'};
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/ajax-cart.php',
		{JSON : PostJson},
		function(resp)
		{	
			document.getElementById("cart_items_section").innerHTML = resp;
			//console.log(resp);
			$('#cart_items_section').html(resp);
			$('.PartHoverZone').each(function() 
			{
				var dta = $(this).data('prod_id');
				if(($(this).data('prod_qty') != null) && ($(this).data('prod_qty') != 0)){ var qty = $(this).data('prod_qty'); } else { var qty= -1;}
				
				$(this).qtip({
					position:{my: 'top right', at: 'top right', target : $(window)},
					show:{effect: function(offset){$(this).slideDown(100);}},
					hide: { when: { event: 'inactive' }, delay: 500 },
					content: {text: 'Loading...', ajax:{url: 'inc/modules/center/mini_prodinfo.php',type: 'GET',data: { product : dta, qty : qty },	success: function(data, status){this.set('content.text',  data);}},
					style: {classes : 'io-content-blue'}
					}
				});
				
			});

		},
		"html"
	);
}

function GetRealtimeCart(reqpart)
{
	var randomnumber=Math.floor(Math.random()*11);
	$.gritter.add({
		title: 'Disponibilité temps réel<br><small>'+reqpart+'</small>',
		text:  '<div id="rt'+randomnumber+'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Veuillez patienter...<br /><img src="img/futurenet-theme/loadbk.gif"></div>',
		image:  'img/futurenet-theme/graph.png',
		sticky: true, 
		time: '',
		class_name: 'my-class',
		after_open: function(e)
		{
			$.get
			(
				'inc/modules/ajax-modules/Realtime-Web-Form.php',
				{part : reqpart},
				function(resp)
				{
					document.getElementById('rt'+randomnumber).innerHTML = resp;
				}
			);
		}		
	});
}

function RemoveFromCart(line_id)
{
	var PostData = 	{	action: 'DELETE_ITEM', ItemNumber: line_id	};
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/ajax-cart.php',
		{JSON : PostJson},
		function(resp){	
			UpdateCartPanel();
			RefreshCartDiv();
			RefreshOrderReview();
			$.gritter.add({
				title: resp.Title,
				text:  resp.Text,
				image:  resp.Img,
				sticky: false, 
				time: 8000,
				class_name: 'my-class'				
			});
		},
		"json"
	);
}

function addslashes (str) {
    return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
}

function AddToCart(prod_id, qty)
{
	var PostData = 
	{
		action: 'ADD',
		ItemNumber: prod_id,
		Qty: qty
	};
	PostJson = $.toJSON(PostData);
	
	$.post
	(
		'inc/modules/ajax-modules/ajax-cart.php',
		{JSON : PostJson},
		function(resp)
		{
			UpdateCartPanel();		
			$.gritter.add({
				title: resp.Title+' ',
				text:  resp.Text+' ',
				image:  resp.Img,
				sticky: false, 
				time: 8000,
				class_name: 'my-class',
				before_open: function()
				{

				},
				after_open: function(e)
				{

				},
				before_close: function(e, manual_close)
				{

				},
				after_close: function()
				{

				}
				
			});
		},
		"json"
	);		  					
}


function InvoicePop(inv_number)
{
	window.open('inc/modules/account-modules/module-getpdf.php?REQ_TYPE=GETPDF&INVOICE_NUMBER='+inv_number);
}

function StatementPop()
{
	window.open('inc/modules/account-modules/module-getstatementpdf.php?REQ_TYPE=GETPDF');
}

function AddOptionToSelect(elementid, name, value, selected)
{
	var seltxt = '';
	{
		if(selected == value) seltxt = ' selected="selected" ';
	}
	
	$('#'+elementid).append('<option value="'+value+'" '+seltxt+'>'+name+'</option>');
}

function RemoveAllOptions(elementid)
{
	$('#'+elementid+' option').remove()
}



function SelectReplacementOption(Item_id, Replace_Id)
{
	$('#SelectedItem'+Item_id).html($('#RepOptCaption'+Replace_Id).html());
	refresh_combo_price();	
}

function SearchCombo(page)
{
	$('#current_page').val(page);
	keyword = '';
	params = $.toJSON($('#tags').serialize());
	var PostData = 	{action: 'SEARCH_COMBO', keyword : keyword, page : page, combo_tag_usage : $('#combo_tag_usage').val(), combo_tag_spec : $('#combo_tag_spec').val(), combo_tag_app : $('#combo_tag_app').val() };
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/combo.ajax.php',
		{JSON : PostJson},
		function(resp)
		{	
			//console.log(resp.params);
			$('#ComboSearchResult').html(resp.formated_result);
			$('#navpage').html(resp.nav);
			//setTimeout('$(".ComboPriceTagContainer").show()',750);
			var i = 350;
			$('.ComboBox').each(function(index) {
				$(this).show("fade", { direction: "right" }, 400);
				i = i+200;
			});
			$(".FirstBtnEn").button({icons: {primary: "ui-icon-arrowthickstop-1-w"},	text: false});
			$(".FirstBtnDis").button({icons: {primary: "ui-icon-arrowthickstop-1-w"},	text: false});
			$(".FirstBtnDis").button( "option", "disabled", true );
			
			$(".LastBtnEn").button({icons: {primary: "ui-icon-arrowthickstop-1-e"},	text: false});
			$(".LastBtnDis").button({icons: {primary: "ui-icon-arrowthickstop-1-e"},	text: false});
			$(".LastBtnDis").button( "option", "disabled", true );
			
			$(".NextBtnEn").button({icons: {primary: "ui-icon-arrowthick-1-e"},	text: false});
			$(".NextBtnDis").button({icons: {primary: "ui-icon-arrowthick-1-e"},	text: false});
			$(".NextBtnDis").button( "option", "disabled", true );
			
			$(".PrevBtnEn").button({icons: {primary: "ui-icon-arrowthick-1-w"},	text: false});
			$(".PrevBtnDis").button({icons: {primary: "ui-icon-arrowthick-1-w"},	text: false});
			$(".PrevBtnDis").button( "option", "disabled", true );
			$('.PageBtn').each(function(index) {
				$(this).button( { label: $(this).data('pageid') } );
			});
			$('.PageBtnDis').each(function(index) {
				$(this).button( { label: $(this).data('pageid') } );
				$(".PageBtnDis").button( { label: $(this).data('pageid') } );
				$(".PageBtnDis").button( "option", "disabled", true );
			});
			$('#combo_tag_usage_list').html(resp.usage);
			$('#combo_tag_application_list').html(resp.app);
			$('#combo_tag_spec_list').html(resp.spec);
		},"json"
	);
}

function GetComboMainForm()
{
	var PostData = 	{action: 'GET_COMBO_MAIN_FORM'};
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/combo.ajax.php',
		{JSON : PostJson},
		function(resp)
		{		
			$('#InsideComboBoxID').hide("fade", { direction: "right" }, fast, function() 
				{
					$("#InsideComboBoxID").html(resp);
					$("#InsideComboBoxID").show("fade", { direction: "left" }, 600);
					setTimeout('refresh_combo_price();',800);
					SearchCombo($('#current_page').val());
				});		
		},"html"
	);	

}


function GetComboInfoBox(combo_id)
{
	$('#InsideComboBoxID').html('<br /><br /><br /><br /><center>Chargement<br /><img src="img/futurenet-theme/ajax-loader.gif"></center><br /><br /><br /><br /><div style="width:631px;"> </div>');
	$.get
	(
		'inc/modules/ajax-modules/combo-info-ajax-module.php',
		{combo_id : combo_id},
		function(resp)
		{
			$('#InsideComboBoxID').hide("fade", { direction: "right" }, 300, function() 
			{
				$("#InsideComboBoxID").html(resp);
				$("#InsideComboBoxID").show("fade", { direction: "left" }, 600);
				setTimeout('refresh_combo_price();',800);
				$('.PartHoverZone').each(function() 
				{
					var dta = $(this).data('prod_id');
					if(($(this).data('prod_qty') != null) && ($(this).data('prod_qty') != 0))
					{ var qty = $(this).data('prod_qty'); } else
					{ var qty= -1;}
					$(this).qtip({
						position:{my: 'top right', at: 'top right', target : $(window)},
						show:{effect: function(offset){$(this).slideDown(100);}},
						hide: { when: { event: 'inactive' }, delay: 500 },
						style: {classes : 'io-content-blue'},
						//show: {event: false},
						content: {text: 'Loading...', ajax:{url: 'inc/modules/center/mini_prodinfo.php',type: 'GET',data: { product : dta, qty : qty },	success: function(data, status){this.set('content.text',  data);}}}
					});
				});
			});			
		}
	); 
}


function ComboTagClick(tagname, tag_type)
{
	var i = 0;
	arra = [];
	
	$('.tag_'+tagname).each(function() {
		
		if ($(this).is(':checked'))
		{
			arra[i] = $(this).data('tag');
			i = i+1;
		}
		
	});
	$('#'+tag_type).val($.toJSON(arra));
}


function refresh_combo_price()
{
	var combo_info =  $.evalJSON($("#combo_info").val());
	var Selected_cpu_id;
	var Selected_replacement_parts = [];	
	for (var i = 0; i<combo_info.Combo_cpu.length; i++)
	{
		if (document.getElementById("cpu"+combo_info.Combo_cpu[i]).checked)
		{
			Selected_cpu_id = combo_info.Combo_cpu[i];
		}		
	}
	for (var i = 0; i<combo_info.Combo_replacement_parts.length; i++)
	{
		if (document.getElementById("Opt_Item_"+combo_info.Combo_replacement_parts[i]).checked)
		{
			Selected_replacement_parts.push(combo_info.Combo_replacement_parts[i]);
		}		
	}
	document.getElementById("Combo_Price_Entier").innerHTML = 'Calcul';
	document.getElementById("Combo_Price_Dec").innerHTML = '';	
	for (var i = 0; i<combo_info.Combo_cpu.length; i++)
	{
		document.getElementById("Cpu_combo_pricing_id_"+combo_info.Combo_cpu[i]).innerHTML = '-<!--<img src="img/futurenet-theme/loading-dollar.gif">-->';				
	}	
	var PostData = 
	{
		Selected_combo_id: combo_info.Combo_id,
		Selected_cpu_id: Selected_cpu_id,
		Selected_combo_replacement_Options: Selected_replacement_parts,
		Selected_acc: $("#Selected_options").val()
	};
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/combo-calculate-pricing-ajax-module.php',
		{JSON : PostJson},
		function(resp)
		{			
			var inte;
			var deci;			
			if (resp.combo_price_raw != "N/A")
			{
				inte = Math.floor(resp.combo_price_raw);
				deci = (Math.floor(resp.combo_price_raw*100))-(inte*100);		
				deci = deci+"";			
				if (deci.length == 0)
				{
					deci = "00";
				} else		
				{
				if (deci.length == 1)
				{
					deci = deci+"0";
				}
				}			
				//var formatedresp;			
				//formatedresp = '<div class="ProductComboPriceTag"> <span class="PriceTextBig" style="color:#333; vertical-align:text-top; text-align:right">'+inte+'</span><span class="PriceTextSmall" style="color:#333; vertical-align:text-top; text-align:right">'+deci+'</span><span class="PriceTextBig" style="color:#333;margin-top:auto; margin-bottom:auto; vertical-align:text-top; text-align:right; font-weight:100;">$</span> </div>';
			} else
			{
				inte = '<img src="img/futurenet-theme/Lock-icon2.png">';
				deci = '';
				formatedresp = '<div width="100%" style="background-image:url(img/futurenet-theme/big-blue-bar.png); -moz-border-radius: 10px 10px 10px 10px; margin-left:5px; margin-right:5px; margin-top:5px; margin-bottom:5px;" ><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td style="font-size:12px; color:white;">Connectez vous pour <br />voir le prix</td></tr></table></div>';
			}
			//PrintOptionSection();
			document.getElementById("Combo_Price_Entier").innerHTML = inte;
			//console.log(inte);
			document.getElementById("Combo_Price_Dec").innerHTML = deci;
				for (var i = 0; i<combo_info.Combo_cpu.length; i++)
				{
					document.getElementById("Cpu_combo_pricing_id_"+combo_info.Combo_cpu[i]).innerHTML = resp.Combo_Cpu_prices[i];				
				}
		},
		"json"
	);		 
	$('#ComboPrice').show("drop", { direction: "right" }, 1500);
	PrintOptionSection();
}

function GetRealtimeSuppliers(reqpart)
{
	document.getElementById("realtime-wraper").innerHTML = '<div><br/><br/><img src="img/futurenet-theme/ajax-loader.gif"><br/><br/><br/></div>';
	// fonctions avant envoi
	$.get
	(
		'inc/modules/ajax-modules/Realtime-Web-Form.php',
		{part : reqpart},
		function(resp)
		{
			document.getElementById("realtime-wraper").innerHTML = resp;
		}
	);		  					
}

function InitializeCartObjects()
{
/*	$('#custom').stepy
	(
		{
			backLabel: ' < Précédent ',
			block: true,
			errorImage: true,
			titleClick: true,
			nextLabel: ' Suivant > ',
			validate: true, 
			finish: false,
			legend: false,
			next: function(index) 
			{
				ValidateCart(index);
			}
		}
	);
	$('fieldset').removeAttr("title");*/
	$('#wizard').smartWizard({
		keyNavigation: false, // Enable/Disable key navigation(left and right keys are used if enabled)
		enableAllSteps: false,  // Enable/Disable all steps on first load
		transitionEffect: 'slideleft', // Effect on navigation, none/fade/slide/slideleft
		enableFinishButton: false, // makes finish button enabled always
		errorSteps:[],    // array of step numbers to highlighting as error steps
		labelNext:' Suivant ', // label for Next button
		labelPrevious:' Précédent ', // label for Previous button
		labelFinish:' Terminer ',  // label for Finish button    	
		onLeaveStep:leaveAStepCallback
	});
	//$('#wizard').smartWizard('transitionEffect',slide);
}

function leaveAStepCallback(obj)
{
	var step_num= obj.attr('rel');
	var PostData = 	{action: 'VALIDATE_CART_SECTION', index: step_num};
	PostJson = $.toJSON(PostData);
	var result = $.ajax({
		  url: "inc/modules/ajax-modules/ajax-cart.php",
		  type: "POST",
		  data: {JSON : PostJson},
		  dataType: "json",
		  async:false
	   }
	).responseText;
	var resp = $.evalJSON(result);
	if (resp.response == 'OK') 
	{ 
		return true;
	} else 
	{ 
		ErrorMessage(resp.response); 
		//$.fn.stepy.step(index-1, '#custom'); 
		return false; 
	}
}

function ValidateCart(index)
{
	var PostData = 	{action: 'VALIDATE_CART_SECTION', index: index};
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/ajax-cart.php',
		{JSON : PostJson},
		function(resp){	
			if (resp.response == 'OK') { return true; } else { ErrorMessage(resp.response); $.fn.stepy.step(index-1, '#custom'); return false; }
			RefreshInfoZones();
		},"json"
	);
}

function RefreshOrderReview()
{
	var PostData = 	{action: 'REVIEW_ORDER'};
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/ajax-cart.php',
		{JSON : PostJson},
		function(resp)
		{	
			//if (resp.response == 'OK') { return true; } else { ErrorMessage(resp.response); $.fn.stepy.step(index-1, '#custom'); return false; }
			//OkMessage('La commande a été envoyé à votre représentant.');
			$('#OrderReview').html(resp.response);
			//myResult = resp.response;
		},"json"
	);	
}

function EditItemQty(DomElement, item_id)
{
	qty = $('#'+DomElement).val();
	var PostData = 	{action: 'EDIT_QTY', qty : qty, item_id : item_id };
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/ajax-cart.php',
		{JSON : PostJson},
		function(resp)
		{	
			if (resp.response == 'OK') 
			{ 
				UpdateCartPanel();
				RefreshCartDiv();
				RefreshOrderReview(); 
			} else 
			{ 
				ErrorMessage(resp.response);
			}

		},"json"
	);	
}

function HighlightConnectBox()
{
	var interval = setInterval
	(
		function() 
		{
			$( "#LBox_1" ).effect( "highlight", 500);
			$( "#LBox_2" ).effect( "highlight", 500);
	    }
		, 1000
	);
}

function StopHighlightConnectBox()
{
	clearTimeout(interval);
}


function PlaceOrder()
{
	var PostData = 	{action: 'PLACE_ORDER'};
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/ajax-cart.php',
		{JSON : PostJson},
		function(resp)
		{	
			//if (resp.response == 'OK') { return true; } else { ErrorMessage(resp.response); $.fn.stepy.step(index-1, '#custom'); return false; }
			OkMessage('Confirmation','La commande a été envoyé à votre représentant.');
			
			setTimeout('window.location.reload()', 3000)
			//myResult = resp.response;
		},"json"
	);
}



function Get_Shipping_Method_Section(method)
{
	var PostData = 	{action: 'GET_SHIPPING_METHOD_SECTION', method: method}; 
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/ajax-cart.php',
		{JSON : PostJson},
		function(resp){	
			$('#ShippingMethodOptions').html(resp.response);
		},
		"json"
	);
}

function Csv(type, val)
{
	var PostData = 	{action: 'CART_SET_VAL', type: type, val: val};
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/ajax-cart.php',
		{JSON : PostJson},
		function(resp){	
			if (resp.error != null)
			{
				$(function () { $.notifyBar({	html: "<table align='center' border=0><tr><td valign='middle'><img src='img/interface/accept.png'></td><td valign='middle'>"+resp.error+"</td></tr></table>",	delay: 2500, animationSpeed: "normal" });});
			} else RefreshOrderReview();
		},
		"json"
	);
}

function Cart_Select_Address(ship_addresses_id)
{
	var PostData = 	{action: 'SELECT_ADDRESS', ship_addresses_id: ship_addresses_id};
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/ajax-cart.php',
		{JSON : PostJson},
		function(resp){	
			//UpdateCartPanel();
			//RefreshCartDiv();	
			$('#AddressPreview').html(resp.response);
		},
		"json"
	);
}

function ResetSearch()
{
	$("#keyword").val(' ');
	$("#InStockQuebec").removeAttr("checked");
	$("#InStockToronto").removeAttr("checked");
	$("#minprice").val('');
	$("#maxprice").val('');
	
	$("#mfg-combobox").multiselect("uncheckAll");
	$("#maincat").multiselect("uncheckAll");
	$("#subcat").multiselect("uncheckAll");
	$("#subsubcat").multiselect("uncheckAll");
	$("#subcat").multiselect("disable");
	$("#subsubcat").multiselect("disable");
}

function SilentPageReload()
{
	var url = document.URL;
	window.location = url;
/*	$.get
	(
		url,
		{bob : 1},
		function(resp)
		{
			$.('#ZBody').html(resp);
		}
	);	*/
}

function ClearEvalForm()
{
	$("#eval_prod_id").val('');
	$("#stars-wrapper2").stars("selectID", -1);
	$("#eval_pros").val('');
	$("#eval_cons").val('');
	$("#eval_comments").val('');
}

function PostEval()
{
	var PostData = 	{action: 'PROD_SET_EVAL', form_eval: $('#form_eval').serialize()};
	PostJson = $.toJSON(PostData);	
	$.post
	(
		'inc/modules/ajax-modules/ajax-cart.php',
		{JSON : PostJson},
		function(resp){	
			if (resp.error == null)
			{
				ClearEvalForm();
				$("#eval-form").dialog( "destroy" );
			} else
			{
				$('#Form_Login_Error').html(resp.error);
			}
		},
		"json"
	);

}

function RemoveUser(ent_login_id)
{
	
	var PostData = 	{action: 'DELETE_USER', ent_login_id : ent_login_id};
	PostJson = $.toJSON(PostData);	
	$( "#dialog-confirm" ).dialog({
		resizable: false,
		height:165,
		modal: true,
		buttons: {
			"Oui": function() 
			{
				$.post
				(
					'inc/modules/ajax-modules/misc.ajax.php',
					{JSON : PostJson},
					function(resp)
					{	
						alert('test');
					},
					"json"
				);
				$( '#dialog-confirm' ).dialog( "close" );
				location.reload();
			},
			"Non": function() 
			{
				$( this ).dialog( "close" );
			}
		}
	});
}

function RemodeAddress(ship_addresses_id)
{
	var PostData = 	{action: 'DELETE_ADDRESS', ship_addresses_id : ship_addresses_id};
	PostJson = $.toJSON(PostData);	
	$( "#dialog-confirm" ).dialog({
		resizable: false,
		height:165,
		modal: true,
		buttons: {
			"Oui": function() 
			{
				$.post
				(
					'inc/modules/ajax-modules/misc.ajax.php',
					{JSON : PostJson},
					function(resp)
					{	
						//console.log(resp);
						if (resp.error == null)
						{
						} else
						{

						}

					},
					"json"
				);
				$( '#dialog-confirm' ).dialog( "close" );
				window.location.reload();
			},
			"Non": function() 
			{
				$( this ).dialog( "close" );
			}
		}
	});
}

function OpenSpecialOfferBox(offer_id)
{
	$('#mini_offer_'+offer_id).hide('fade',function(){$('#prod_offer_'+offer_id).show('fade',1200);});
}

function CloseSpecialOfferBox(offer_id)
{
	$('#prod_offer_'+offer_id).hide('fade',function(){$('#mini_offer_'+offer_id).show('fade',800);});
}

function EvalProduct(prod_id)
{
	ClearEvalForm();
	$("#eval-form").dialog(
    {
        autoOpen: true,
        height: 500,
        width: 650,
        modal: true,
		open: function(event, ui) 
		{
			$("#stars-wrapper2").stars({
				inputType: "select",
				callback: function(ui, type, value){
					$('#eval_rating').val(value);
					$('#eval_prod_id').val(prod_id);
				}
			})
		},
        buttons: {
            "Envoyez votre évaluation": function ()
            {
				PostEval();
				ClearEvalForm();
				$("#eval-form").dialog( "destroy" ); 
            },
            Cancel: function ()
            {
             	ClearEvalForm();
				$("#eval-form").dialog( "destroy" ); 
				  
            }
        },
        close: function ()
        {
			ClearEvalForm();
			$("#eval-form").dialog( "destroy" );
		}
    })
};



/*function AjaxLogin()
{
	$( "#Login_in_Form" ).dialog({
		width : 500,
		modal: true
	});
	if ($('#LBox_2').val() == '48b739e2d293a101340b1457445767d9')
	{
		p = readCookie('sess_p');
	} else p = MD5($('#LBox_2').val());
	$.post
	(
		'inc/modules/ajax-modules/start_session.ajax.php',
		{Login_User: $('#LBox_1').val(), Login_Password: p},
		function(resp)
		{	
			$("#Login_in_Form").dialog('close');
			//console.log(resp);
			if (resp == 'true')
			{
				
				flag = false;
				user = readCookie('sess_u');
				pass = readCookie('sess_p');
				never = readCookie('never.save');
				if ( (never != 'true') && ($('#LBox_2').val() != '48b739e2d293a101340b1457445767d9') )
				{
					$( "#FormRememberPassword" ).dialog({
						width : 500,
						modal: true
					});
				} else window.location.reload();
			}  else
			{				
				if ($('#LBox_2').val() == '48b739e2d293a101340b1457445767d9')
				{
					eraseCookie('sess_u');
					$('#LBox_2').val('');
				};
				
				$( "#Login_failed" ).dialog({
					width : 500,
					modal: true
				});
			}
		},
		"html"
	);	
}

function AjaxLogout()
{
	$.post
	(
		'inc/modules/ajax-modules/start_session.ajax.php',
		{logout: 'logout'},
		function(resp)
		{	

			window.location.reload();
		},
		"html"
	);	
}

function ShowPassResetForm()
{
	$( "#PassResetForm" ).dialog({
		width : 500,
		modal: true
	});	
}

function rst_pass_Validate()
{
	e1 = $("#p1").val();
	e2 = $("#p2").val();
	if ( (e1 == e2) && (e1.length >= 6) )
	{
		$("#e3").val(MD5(e1));
		$("#rst_pass_status_img").attr('src','img/futurenet-theme/accept.png');
		$("#rst_pass_status").html('Cliquez ici pour changer votre mot de passe -> <input type="submit" value="Envoyer">');
	} else
	{
		$("#rst_pass_status_img").attr('src','img/futurenet-theme/error.png');
		$("#rst_pass_status").html('Votre mot de passe doit compter au moins 6 caractères.<br>Les deux mot de passe doivent être identiques.');
	}
}

function SendResetPassRequest(email)
{
	var PostData = 	{email: email};
	PostJson = $.toJSON(PostData);
	$.post
	(
		'inc/modules/ajax-modules/RstPs.ajax.php',
		{JSON : PostJson},
		function(resp)
		{	
			if (resp.error == 'False')
			{
				OkMessage('Opération effectuée','Un courriel contenant les instructions vous a été envoyé.');
				$("#PassResetForm").dialog('close');
			} else 
			{
				ErrorMessage('Ce courriel n\'existe pas dans notre base de donnée.');
				$("#PassResetForm").dialog('close');
			}
		},
		"json"
	);		
}*/
