function show_ajax_product_from_ajax(product_id,parent_product_id,field) {
	var first_ajax_select = document.getElementById('first_ajax_select');
	if (first_ajax_select) {
		var selected = first_ajax_select.options[first_ajax_select.selectedIndex].value;
		//alert(field+" will be set to "+selected+'; parent is '+parent_product_id);
		change_div_content('inline_popup_content',"<img src=\"/images/design/loading.gif\">");
		var browserName=navigator.appName; 
		if (browserName=="Microsoft Internet Explorer") {
			var pos = navigator.appVersion.indexOf("MSIE 7.0");
			if (pos>0) {
			} else {
				scroll(0,0);
			}
		}
		//alert('group:'+var_s+' | id:'+var_t+', project_id:'+projects_id);
		half_fade('main',500);
		var futdate = new Date();
		var expdate = futdate.getTime();
		http.open('get', '/shop/ajax_product.php?product_id='+product_id+'&parent_product_id='+parent_product_id+'&'+field+'='+selected+'&unique='+expdate);
		http.onreadystatechange = handleResponse;
		http.send(null);
	} else {
		change_div_content('inline_popup_content',"<img src=\"/images/design/loading.gif\">");
		var browserName=navigator.appName; 
		if (browserName=="Microsoft Internet Explorer") {
			var pos = navigator.appVersion.indexOf("MSIE 7.0");
			if (pos>0) {
			} else {
				scroll(0,0);
			}
		}
		//alert('group:'+var_s+' | id:'+var_t+', project_id:'+projects_id);
		half_fade('main',500);
		var futdate = new Date();
		var expdate = futdate.getTime();
		http.open('get', '/shop/ajax_product.php?product_id='+product_id+'&parent_product_id='+parent_product_id+'&unique='+expdate);
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
	
}

function show_ajax_product(product_id,parent_product_id) {
	change_div_content('inline_popup_content',"<img src=\"/images/design/loading.gif\">");
	var browserName=navigator.appName; 
	if (browserName=="Microsoft Internet Explorer") {
		var pos = navigator.appVersion.indexOf("MSIE 7.0");
		if (pos>0) {
		} else {
			scroll(0,0);
		}
	}
	//alert('group:'+var_s+' | id:'+var_t+', project_id:'+projects_id);
	half_fade('main',500);
	var futdate = new Date();
	var expdate = futdate.getTime();
	http.open('get', '/shop/ajax_product.php?product_id='+product_id+'&parent_product_id='+parent_product_id+'&unique='+expdate);
	http.onreadystatechange = handleResponse;
	http.send(null);
}

function show_ajax_movie(url) {
	change_div_content('inline_popup_content',"<img src=\"/images/design/loading.gif\">");
	var browserName=navigator.appName; 
	if (browserName=="Microsoft Internet Explorer") {
		var pos = navigator.appVersion.indexOf("MSIE 7.0");
		if (pos>0) {
		} else {
			scroll(0,0);
		}
	}
	//alert('group:'+var_s+' | id:'+var_t+', project_id:'+projects_id);
	half_fade('main',500);
	var futdate = new Date();
	var expdate = futdate.getTime();
	http.open('get', '/shop/ajax_movie.php?url='+url+'&unique='+expdate);
	http.onreadystatechange = handleResponseJavascript;
	http.send(null);
}

function show_ajax_embed(product_id) {
	change_div_content('inline_popup_content',"<img src=\"/images/design/loading.gif\">");
	var browserName=navigator.appName; 
	if (browserName=="Microsoft Internet Explorer") {
		var pos = navigator.appVersion.indexOf("MSIE 7.0");
		if (pos>0) {
		} else {
			scroll(0,0);
		}
	}
	//alert('group:'+var_s+' | id:'+var_t+', project_id:'+projects_id);
	half_fade('main',500);
	var futdate = new Date();
	var expdate = futdate.getTime();
	http.open('get', '/shop/ajax_embed.php?product_id='+product_id+'&unique='+expdate);
	http.onreadystatechange = handleResponse;
	http.send(null);
}


function createRequestObject() {
	var ro3;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
			ro3 = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
			ro3 = new XMLHttpRequest();
	}
	return ro3;
}
var http = createRequestObject();

