function quicklink(linkurl){
	act = linkurl.substr(0,1);
	hyperlink = linkurl.substr(2);
	if(act == "Y"){
		window.open(hyperlink,'TripodPopup');
	}else{
		location.href=hyperlink;
	}
}
function souvenir_Cat(catid){
	if(catid!=""){
		location.href='souvenir.php?cat='+catid;
	}else{
		location.href='souvenir.php';
	}
}
function largeImage(img){
	obj = document.getElementById('largePhoto');
	obj.src=img;
}
function largeVideo(video,obj){
	obj = document.getElementById(obj);
	obj.innerHTML = '<EMBED SRC="'+video+'" WIDTH=580 HEIGHT="345" BGCOLOR="#F1F1F1" TYPE="video/quicktime" autostart="true" PLUGINSPAGE="http://www.apple.com/quicktime/download/" /> ';
}
function popwin(myname, myheight, mywidth){
	//var mywin = window.open(myname ,'membercheckno','width=' + mywidth +', height=' + myheight +',location=no,directories=no,menubar=no,toolbar=no,scrollbars=yes,status=no,resizable=no,left=0,top=0');
	var mywin = window.open(myname ,'TripodPopup');
	mywin.focus();
}


function changelang(olang, nlang){
	var locat = window.location;
	var strlocat = locat.toString();
	strlocat = strlocat.replace("/" + olang + "/", "/" + nlang + "/");

	if (strlocat.substr(strlocat.length-1, 1) == '#')
		strlocat = strlocat.replace("#", "");
	
	window.location = strlocat;
}

function getAbsoluteLeft(objectId) {
 o = document.getElementById(objectId)
 oLeft = o.offsetLeft
 while(o.offsetParent!=null) {
      oParent = o.offsetParent 
      oLeft += oParent.offsetLeft
      o = oParent
 }
 return oLeft
}



function getAbsoluteRight(objectId) {
 o = document.getElementById(objectId)
 w = o.offsetWidth
 oLeft = o.offsetLeft
 while(o.offsetParent!=null) {
      oParent = o.offsetParent 
      oLeft += oParent.offsetLeft
      o = oParent
 }
 return oLeft + w
}

function getAbsoluteTop(objectId) {
 o = document.getElementById(objectId)
 oTop = o.offsetTop
 while(o.offsetParent!=null) {
      oParent = o.offsetParent 
      oTop += oParent.offsetTop
      o = oParent
 }
 return oTop
}

function getAbsoluteBottom(objectId) {
 o = document.getElementById(objectId)
 h = o.offsetHeight;
 oTop = o.offsetTop
 while(o.offsetParent!=null) {
      oParent = o.offsetParent 
      oTop += oParent.offsetTop
      o = oParent
 }
 return oTop + h
}


Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  if (WhichMonth == "4" || WhichMonth == "6" || WhichMonth == "9" || WhichMonth == "11") DaysInMonth = 30;
  if (WhichMonth == "2")
  {
  	if ((WhichYear % 4 == 0 && WhichYear % 100 != 0) || WhichYear % 400 == 0 || WhichYear == 0) 
  		DaysInMonth = 29;
  	else
  		DaysInMonth = 28;
  }
  return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(Which)
{
  DaysObject = eval("document.myform." + Which + "Day");
  MonthObject = eval("document.myform." + Which + "Month");
  YearObject = eval("document.myform." + Which + "Year");

  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject.value;

  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length;
  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DaysObject.options[DaysObject.options.length - 1] = null
    }
  }
  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
      NewOption = new Option(DaysObject.options.length + 1, DaysObject.options.length + 1);
      DaysObject.add(NewOption);
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//function to set options to today
function SetToToday(Which)
{
  DaysObject = eval("document.myform." + Which + "Day");
  MonthObject = eval("document.myform." + Which + "Month");
  YearObject = eval("document.myform." + Which + "Year");

//  YearObject[0].selected = true;
  MonthObject[NowMonth].selected = true;

  ChangeOptionDays(Which);

  DaysObject[NowDay-1].selected = true;
}

//function to write option years plus x
function WriteYearOptions(YearsAhead)
{
  line = "";
  for (i=0; i<YearsAhead; i++)
  {
    line += "<OPTION>";
    line += NowYear + i;
  }
  return line;
}

