
function init(){
	toggleMainGroup();
	toggleSecondGroup();
}




/**
 * toggle the main group list 
 * in the add_products.php file
 * @return
 */
function toggleMainGroup(){
	
	if($("#main_box").is(':checked')){
    	$("#tr_new_mg_nl").show();
    	$("#tr_new_mg_fr").show();
    	$("#tr_new_mg_uk").show();
    	$('#mg1').attr("disabled", true); 
    }
    else{
    	$("#tr_new_mg_nl").hide();
    	$("#tr_new_mg_fr").hide();
    	$("#tr_new_mg_uk").hide();
    	$('#mg1').removeAttr("disabled"); 
    }
}

/**
 * toggle the second group list 
 * in the add_products.php file
 * @return
 */
function toggleSecondGroup(){
	
	if($("#sub_main_box").is(':checked')){
    	$("#tr_new_sg_nl").show();
    	$("#tr_new_sg_fr").show();
    	$("#tr_new_sg_uk").show();
    	$('#sg1').attr("disabled", true); 
    }
    else{
    	$("#tr_new_sg_nl").hide();
    	$("#tr_new_sg_fr").hide();
    	$("#tr_new_sg_uk").hide();
    	$('#sg1').removeAttr("disabled"); 
    }
}

function validatePrice(){

	$('#price').bind("change keyup", function() { 
      var price = $(this).val();
      if(price!= "" && !isNumeric(price)){
    	  $("#price_error").empty().hide();
    	  $("#price_error").show().append("<font color='red'>Price should be numeric, no euro symbol no ',-'</font>"); 
      }
      else{
    	  $("#price_error").empty().hide();
      }
  	});
}

function imageAlert(image, title, imageW, imageH){
	
	title = (title!= "") ? title : "Alert";
	$(function() {
		$("#image_dialog").dialog({
			bgiframe: true,
			modal: true,
			title: title,
			autoOpen: false
		});
	});
	var imgContent = '<img src=http://celly.nl/prodImage/'+image+' border="0" width="275" height="275">';
	$("#image_dialog").attr("innerHTML", imgContent);
	$('#image_dialog').dialog('open');
}

function getAlertContent(message, check){
	
	var orgContent = '<p>';
	var icon = (check == true) ? 'ui-icon ui-icon-circle-check' : 'ui-icon ui-icon-alert';
	orgContent += '<span class="'+icon+'" style="float:left; margin:0 7px 50px 0;"></span>';
	orgContent += message;
	orgContent += '</p>';
	//orgContent += '<p>';
	//orgContent += 'Currently using <b>36% of your storage space</b>.';
	//orgContent += '</p>';
	return orgContent;
}

function basicAlert(title, message, height){
	
	var orgContent = getAlertContent(message);
	height = (height!= null) ? height : 140;
	title = (title!= "") ? title : "Alert";
	$(function() {
		$("#dialog").dialog({
			bgiframe: true,
			modal: true,
			height:height,
			resizable: false,
			title: title,
			autoOpen: false
		});
	});
	$("#dialog").attr("innerHTML", orgContent);
	$('#dialog').dialog('open');
}

function advancedAlert(title, message, callBack, arg){

	var orgContent = getAlertContent(message);
	title = (title!= "") ? title : "Alert";
	$(function() {
		$("#dialog").dialog({
			bgiframe: true,
			modal: true,
			resizable: false,
			title: title,
			autoOpen: false,
			buttons: {
				OK: function() {
					$(this).dialog('close');
					if(arg!= null){
						callBack(arg);
					}
					else
						callBack();
				},
				Cancel: function() {
					$(this).dialog('close');
				}
			},
			close: function() {
			}
		});
	});
	$("#dialog").attr("innerHTML", orgContent);
	$('#dialog').dialog('open');
}



