function openBannerWindow(url,width,height) {
  var bannerWindow = window.open(url,'','scrollbars=yes,menubar=yes,height='+height+',width='+width+',resizable=yes,toolbar=no,location=yes,status=yes');
}

function isValid(type, str) {
  if (type.toLowerCase() === "email") {
    var reEmail = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    if (!reEmail.test(str)) return false;
    return true;
  } else if (type.toLowerCase() === "telephone") {
    var rePhoneNumber = new RegExp(/^(\+\d)*\s*(\(?\d{3}\)?\s*)*-?\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/);
    if (!rePhoneNumber.test(str)) return false;
    return true;
  }
};

var ecomtitle = document.createElement('p')
ecomtitle.className = 'features'
ecomtitle.innerHTML = "Select Features:"

$(document).ready(function() {
  $("input[type=text][title]").each(function() { $(this).val($(this).attr("title")); if($.trim($(this).val()) == "") $(this).val($(this).attr("title")); $(this).focus(function() { if($(this).val() == $(this).attr("title")) $(this).val(""); }).blur(function() { if($.trim($(this).val()) == "") $(this).val($(this).attr("title")); }); });
  $("a[href][rel*=external]").attr("target", "_blank");
  $(ecomtitle).insertBefore("div.ItemDetailPriceBlock form")
  $('p.itemListingPrice').each(function () {var tempval = $(this).text(); $(this).text('You Pay: ' + tempval);})
});

$(window).load(function(){
	$('a.itemimg img').each(
		function ()
		{
			resizeImage(this)
		})
	$('div.imgcont a img').each(
		function ()
		{
			resizeImage(this)
		}
	);
	$('img.itemImageThumb').each(
		function ()
		{
			resizeImage(this)
		})
	$('#mainImgID').each(
		function ()
		{
			resizeImage(this)
		})
})

function resizeImage(obj)
{
	var obj2 = obj;
	
	if(obj.parentNode.className == '')
	{
		obj = obj.parentNode;
	}

	if(document.defaultView && document.defaultView.getComputedStyle)
	{ // IS MOZILLA BASED BROWSER //
		var objheight = document.defaultView.getComputedStyle(obj.parentNode, '').getPropertyValue("height")
		var objwidth = document.defaultView.getComputedStyle(obj.parentNode, '').getPropertyValue("width")
	} else if(document.uniqueID && obj.parentNode.currentStyle){ 
		var objheight = obj.parentNode.currentStyle.height
		var objwidth = obj.parentNode.currentStyle.width
	}
	parenth = objheight.split('p')[0]
	parentw = objwidth.split('p')[0]
	parentAspect = parentw / parenth
	childAspect = obj2.width / obj2.height
	if(parentAspect >= childAspect)
	{
		obj2.style.height = '100%';
		obj2.style.width = 'auto';
		obj2.style.padding = '0';
	} else {
		obj2.style.width = '100%'
		if(parenth == 'auto')
			obj2.style.padding = '0'
		else
			obj2.style.padding = ((parenth - obj2.height)/2) + 'px 0 0 0'
		obj2.style.height = 'auto'
	}
}