function dateInput(objName){
	
	document.writeln ("<SELECT name=\"" + objName + "Day\" class=fromtable>");
	document.writeln ("	<OPTION value='01'>1");
	document.writeln ("	<OPTION value='02'>2");
	document.writeln ("	<OPTION value='03'>3");
	document.writeln ("	<OPTION value='04'>4");
	document.writeln ("	<OPTION value='05'>5");
	document.writeln ("	<OPTION value='06'>6");
	document.writeln ("	<OPTION value='07'>7");
	document.writeln ("	<OPTION value='08'>8");
	document.writeln ("	<OPTION value='09'>9");
	document.writeln ("	<OPTION value='10'>10");
	document.writeln ("	<OPTION value='11'>11");
	document.writeln ("	<OPTION value='12'>12");
	document.writeln ("	<OPTION value='13'>13");
	document.writeln ("	<OPTION value='14'>14");
	document.writeln ("	<OPTION value='15'>15");
	document.writeln ("	<OPTION value='16'>16");
	document.writeln ("	<OPTION value='17'>17");
	document.writeln ("	<OPTION value='18'>18");
	document.writeln ("	<OPTION value='19'>19");
	document.writeln ("	<OPTION value='20'>20");
	document.writeln ("	<OPTION value='21'>21");
	document.writeln ("	<OPTION value='22'>22");
	document.writeln ("	<OPTION value='23'>23");
	document.writeln ("	<OPTION value='24'>24");
	document.writeln ("	<OPTION value='25'>25");
	document.writeln ("	<OPTION value='26'>26");
	document.writeln ("	<OPTION value='27'>27");
	document.writeln ("	<OPTION value='28'>28");
	document.writeln ("	<OPTION value='29'>29");
	document.writeln ("	<OPTION value='30'>30");
	document.writeln ("	<OPTION value='31'>31");
	document.writeln ("</SELECT>");
	document.writeln ("<SELECT name=\"" + objName + "Month\" onchange=\"ChangeOptionDays('" + objName + "')\" class=fromtable>");
	document.writeln ("	<OPTION value='01'>1");
	document.writeln ("	<OPTION value='02'>2");
	document.writeln ("	<OPTION value='03'>3");
	document.writeln ("	<OPTION value='04'>4");
	document.writeln ("	<OPTION value='05'>5");
	document.writeln ("	<OPTION value='06'>6");
	document.writeln ("	<OPTION value='07'>7");
	document.writeln ("	<OPTION value='08'>8");
	document.writeln ("	<OPTION value='09'>9");
	document.writeln ("	<OPTION value='10'>10");
	document.writeln ("	<OPTION value='11'>11");
	document.writeln ("	<OPTION value='12'>12");
	document.writeln ("</SELECT>");
	document.writeln ("<input id=\"" + objName + "Year\" name=\"" + objName + "Year\" onchange=\"ChangeOptionDays('" + objName + "')\" maxlength=4 size=5 class=fromtable>");
	
}

function dateInput_arr(objName, i){
	
	document.writeln ("<SELECT id=\"" + objName + i + "Day\" name=\"" + objName + "Day[]\" class=fromtable>");
	document.writeln ("	<OPTION value='01'>1");
	document.writeln ("	<OPTION value='02'>2");
	document.writeln ("	<OPTION value='03'>3");
	document.writeln ("	<OPTION value='04'>4");
	document.writeln ("	<OPTION value='05'>5");
	document.writeln ("	<OPTION value='06'>6");
	document.writeln ("	<OPTION value='07'>7");
	document.writeln ("	<OPTION value='08'>8");
	document.writeln ("	<OPTION value='09'>9");
	document.writeln ("	<OPTION value='10'>10");
	document.writeln ("	<OPTION value='11'>11");
	document.writeln ("	<OPTION value='12'>12");
	document.writeln ("	<OPTION value='13'>13");
	document.writeln ("	<OPTION value='14'>14");
	document.writeln ("	<OPTION value='15'>15");
	document.writeln ("	<OPTION value='16'>16");
	document.writeln ("	<OPTION value='17'>17");
	document.writeln ("	<OPTION value='18'>18");
	document.writeln ("	<OPTION value='19'>19");
	document.writeln ("	<OPTION value='20'>20");
	document.writeln ("	<OPTION value='21'>21");
	document.writeln ("	<OPTION value='22'>22");
	document.writeln ("	<OPTION value='23'>23");
	document.writeln ("	<OPTION value='24'>24");
	document.writeln ("	<OPTION value='25'>25");
	document.writeln ("	<OPTION value='26'>26");
	document.writeln ("	<OPTION value='27'>27");
	document.writeln ("	<OPTION value='28'>28");
	document.writeln ("	<OPTION value='29'>29");
	document.writeln ("	<OPTION value='30'>30");
	document.writeln ("	<OPTION value='31'>31");
	document.writeln ("</SELECT>");
	document.writeln ("<SELECT id=\"" + objName + i + "Month\" name=\"" + objName + "Month[]\" onchange=\"ChangeOptionDays('" + objName + i + "')\" class=fromtable>");
	document.writeln ("	<OPTION value='01'>1");
	document.writeln ("	<OPTION value='02'>2");
	document.writeln ("	<OPTION value='03'>3");
	document.writeln ("	<OPTION value='04'>4");
	document.writeln ("	<OPTION value='05'>5");
	document.writeln ("	<OPTION value='06'>6");
	document.writeln ("	<OPTION value='07'>7");
	document.writeln ("	<OPTION value='08'>8");
	document.writeln ("	<OPTION value='09'>9");
	document.writeln ("	<OPTION value='10'>10");
	document.writeln ("	<OPTION value='11'>11");
	document.writeln ("	<OPTION value='12'>12");
	document.writeln ("</SELECT>");
	document.writeln ("<input id=\"" + objName + i + "Year\" name=\"" + objName + "Year[]\" onchange=\"ChangeOptionDays('" + objName + i + "')\" maxlength=4 size=5 class=fromtable>");
	
}