function zoom_image(zoom_image,use_kzoom,image_description) {
	change_div_content('inline_popup_content',"<img src=\"/images/design/loading.gif\">");
	var browserName=navigator.appName; 
	if (browserName=="Microsoft Internet Explorer") {
		var pos = navigator.appVersion.indexOf("MSIE 7.0");
		if (pos>0) {
		} else {
			scroll(0,0);
		}
	}
	//alert('group:'+var_s+' | id:'+var_t+', project_id:'+projects_id);
	half_fade('main',500);
	var futdate = new Date();
	var expdate = futdate.getTime();
	http.open('get', '/shop/ajax_zoom.php?image='+zoom_image+'&use_kzoom='+use_kzoom+'&image_description='+image_description+'&unique='+expdate);
	http.onreadystatechange = handleResponse;
	http.send(null);
}



function handleResponse() {  
	if(http.readyState == 4){
		var response = http.responseText;
		change_div_content('inline_popup_content',response);
		show_fade('inline_popup',500);
	}
}
function handleResponseJavascript() {   
	if(http.readyState == 4) {	
		var response = http.responseText;	
		var a_returned_data = new Array();	
		a_returned_data = response.split('|-|'); 	
		if(response.indexOf('|-|') == -1) { 	
			alert('error, no separators returned in ajax response');	
		  	alert(response);	  
	   	} 
		var html = a_returned_data[0];	
		var javascript = a_returned_data[1]; 
		//alert('change '+'inline_popup_content'+' to '+html);
		document.getElementById('inline_popup_content').innerHTML = html;
		show_fade('inline_popup',500);
		//alert(javascript);
		eval(javascript);
	} //end if readystate=4
} //end handle response function



function show_html(main_html) {
	var html = main_html;
	change_div_content('inline_popup_content',html);
	half_fade('container',500);
	show_fade('inline_popup',500);
}
function change_div_content(id,html) {	
	document.getElementById(id).innerHTML = html;
}

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
		var object = document.getElementById(id).style; 
		object.opacity = (opacity / 100); 
		object.MozOpacity = (opacity / 100); 
		object.KhtmlOpacity = (opacity / 100); 
		object.filter = "alpha(opacity=" + opacity + ")"; 
} 
		
function opacity(id, opacStart, opacEnd, millisec) { 
		if (millisec<499) {
			var steps = 50;
		} else {
			var steps = 100;
		}
		//speed for each frame 
		var speed = Math.round(millisec / steps); 
		var timer = 0; 

		//determine the direction for the blending, if start and end are the same nothing happens 
		if(opacStart > opacEnd) { 
				for(i = opacStart; i >= opacEnd; i--) { 
						setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
						timer++; 
				} 
		} else if(opacStart < opacEnd) { 
				for(i = opacStart; i <= opacEnd; i++) 
						{ 
						setTimeout("changeOpac("+i+",'"+id+"')",(timer * speed)); 
						timer++; 
				} 
		} 
		if (opacEnd == 0) {	
			setTimeout(" hide_div('"+id+"'); ",700);
		}
} 


function toggle_fade(id,millisec) { 
	 //if an element is invisible, make it visible, else make it ivisible 
		if(document.getElementById(id).style.opacity < 1 || document.getElementById(id).style.display != 'block') { 
			if (document.getElementById(id).style.display == 'none') {
				changeOpac(0,id); 
				show_div(id);
			}
			opacity(id, 0, 100, millisec); 
		} else { 
			opacity(id, 100, 0, millisec); 
		} 
} 
function show_fade(id,millisec) { 
 //if an element is invisible, make it visible, else make it ivisible 
	if (document.getElementById(id).style.opacity < 1 || document.getElementById(id).style.display != 'block') {
		if (document.getElementById(id).style.display != 'block') {
			changeOpac(0,id); 
			show_div(id);
		} else {
			//alert('not hidden:'+document.getElementById(id).style.display);
		}
		opacity(id, document.getElementById(id).style.opacity, 100, millisec); 
	} else {
		//alert("didn't get it");
	}
} 
function hide_fade(id,millisec) { 
	if(document.getElementById(id).style.opacity != 0) { 
		opacity(id, 100, 0, millisec); 
	}
} 
function half_fade(id,millisec) { 
	if(document.getElementById(id).style.opacity != 0) { 
		opacity(id, 100, 50, millisec); 
	}
} 
function half_fade_up(id,millisec) { 
	if(document.getElementById(id).style.opacity != 0) { 
		opacity(id, 50, 100, millisec); 
	}
} 