var path_to_design = '../grafiken/2002/grafik_gross/g_'+design+'.png';

function change_photo_shirt(typ) {
	if(typ) {
		switch(typ) {
			case 'shirt':
				var path_to_product = '../grafiken/2002/produkte/270/'+global_product+global_product_color+'vorne.jpg';
				document.getElementById('lD_main_shirt').src=img_server+'/php/shirtdesigner_graphic.php?reset_zoom_set_middle=True&mode=1&pm=flextransfer&x='+global_x+'&y='+global_y+'&path_product='+path_to_product+'&print_width='+global_print_width+'&pc='+global_product+'&path_print='+path_to_design+'&zoom=100'; 
				document.getElementById('lD_main_shirt_shirt').src=img_server+'/grafiken/2002/sp_2008/product_aktiv_small.jpg'; 
				document.getElementById('lD_main_shirt_catalog').src=img_server+'/grafiken/2002/sp_2008/photo_passiv_small.jpg'; 
				document.getElementById('lD_main_shirt_design').src=img_server+'/grafiken/2002/sp_2008/zoom_button_passiv_small.jpg';
			break;
			case 'catalog':
				document.getElementById('lD_main_shirt').src=img_server+'/php/startpage_image_check.php?img='+design+'&typ=catalog&size=270'; 
				document.getElementById('lD_main_shirt_shirt').src=img_server+'/grafiken/2002/sp_2008/product_passiv_small.jpg'; 
				document.getElementById('lD_main_shirt_catalog').src=img_server+'/grafiken/2002/sp_2008/photo_aktiv_small.jpg'; 
				document.getElementById('lD_main_shirt_design').src=img_server+'/grafiken/2002/sp_2008/zoom_button_passiv_small.jpg';
			break;
			case 'zoom':
				document.getElementById('lD_main_shirt').src=img_server+'/php/startpage_image_check.php?img='+design+'&typ=design&colorcode='+global_hex_color+'&size=270'; 
				document.getElementById('lD_main_shirt_shirt').src=img_server+'/grafiken/2002/sp_2008/product_passiv_small.jpg'; 
				document.getElementById('lD_main_shirt_catalog').src=img_server+'/grafiken/2002/sp_2008/photo_passiv_small.jpg'; 
				document.getElementById('lD_main_shirt_design').src=img_server+'/grafiken/2002/sp_2008/zoom_button_aktiv_small.jpg';
			break;
		}
	}
	// hide suggest shirt
	document.getElementById('dlp_suggest_shirt').style.display = "none";
	update_designer_link();
}