function dateInput2(objName){
	Now = new Date();
	NowYear = Now.getYear();
	
	if(NowYear < 2000)
		NowYear = (NowYear * 1) + 1900;
		
	document.writeln ("<SELECT name=\"" + objName + "Day\" class=fromtable>");
	document.writeln ("	<OPTION value='01'>1");
	document.writeln ("	<OPTION value='02'>2");
	document.writeln ("	<OPTION value='03'>3");
	document.writeln ("	<OPTION value='04'>4");
	document.writeln ("	<OPTION value='05'>5");
	document.writeln ("	<OPTION value='06'>6");
	document.writeln ("	<OPTION value='07'>7");
	document.writeln ("	<OPTION value='08'>8");
	document.writeln ("	<OPTION value='09'>9");
	document.writeln ("	<OPTION value='10'>10");
	document.writeln ("	<OPTION value='11'>11");
	document.writeln ("	<OPTION value='12'>12");
	document.writeln ("	<OPTION value='13'>13");
	document.writeln ("	<OPTION value='14'>14");
	document.writeln ("	<OPTION value='15'>15");
	document.writeln ("	<OPTION value='16'>16");
	document.writeln ("	<OPTION value='17'>17");
	document.writeln ("	<OPTION value='18'>18");
	document.writeln ("	<OPTION value='19'>19");
	document.writeln ("	<OPTION value='20'>20");
	document.writeln ("	<OPTION value='21'>21");
	document.writeln ("	<OPTION value='22'>22");
	document.writeln ("	<OPTION value='23'>23");
	document.writeln ("	<OPTION value='24'>24");
	document.writeln ("	<OPTION value='25'>25");
	document.writeln ("	<OPTION value='26'>26");
	document.writeln ("	<OPTION value='27'>27");
	document.writeln ("	<OPTION value='28'>28");
	document.writeln ("	<OPTION value='29'>29");
	document.writeln ("	<OPTION value='30'>30");
	document.writeln ("	<OPTION value='31'>31");
	document.writeln ("</SELECT>");
	document.writeln ("<SELECT name=\"" + objName + "Month\" onchange=\"ChangeOptionDays('" + objName + "')\" class=fromtable>");
	document.writeln ("	<OPTION value='01'>1");
	document.writeln ("	<OPTION value='02'>2");
	document.writeln ("	<OPTION value='03'>3");
	document.writeln ("	<OPTION value='04'>4");
	document.writeln ("	<OPTION value='05'>5");
	document.writeln ("	<OPTION value='06'>6");
	document.writeln ("	<OPTION value='07'>7");
	document.writeln ("	<OPTION value='08'>8");
	document.writeln ("	<OPTION value='09'>9");
	document.writeln ("	<OPTION value='10'>10");
	document.writeln ("	<OPTION value='11'>11");
	document.writeln ("	<OPTION value='12'>12");
	document.writeln ("</SELECT>");
	document.writeln ("<SELECT name=\"" + objName + "Year\" onchange=\"ChangeOptionDays('" + objName + "')\" class=fromtable>");
	document.writeln ("	<OPTION value='0000'>- - -</option>");
	document.writeln ("	<OPTION value='" + (NowYear - 1) + "'>" + (NowYear - 1) + "</option>");
	document.writeln ("	<OPTION value='" + NowYear + "' selected>" + NowYear + "</option>");
	document.writeln ("	<OPTION value='" + (NowYear + 1) + "'>" + (NowYear + 1) + "</option>");
	document.writeln ("	<OPTION value='" + (NowYear + 2) + "'>" + (NowYear + 2) + "</option>");
	document.writeln ("</SELECT>");
	
}


function LTrim(str){
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
     
      s = s.substring(j, i);
   }
   return s;
}

function RTrim(str){
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;       // Get length of string
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}

function Trim(str){
   return RTrim(LTrim(str));
}

function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
		return false;
}

function isPositiveInt(myvalue){
	if(myvalue.search(/^[0-9]+$/) != -1){
		return true;
	}else{
		return false;
	}
}
