function element_left(el){
	var et = 0;
	while(el){
		et += el.offsetLeft;
		el = el.offsetParent;
	}
	return et;
}

function element_top(el){
	var et = 0;
	while(el){
		et += el.offsetTop;
		el = el.offsetParent;
	}
	return et;
}

function check_mail(str){
	emailEx1 = /[^@]+@[A-Za-z0-9_-]+.[A-Za-z]+/;
	emailEx2 = /[^@]+@[A-Za-z0-9_-]+.[A-Za-z0-9_-]+.[A-Za-z]+/;
	emailEx3 = /[^@]+@[A-Za-z0-9_-]+.[A-Za-z0-9_-]+.[A-Za-z0-9_-]+.[A-Za-z]+/;
	
	if(emailEx1.test(str)) return true;;
	if(emailEx2.test(str)) return true;
	if(emailEx3.test(str)) return true;
	
	return false;
}
var cartAvailable;
function viewCart(f, str) {
	if(!cartAvailable && str) {
		isCartActive = true;
		var cartModule = $('cartSDK');
		cartModule.style.display = 'block';
		cartModule.style.top = element_top(f) + 22 + 'px';
		cartModule.style.left = element_left(f) + 'px';
	} else {
		isCartActive = false;
		var cartModule = $('cartSDK');
		cartModule.style.display = 'none';
	}
}

function saleIconPos(str) {
	var i = 0;
	$$('select.select').each( function(o){ 
		if(o.selectedIndex == 0) {
			if(i++==0)
				o.selectedIndex = (str)? str: 1;
			else
				o.selectedIndex = 1;
		}
		});
		
	/*var s = 'div.personalization-question input[type=radio]';
	var _name;
	i = 0;
	$A($$(s)).each(function(o) {
		if(_name != o.name) {
			if(i++!=0 || o.nextSibling.innerHTML == '<B>Shown as Picture [Default]</B>' || o.nextSibling.innerHTML == '<b>Shown as Picture [Default]</b>')
				o.checked = true;
			_name = o.name;
		}
	});*/
	
}

function chainDesc() {
	
	var s = '.personalization-question-label';
	
	$A($$(s)).each(function(o) {
		
		if( o.innerHTML == 'Chain' ) {
			
			o.innerHTML += '<span id="shippingDesc" style="font-weight:normal;"> [*TOTAL length of the jewelry(charm + chain lenth)]</span>'
		}
	});
}

function viewDetail(obj, f, str) {
	if($(obj)) {
		if(str) {
			$(obj).style.top = element_top(f) + 'px';
			$(obj).style.left = element_left(f) + 20 + 'px';
			$(obj).style.display = 'block';
		} else {
			$(obj).style.display = 'none';
		}
	}
}