function try_alert(text) {
	alert(text);
}

function switch_pict(id_name, pict_name) {
	var img_id = document.getElementById(id_name);
	
	img_id.src = pict_name;
}

function zoom_pict(img_id, img_name) {
	if (window.innerWidth) {
		var screen_width = window.innerWidth;
		var screen_height = window.innerHeight;
	}	else if (document.all) {
		var screen_width = document.body.clientWidth;
		var screen_height = document.body.clientHeight;
	}
	var zoom_area = document.getElementById('zoom_area');
	zoom_area.style.top = (screen_height/3);
	zoom_area.style.left = (screen_width/2)-(275);
	
	var zoomed_img = document.getElementById('zoomed_img');
	zoomed_img.src = 'images/'+img_name;
	zoom_area.style.display = 'inline';
}

function zoom_pict_ajax (img_id) {
	if (window.innerWidth) {
		var screen_width = window.innerWidth;
		var screen_height = window.innerHeight;
	}	else if (document.all) {
		var screen_width = document.body.clientWidth;
		var screen_height = document.body.clientHeight;
	}
	var zoom_area = document.getElementById('zoom_area_'+img_id);
	zoom_area.style.top = (screen_height/3);
	zoom_area.style.left = (screen_width/2)-(275);
  
  zoom_area.style.display = 'inline';
  	
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	var xml = new JKL.ParseXML("/LifeClothingStore/popup_image.php?products_id="+img_id+"&language_id=1&ajax=1");
	var data = xml.parse();
	var results = data['results'];
	if (results!=undefined) {
		var detail_area = document.getElementById('detail_area_'+img_id);
		var detail_text = '<ul>';
		for (var i=0; i<results.attribute.length;i++) {
			var att_name = results.attribute[i].att_name;
			var att_text = '';
			//for (var j=0;j<results.attribute[i].att_spec.att_item.length;j++) {
			if (att_text!='') att_text+= ', ';
			att_text+= results.attribute[i].att_spec.att_item;
			//}
			if (att_text==undefined) {
				att_text+= results.attribute.att_spec.att_item;
			}
			detail_text += '<li style="margin-top:3px;">'+att_name+' Available: '+att_text+'</li>';
		}
		if (att_name==undefined) {
			var att_name = results.attribute.att_name;
			for (var j=0;j<results.attribute.att_spec.att_item.length;j++) {
				if (att_text!='') att_text+= ', ';
				att_text+= results.attribute.att_spec.att_item[j];
			}
			if (att_text==undefined) {
				att_text+= results.attribute.att_spec.att_item;
			}
			detail_text += '<li style="margin-top:3px;">'+att_name+' Available: '+att_text+'</li>';
		}
		detail_area.innerHTML = detail_text+'</ul>';
	} else {
		prod_popup_close()
	}
	
}

function prod_popup (pid,p_desc,dest_url,chart_url) {
	//alert(chart_url);
	var ghost = document.getElementById('ghost_div');
	var thumbnail = document.getElementById('thumbnail'+pid);
	var position = findPos(thumbnail);
	var left_pos = position[0] - 32;
	var top_pos = position[1] - 45;
	var ghost_desc = document.getElementById('ghost_desc');
	var ghost_zoom = document.getElementById('ghost_zoom');
	var ghost_chart = document.getElementById('ghost_chart');
	ghost.style.left = left_pos;
	ghost.style.top = top_pos;

	var ghost_url = document.getElementById('ghost_url');
	p_desc += "<br><a href='"+dest_url+"'>Read More</a>";
	ghost_desc.innerHTML = p_desc;
	//ghost_url.href = dest_url;
	ghost_zoom.href = 'javascript:prod_popup_close();zoom_pict_ajax('+pid+')';
	ghost_chart.href = chart_url;
	
	ghost.style.display = 'block';
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
					curleft += obj.offsetLeft;
					curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
		return [curleft,curtop];
	}
}



function prod_popup_close() {
	var ghost = document.getElementById('ghost_div');
	ghost.style.display = 'none';
}

function close_zoom(pid) {
	if (pid==undefined) { 
		var zoom_area = document.getElementById('zoom_area');
	} else {
		var zoom_area = document.getElementById('zoom_area_'+pid);
	}
	zoom_area.style.display = 'none';
}

function switch_img(image_sel, pid) {
	if (pid==undefined) {
		var zoomed_img = document.getElementById('zoomed_img');
	} else {
		var zoomed_img = document.getElementById('zoomed_img_'+pid);
	}
	zoomed_img.src = image_sel;
}

function bfriday () {
	window.open("bfriday.html", "", "location=0,status=0,resizable=0,scrollbars=0,width=500,height=200");
}

function return_policy() {
	window.open("rpolicy.html", "", "location=0,status=0,resizable=0,scrollbars=1,width=500,height=700");
}

function holiday () {
	window.open("holiday.html", "", "location=0,status=0,resizable=0,scrollbars=0,width=500,height=200");
}

function fshipping () {
	window.open("free_shipping.html", "", "location=0,status=0,resizable=0,scrollbars=0,width=500,height=200");
}

function coupons() {
	window.open("coupons.html", "", "location=0,status=0,resizable=0,scrollbars=0,width=500,height=200");
}