function change_photo_typ(typ, colorcode) {
	if (typeof colorcode == "undefined") {
		colorcode = false;
	}
	if(typ) {
		switch(typ) {
			case 'woman':
				// set variables
				global_product = 'lara';
				global_product_color = global_default_colorcode_woman;
				global_hex_color=global_default_hex_color_woman;
				global_x = global_x_woman;
				global_y = global_y_woman;
				global_print_width = global_print_width_woman;
				global_category = 'dshirts';
				document.getElementById('lD_men').src=img_server+'/grafiken/2002/sp_2008/lD_men_passiv.jpg';
				document.getElementById('lD_women').src=img_server+'/grafiken/2002/sp_2008/lD_women_aktiv.jpg';
			break;
			default:
				// set variables
				global_product = 'tsj';
				global_product_color=global_default_colorcode_man;
				global_hex_color=global_default_hex_color_man;
				global_x = global_x_man;
				global_y = global_y_man;
				global_print_width = global_print_width_man;
				global_category = 'hshirts';
				document.getElementById('lD_men').src=img_server+'/grafiken/2002/sp_2008/lD_men_aktiv.jpg';
				document.getElementById('lD_women').src=img_server+'/grafiken/2002/sp_2008/lD_women_passiv.jpg';
			break;
		}
		if (colorcode !== false) {
			global_product_color = colorcode;
		}
		var path_to_product = '../grafiken/2002/produkte/270/'+global_product+global_product_color+'vorne.jpg';
		// update session
		getDiv('dlp_product='+global_product+'&product_color='+global_product_color+'&product_category='+global_category+'&hex_color='+global_hex_color+'&shirt_size='+global_size+'&div_style='+global_div_style+'&position_x='+global_x+'&position_y='+global_y+'&print_width='+global_print_width+'&'+sid_string,'ajax_helper',http_server_tld+'/'+language+'/sc_update_session.php');
		// update colors selection
		getDiv('product='+global_product+'&franchisee='+franchisee+'&language='+language+'&product_color='+global_product_color+'&'+sid_string,'possible_colors',http_server_tld+'/'+language+'/design_landing_page_colors.inc.php')
		// update size selection
		getDiv('product='+global_product+'&franchisee='+franchisee+'&color='+global_product_color+'&size_selected='+global_size,'product_sizes',http_server_tld+'/'+language+'/design_landing_page_sizes.inc.php');
		// update category selection
		getDiv("product_category="+global_category+"&"+sid_string, "product_category_selection", http_server_tld+'/'+language+'/design_landing_page_prod_cat.inc.php');
		// update product selection
		getDiv('product_category='+global_category+'&product='+global_product+'&'+sid_string, 'product_selection', http_server_tld+'/'+language+'/design_landing_page_products.inc.php');
		// update buttons color
		document.getElementById('lD_main_shirt').src=img_server+'/php/shirtdesigner_graphic.php?reset_zoom_set_middle=True&mode=1&pm=flextransfer&x='+global_x+'&y='+global_y+'&path_product='+path_to_product+'&print_width='+global_print_width+'&pc='+global_product+'&path_print='+path_to_design+'&zoom=100';
		document.getElementById('lD_main_shirt_shirt').src=img_server+'/grafiken/2002/sp_2008/product_aktiv_small.jpg'; 
		document.getElementById('lD_main_shirt_catalog').src=img_server+'/grafiken/2002/sp_2008/photo_passiv_small.jpg'; 
		document.getElementById('lD_main_shirt_design').src=img_server+'/grafiken/2002/sp_2008/zoom_button_passiv_small.jpg';
		document.getElementById('view_products_for_category').style.display = 'block';
		// calculate price
		calculate_price(global_product,design_color_count,design,global_product_color);
		// hide suggest shirt
		document.getElementById('dlp_suggest_shirt').style.display = "none";
		update_designer_link();
	}
}

function change_photo_color(color,hex) {
	global_product_color = color;
	global_hex_color = hex;
	var path_to_product = '../grafiken/2002/produkte/270/'+global_product+global_product_color+'vorne.jpg';
	getDiv('hex_color='+global_hex_color+'&product_color='+global_product_color+'&'+sid_string,'ajax_helper',http_server_tld+'/'+language+'/sc_update_session.php');
	// update sizes
	getDiv('product='+global_product+'&franchisee='+franchisee+'&color='+global_product_color+'&size_selected='+global_size,'product_sizes',http_server_tld+'/'+language+'/design_landing_page_sizes.inc.php');
	//getDiv('product='+global_product+'&franchisee='+franchisee+'&color='+global_product_color+'&change=sizes&img_server='+img_server+'&size_selected='+global_size,'product_sizes',http_server_tld+'/'+language+'/design_landing_page_update_img.inc.php');
	document.getElementById('lD_main_shirt').src=img_server+'/php/shirtdesigner_graphic.php?reset_zoom_set_middle=True&mode=1&pm=flextransfer&x='+global_x+'&y='+global_y+'&path_product='+path_to_product+'&print_width='+global_print_width+'&pc='+global_product+'&path_print='+path_to_design+'&zoom=100'; 
	document.getElementById('lD_main_shirt_shirt').src=img_server+'/grafiken/2002/sp_2008/product_aktiv_small.jpg'; 
	document.getElementById('lD_main_shirt_catalog').src=img_server+'/grafiken/2002/sp_2008/photo_passiv_small.jpg'; 
	document.getElementById('lD_main_shirt_design').src=img_server+'/grafiken/2002/sp_2008/zoom_button_passiv_small.jpg';
	// hide suggest shirt
	document.getElementById('dlp_suggest_shirt').style.display = "none";
	update_designer_link();
}

function get_info_div(mode) {
	getDiv('mode='+mode+'&color='+global_product_color+'&product_code='+global_product+'&'+sid_string, 'info-div', http_server_tld+'/shop/'+language+'/static/size_table_2009.php');
	// hide suggest shirt
	document.getElementById('dlp_suggest_shirt').style.display = "none";
}

