
function propertyLocation(whichPage,lan,id_webshop,id_property)
{
	var f=window.open(whichPage+"?lan="+lan+"&id_webshop="+id_webshop+"&id_property="+id_property,'TDPropertyLocation','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=850,height=550');
	f.focus();
}

/*
function strToDate(strDate)
{
	// konvertira string formata YYYY-MM-DD u varijablu tipa Date
	var myDate = new Date();
	myYear = strDate.substr(0,4);
	myMonth = parseInt(strDate.substr(5,2),10)-1;
	myDay = strDate.substr(8,2);
	myDate.setFullYear(myYear, myMonth, myDay);
	return myDate;
}
*/
function strToDate(strDate)
{
	// konvertira string formata YYYY-MM-DD u varijablu tipa Date
	var myDate = new Date();
	var dateParts = strDate.split("-");
	myYear = dateParts[0];
	myMonth = parseInt(dateParts[1],10)-1;
	myDay = dateParts[2];
	myDate.setFullYear(myYear, myMonth, myDay);
	return myDate;
}

function trimboth(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function numbersonly(myfield, e, decimal, negative)
{
	var key;
	var keychar;
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);
	if (key==13)  // return key
	{
		return true;
	}
	else if ((key==null) || (key==0) || (key==8) || (key==9))  // control keys: 0=null, 8=backspace, 9=tab, 27=esc
		return true;
	else if (("0123456789").indexOf(keychar) > -1)  // numbers
		return true;
	else if (negative && (keychar == "-"))  // negative
	{
		if (myfield.value.indexOf("-") > -1)
			myfield.value = myfield.value.substring(1);
		else
			myfield.value = "-" + myfield.value;
		return false;
	}
	else if (decimal && ((keychar == ".")||(keychar == ",")) && (myfield.value.indexOf(".") == -1))  // decimal point
	{
		if ((myfield.value=="") || (myfield.value=="-")) myfield.value += "0";
		myfield.value += ".";
		return false;
	}
	else
		return false;
}


/*
Equal height boxes with Javascript
http://www.thewatchmakerproject.com/journal/308/equal-height-boxes-with-javascript

window.onload = function() {
	BoxHeights.equalise('one','two','three','four');
}
*/
function $() {
	var elements = new Array();
	for (var i=0;i<arguments.length;i++) {
		var element = arguments[i];
		if (typeof element == 'string') element = document.getElementById(element);
		if (arguments.length == 1) return element;
		elements.push(element);
	}
	return elements;
}
var BoxHeights = {
	maxh: 0,
	boxes: Array(),
	num: 0,
	op_test: false,
	equalise: function() {
		this.num = arguments.length;
		for (var i=0;i<this.num;i++) if (!$(arguments[i])) return;
		this.boxes = arguments;
		this.maxheight();
		for (var i=0;i<this.num;i++) $(arguments[i]).style.height = this.maxh+"px";
	},
	maxheight: function() {
		var heights = new Array();
		for (var i=0;i<this.num;i++) {
			if (navigator.userAgent.toLowerCase().indexOf('opera') == -1) {
				heights.push($(this.boxes[i]).scrollHeight);
			} else {
				heights.push($(this.boxes[i]).offsetHeight);
			}
		}
		heights.sort(this.sortNumeric);
		this.maxh = heights[this.num-1];
	},
	sortNumeric: function(f,s) {
		return f-s;
	}
}

function propertyDescription(whichPage,lan,id_webshop,id_property,id_unit)
{
	if (id_unit)
	{
		id_unit='&id_unit='+id_unit;
	} else {
		id_unit = '';
	}
	switch(whichPage)
	{

		case 'inquiry' :
			page = 'inquiry.php';
			break;
		case 'prices' :
			page = 'property_unit_prices.php';
			break;
		case 'availability' :
			page = 'property_unit_availability.php';
			break;
		case 'unit' :
			page = 'property_unit_description.php';
			break;
		case 'location' :
			page = 'property_map.php';
			break;
		case 'property_unit_gallery' :
			page = 'property_unit_gallery.php';
			break;
		case 'property_unit_description_hotels' :
			page = 'property_unit_description_hotels.php';
			break;
		case 'property_description_window' :
			page = 'property_description_window.php';
			break;
		case 'property_gallery' :
			page = 'property_gallery.php';
			break;
		case 'package_gallery' :
			page = 'package_gallery.php';
			break;
		case 'package_write_review' :
			page = 'property_write_review.php';
			break;
		case 'property' :
		default :
			page = 'property_description.php';
			break;
	}

	switch(whichPage)
	{
		case 'property_description_window' :
			var f=window.open("http://www.travel-design.com/"+page+"?lan="+lan+"&id_webshop="+id_webshop+"&id_property="+id_property+id_unit,'TDPropertyDescription'+id_property,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=610,height=550');
			f.focus()
		break;
		default :
			var f=window.open("http://www.travel-design.com/"+page+"?lan="+lan+"&id_webshop="+id_webshop+"&id_property="+id_property+id_unit,'TDPropertyDescription'+id_property,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=850,height=550');
			f.focus()
		break;

	}



}

function propertyPricelist(whichPage,lan,id_webshop,id_property,id_unit)
{
	if (id_unit)
	{
		id_unit='&id_unit='+id_unit;
	} else {
		id_unit = '';
	}
	switch(whichPage)
	{
		case 'pricelist' :
			page = 'property_unit_description_hotels.php';
			break;
	}
	var f=window.open(page+"?pricelist=show&lan="+lan+"&id_webshop="+id_webshop+"&id_property="+id_property+id_unit,'TDPropertyDescription'+id_property,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=850,height=550');
	f.focus()
}





function newWindow(whichPage,lan,id_webshop)
{
	var f=window.open(whichPage+"?lan="+lan+"&id_webshop="+id_webshop,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=750,height=550');
	f.focus();
}



