var fixable_png_array = new Array();
function add_png_to_fix(class_name)
{
	fixable_png_array.push(class_name);
}
function png_fix()
{
	if (!(/MSIE/.test(navigator.userAgent))){ 
		for (i=0;i<fixable_png_array.length;i++) $('.'+fixable_png_array[i]).attr('class',fixable_png_array[i]+'_FF');		
	}
}
function isValidEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".")+1 == email.length) {  // . must not be the last character
	return false;
    }
    return true;
	}
function allValidChars(email) {
	  var parsed = true;
	  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
	  for (var i=0; i < email.length; i++) {
		var letter = email.charAt(i).toLowerCase();
		if (validchars.indexOf(letter) != -1)
		  continue;
		parsed = false;
		break;
	  }
	  return parsed;
	}
	
function reload_contact_form()
{	
	$('#inner_box').load('jax/kontaktformular_load.jax.php', $('#form1').serializeArray()); 
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
function recToFriend(page, obj)
{
var p = findPos(obj);
$('#actionBox').css("top",p[1]-330+"px");
$('#actionBox').css("left",p[0]+"px");
$('#actionBox').css('display', 'block');
$('#actionBox').load('jax/tellToFriend.jax.php', { 'page':page}); 
}
function printPage(print_page){
	popup = window.open( print_page, 'print', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=yes,width=' + '740' + ', height=' + '900'  );
}
function modify_width (wid)
{
	$('#main_image_div').css('width',wid+'px');
	txtwidth = 490 - wid;
	$('#txt_div').css ('width', txtwidth+'px');
}
function select_region(r)
{
	if ($('#step_2').css('display') == 'none') { $('#step_2').show("slide", {direction:"up"}, 800,function(){});}
	$('#bezirk').val(r);
	quick_search();
}
function quick_search()
{
	$('#search_results').load('jax/search_after_region.jax.php', $('#search_form').serializeArray(), function(){ $('#step_2').css('display','block');}); 	
}
function show_select(field,obj,id1, id2) {	
	var p = findPos(obj);
	$('#zip_codes').css('top',p[1]+19+'px');
	$('#zip_codes').css('left',p[0]+'px');
	code_var = field.value;
	$('#zip_codes').load('jax/import_zipcode.jax.php', {code: code_var, id1: id1, id2 : id2}); 
	$('#zip_codes').css('display','block');
}
function import_place(code,place,id1,id2)
{
	$('#'+id1).attr("value",code);
	$('#'+id2).attr("value",place);
	if (id1 == 'zip') quick_search()
}
function import_place_edit(code,place)
{
	$('#zip').attr("value",code);
	$('#city').attr("value",place);
	quick_search()
}

var index_fields = 4;
function add_fields()
{
	$('#products_fields_container').append( "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"515\" class=\"prod_table\"><tr><td width=\"47\"><input type=\"text\" id=\"nr_of_prod"+index_fields+"\" class=\"input\" value=\""+nr_var+"\" name=\"nr_of_prod[]\" style=\"width:45px;padding:0px; margin:0px;\" onkeyup=\"number_change("+index_fields+",$('#nr_of_prod"+index_fields+"').val())\"/></td><td width=\"10\">&nbsp;</td><td width=\"250\"><select name=\"product[]\" id=\"product"+index_fields+"\" class=\"input_select\" style=\"width:248px;padding:0px; margin:0px; line-height:100%\" onchange=\"prod_change("+index_fields+",$('#product"+index_fields+" :selected').val())\"><option value=''>-&nbsp;"+prod_var+"&nbsp;-</option>"+prod_op_var+"</select></td><td width=\"10\">&nbsp;</td><td width=\"123\"><select name=\"color[]\" id=\"color"+index_fields+"\" class=\"input_select\" style=\"width:121px; padding:0px; margin:0px;\" onchange=\"color_change("+index_fields+",$('#color"+index_fields+" :selected').val())\"><option value=''>-&nbsp;"+color_var+"&nbsp;-</option>"+color_op_var+"</select></td><td width=\"10\">&nbsp;</td><td width=\"65\" align=\"right\"><select name=\"size[]\" id=\"size"+index_fields+"\" class=\"input_select\" style=\"width:63px;padding:0px; margin:0px;\" onchange=\"size_change("+index_fields+",$('#size"+index_fields+" :selected').val())\"><option value=''>"+size_var+"</option>"+size_op_var+"</select></td></tr></table>" );
	index_fields++;
	//alert (index_fields);
}

function prod_change(ind, pval)
{
		//alert (ind+" "+pval);
		$('#jax_box').load('jax/change_prod.jax.php', {ind: ind, pval: pval}); 
}

function color_change(ind, cval)
{
		$('#jax_box').load('jax/change_color.jax.php', {ind: ind, cval: cval}); 
}

function size_change(ind, sval)
{
		$('#jax_box').load('jax/change_size.jax.php', {ind: ind, sval: sval}); 
}

function number_change(ind, nval)
{
		$('#jax_box').load('jax/change_number.jax.php', {ind: ind, nval: nval}); 
}

function read_session_data()
{
	$('#jax_box').load('jax/read_session_data.jax.php'); 
}