function go_to_designer() {
	self.location.href=http_server_tld+'/shop/index.php?set_vorne_grafik=True&grafik='+design+'&produkt='+global_product+'&farbe='+global_product_color+'&neue_grafik=vorne&vorne_print_method=flextransfer&design_details=1&'+sid_string;
	//self.location.href=http_server_tld+'/designer?'+sid_string;
}

function strtolower( str ) {
  return (str+'').toLowerCase();
}

// update size to session
function update_size(what) {
	document.getElementById('add_item_to_cart').style.display = 'none';
	if(document.getElementById('please_select_your_size')) {
		document.getElementById('please_select_your_size').style.display = 'none';
	}
	if(what) {
		global_size = what;
		getDiv('shirt_size='+what+'&'+sid_string,'ajax_helper',http_server_tld+'/'+language+'/sc_update_session.php');
		// calculate price
		calculate_price(global_product,design_color_count,design,global_product_color);
	}
}

// change size color onmouseover/out
function change_size_img() {	
	for(i=0;i<sizes.length;i++) {
		var image = document.getElementById(sizes[i]);
		if(image) {
			if(global_size!=sizes[i]) {			
				image.src=img_server+'/grafiken/2002/sp_2008/lD_size_'+strtolower(sizes[i])+'_passiv.jpg';
			}
		}
	}
}

function update_product_category(category,typ) {
	// set variables
	global_category = category;
	global_div_style = 'block';
	document.getElementById('view_products_for_category').style.display = 'block';
	document.getElementById('add_item_to_cart').style.display = 'none';
	// update category selection
	getDiv("product_category="+global_category+"&"+sid_string, "product_category_selection", http_server_tld+'/'+language+'/design_landing_page_prod_cat.inc.php');
	if(typ!=1) {
		// update product selection
		getDiv("product_category="+global_category+"&product="+global_product+"&"+sid_string, "product_selection", http_server_tld+'/'+language+'/design_landing_page_products.inc.php');
	}
	if(global_category=='dshirts') {
		document.getElementById('lD_men').src=img_server+'/grafiken/2002/sp_2008/lD_men_passiv.jpg';
		document.getElementById('lD_women').src=img_server+'/grafiken/2002/sp_2008/lD_women_aktiv.jpg';
	}
	else if(global_category=='hshirts') {
		document.getElementById('lD_men').src=img_server+'/grafiken/2002/sp_2008/lD_men_aktiv.jpg';
		document.getElementById('lD_women').src=img_server+'/grafiken/2002/sp_2008/lD_women_passiv.jpg';
	} else {
		document.getElementById('lD_men').src=img_server+'/grafiken/2002/sp_2008/lD_men_passiv.jpg';
		document.getElementById('lD_women').src=img_server+'/grafiken/2002/sp_2008/lD_women_passiv.jpg';
	}
	// hide suggest shirt
	document.getElementById('dlp_suggest_shirt').style.display = "none";
}

function update_product_selection(product,product_color,hex_color,x,y,print_width) {
	if (coop_products) {
		if (document.getElementById('lD_men')) {
			if (product == 'tsj') {
				document.getElementById('lD_men').src=img_server+'/grafiken/2002/sp_2008/lD_men_aktiv.jpg';
			} else {
				document.getElementById('lD_men').src=img_server+'/grafiken/2002/sp_2008/lD_men_passiv.jpg';
			}
		}
		if (document.getElementById('lD_women')) {
			if (product == 'lara') {
				document.getElementById('lD_women').src=img_server+'/grafiken/2002/sp_2008/lD_women_aktiv.jpg';
			} else {
				document.getElementById('lD_women').src=img_server+'/grafiken/2002/sp_2008/lD_women_passiv.jpg';
			}
		}
	}
	// set variables
	global_product = product;
	global_product_color = product_color;
	global_hex_color = hex_color;
	global_x = x;
	global_y = y;
	global_print_width = print_width;
	var path_to_product = '../grafiken/2002/produkte/270/'+global_product+global_product_color+'vorne.jpg';
	document.getElementById('view_products_for_category').style.display = 'block';
	document.getElementById('add_item_to_cart').style.display = 'none';
	// update product selection
	getDiv("product_category="+global_category+"&product="+global_product+"&"+sid_string, "product_selection", http_server_tld+'/'+language+'/design_landing_page_products.inc.php');
	// change main photo
	document.getElementById('lD_main_shirt').src=img_server+'/php/shirtdesigner_graphic.php?reset_zoom_set_middle=True&mode=1&pm=flextransfer&x='+global_x+'&y='+global_y+'&path_product='+path_to_product+'&print_width='+global_print_width+'&pc='+global_product+'&path_print='+path_to_design+'&zoom=100'; 
	// change buttons color
	document.getElementById('lD_main_shirt_shirt').src=img_server+'/grafiken/2002/sp_2008/product_aktiv_small.jpg'; 
	document.getElementById('lD_main_shirt_catalog').src=img_server+'/grafiken/2002/sp_2008/photo_passiv_small.jpg'; 
	document.getElementById('lD_main_shirt_design').src=img_server+'/grafiken/2002/sp_2008/zoom_button_passiv_small.jpg';
	// update colors selection
	getDiv('product='+global_product+'&franchisee='+franchisee+'&language='+language+'&product_color='+product_color+'&'+sid_string,'possible_colors',http_server_tld+'/'+language+'/design_landing_page_colors.inc.php')
	// update size selection
	getDiv('product='+global_product+'&franchisee='+franchisee+'&color='+global_product_color+'&size_selected='+global_size+'&'+sid_string,'product_sizes',http_server_tld+'/'+language+'/design_landing_page_sizes.inc.php');
	// update session
	getDiv('dlp_product='+global_product+'&product_color='+global_product_color+'&product_category='+global_category+'&hex_color='+global_hex_color+'&shirt_size='+global_size+'&div_style='+global_div_style+'&position_x='+global_x+'&position_y='+global_y+'&print_width='+global_print_width+'&'+sid_string,'ajax_helper',http_server_tld+'/'+language+'/sc_update_session.php');
	// calculate price
	calculate_price(global_product,design_color_count,design,product_color);
	// hide suggest shirt
	document.getElementById('dlp_suggest_shirt').style.display = "none";
	update_designer_link();
}

function calculate_price(product,colorcount,design_id,product_color) {
	getDiv('product='+product+'&product_color='+product_color+'&colorcount='+colorcount+'&design='+design_id+"&"+sid_string,'dlp_shopping_cart',http_server_tld+'/'+language+'/design_landing_page_price.inc.php');
}

/** add remove favorites **/
function designer_favorites(design,typ) {
	document.getElementById('add_item_to_cart').style.display="block";
	getDiv("design_id="+design+"&designer_favorites_typ="+typ+"&colorcode="+global_hex_color+"&"+sid_string, "add_to_favorites", http_server_tld+"/"+language+"/design_landing_page_favorites.inc.php");
	// hide suggest shirt
	document.getElementById('dlp_suggest_shirt').style.display = "none";
}

/** update shirts qty **/
function update_shirts_qty() {
	var el = document.getElementById('lDesigner_quantity');
	if(el) {
		getDiv("shirts_qty="+el.value+"&"+sid_string,"ajax_helper",http_server_tld+'/'+language+'/sc_update_session.php');
	}
}

/** add item to cart **/
function add_item_to_cart() {
	document.getElementById('add_item_to_cart').style.display="none";
	var shirts_qty = document.getElementById('lDesigner_quantity').value;
	getDiv("shirts_qty="+shirts_qty+"&shirt_size="+global_size+"&product_color="+global_product_color+"&dlp_product="+global_product+"&"+sid_string,'dlp_shopping_cart',http_server_tld+'/'+language+'/design_landing_page_add_to_cart.inc.php');
	// hide suggest shirt
	document.getElementById('dlp_suggest_shirt').style.display = "none";
}

/** update td color content if selected **/
function  update_td_content(id) {
	if(id) {
		document.getElementById(id).style.display = "block";
		var el = document.getElementById('color_selected').value;
		if(el) {
			document.getElementById(el).style.display = "none";
		}
		document.getElementById('color_selected').value = id;
		
		// calculate price
		calculate_price(global_product,design_color_count,design,global_product_color);
	}
}

function update_designer_link() {
	var obj = document.getElementById('designer_link');
	if (obj) {
		var href = obj.href.substr(0,obj.href.indexOf('?'));
		href += "?grafik="+design+"&neue_grafik=vorne&produkt="+global_product+"&farbe="+global_product_color+"&vorne_print_method=flextransfer&design_details=1&"+sid_string;
		obj.href=href;
	}
}