////////////////////////////////////////////////////////////////////////////
//'	* ASP-Nuke Community 1.4 Copyright © 2004 by Rolf Thomassen            *
//'	* (mrspock(a)rediff.com) http://www.rot.dk                             *
////////////////////////////////////////////////////////////////////////////
function TZDemo(){
   var d, tz, s = "The current local time is ";
   d = new Date();
   tz = d.getTimezoneOffset();
   if (tz < 0)
      s += -tz / 60 + " hours before GMT";
   else if (tz == 0)
      s += "GMT";
   else
      s += tz / 60 + " hours after GMT";
   return(s);
}

function GetTimeZone(){
	var d, tz, m, s="GMT";
	d = new Date();
	tz = d.getTimezoneOffset();
	if (tz < 0) {
		m=-tz%60;if(m<10) m="0"+m;
		s+="+"+parseInt(-tz/60) + ":" + m;
	} else if (tz == 0)
		s+="";
	else {
		m=tz%60;if(m<10) m="0"+m;
		s+="-"+parseInt(tz/60)+":" + m;
	}
	return(s);
}

function GetTZoffset(){
	var d = new Date();
	return(d.getTimezoneOffset());
}

function getZone() {
	// Get local timezone and set cookie
	var d = new Date();
	var offset = (d.getTimezoneOffset());
	SetCookie('timezone', offset, 30);
}

////////////////////////////////////////////
// time function by Zach Nakaska
function SetCookie(cookieName, cookieValue, nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays == null || nDays == 0)
		nDays = 1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString();
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var start = 0;
	while (start < clen) {
		var len = start + alen;
		if (document.cookie.substring(start, len) == arg) {
			var endstr = document.cookie.indexOf (";", len);
			if (endstr == -1)
				endstr = clen;
			return unescape(document.cookie.substring(len, endstr));
		}
		start = document.cookie.indexOf(" ", start) + 1;
		if (start == 0)
			break;
	}
	return null;
}

function AHAHrequest(url, target, callMessage, errorMessage, method, parameters) {
	var req = null;
	if (!callMessage)
		callMessage = '';
	if (!errorMessage)
		errorMessage = '';
	if (!parameters)
		parameters = '';
	if (!method)
		method = 'GET';
	else
		method = method.toUpperCase();
	if ((method=='GET') && (parameters!=''))
		url = url + '?' + parameters
	if (callMessage != '') {
		var ele = getObject(target);
		var nn = ele.nodeName;
		if (nn.toUpperCase() == "TEXTAREA" || nn.toUpperCase() == "INPUT") {
			ele.value = callMessage;
		}
		else {
			ele.innerHTML = callMessage;
		}
	}
	try {
		req = new XMLHttpRequest(); /* e.g. Firefox */
	} catch(e) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");  /* some versions IE */
		} catch (e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
			} catch (e) {
				req = false;
			}
		}
	}
	req.onreadystatechange = function() {AHAHresponse(req, target, errorMessage);};
	req.open(method,url,true);
	if (method=='GET') {
		req.send(null);
	}
	else {
		req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		req.send(parameters);
	}
}
function AHAHresponse(req, target, errorMessage, scroll) {
	if(req) {
		if (!errorMessage)
			errorMessage = '';
		if (!scroll)
			scroll = 0;
		if(req.readyState == 4) {
			var ele = getObject(target);
			var nn = ele.nodeName;
			if(req.status == 200) {
				if (nn.toUpperCase() == "TEXTAREA" || nn.toUpperCase() == "INPUT") {
					ele.value = req.responseText;
				} else {
					ele.innerHTML = req.responseText;
					ele.scrollTop = scroll;
				}
			}
			else {
				if (nn.toUpperCase() == "TEXTAREA" || nn.toUpperCase() == "INPUT") {
					ele.value = errorMessage+req.responseText;
				} else {
					ele.innerHTML = errorMessage+req.responseText;
				}
			}
		}
	}
}

function encodemail(utente, dominio) {
	window.location.href = 'mailto:' + utente + '@' + dominio;
}

function preloadimages(){
	for (i=0;i<preloadimages.arguments.length;i++){
		myimages[i]=new Image();
		myimages[i].src=preloadimages.arguments[i];
	}
}

function trimString(inString) {
	var outString = "";
	var startPos;
	var endPos;
	var ch;

	// where do we start?
	startPos = 0;
	ch = inString.charAt(startPos);
	while (ch == " ") {
		startPos++;
		ch = inString.charAt(startPos);
	}

	// where do we end?
	endPos = inString.length - 1;
	ch = inString.charAt(endPos);
	while (ch == " ") {
		endPos--;
		ch = inString.charAt(endPos);
	}

	// get the string
	if (startPos < (endPos + 1))
		outString = inString.substring(startPos, endPos + 1);

	return outString;
}

function getObject(id) {
	if (ie4) {
		return document.all[id];
	} else {
		return document.getElementById(id);
	}
}

function ToggleImage(imgId, img_block, img_none) {
	var d = getObject("div_"+imgId);
	var i = getObject("img_"+imgId);
	if (i != null) {
		if (d.style.display != "none")
			i.src = img_block;
		else
			i.src = img_none;
	}
}

function ToggleColumn(imgId, img_block, img_none) {
	var d = getObject("div_"+imgId);
	var i = getObject("colw_"+imgId);
	if (i != null) {
		if (d.style.display != "none")
			i.width = img_block;
		else
			i.width = img_none;
	}
}

function ToggleBlock(divId) {
	var d = getObject(divId);
	if (d != null) 	{
		if (d.style.display != 'none')
			d.style.display = 'none';
		else
			d.style.display = 'block';
	}
	SetCookie(divId,d.style.display,365);
}

function ToggleContent(imgId, img_block, img_none) {
	var i = getObject(imgId);
	if (i != null) {
		if (i.innerHTML == img_block)
			i.innerHTML = img_none;
		else if (i.innerHTML == img_none)
			i.innerHTML = img_block;
	}
}

var myimages=new Array();
var ie4 = false;
var RGB = new Array(256);
var k = "0123456789abcdef";

for (var i = 0; i < 16; i++)
	for (var j = 0; j < 16; j++)
		RGB[16*i+j] = k.charAt(i) + k.charAt(j);

if(document.all) {
	ie4 = true;
}
getZone();
//---------------------------------------------------------------------
function show_flash_object(flash_source, flash_width, flash_height, flash_vars)
{	
	document.write('<NONSCRIPT><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=3,0,0,0" width="'+flash_width+'" height="'+flash_height+'" id="up_player" align="left">')
    document.write('<param name="allowScriptAccess" value="sameDomain" />')
    document.write('<param name="movie" value="'+flash_source+'" />')
    document.write('<param name="loop" value="true" />')
	document.write('<PARAM NAME=play VALUE=true>')
	document.write('<PARAM NAME=wmode VALUE=transparent>')
    document.write('<param name="menu" value="false" />')
    document.write('<param name="quality" value="best" />')
    //document.write('<param name="scale" value="exactfit" />')
    document.write('<param name="salign" value="lt" />')
    document.write('<param name="bgcolor" value="#ffffff" />')
	document.write('<param name="flashvars" value="'+flash_vars+'">');
    document.write('<embed src="'+flash_source+'" swLiveConnect="FALSE" FLASHVARS="'+flash_vars+'" loop="false" menu="false" play="true" quality="best" wmode="transparent" salign="lt" bgcolor="#ffffff" width="'+flash_width+'" height="'+flash_height+'" name="up_player" align="left" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />')
    document.write('</object></NONSCRIPT>')
}
function setZoneShop(id){	
  document.location='kricXzone_ru.asp?idZone='+id;
}
function setTipoShop(id){
  document.location='kricXtipo_ru.asp?idTipiShop='+id;
}
function setCatProd(id){
  document.location='kricXcat_ru.asp?idCatProd='+id;
}
function listaPreferiti(){
	var f = document.forms["ricShop"];
	
}
function eliminareAnnuncio(url, msg){
   if (confirm(msg)) {
       document.location = url;
   }
}
//------------------------- com --------------------------------------------
function isEmpty(s) {
	var t = Trim(s);
	if (t.length == 0){ 
		return true;
	}else{
		return false;
	}		
}
function lessChars(s, n) {
	// n - numero chars minimale
	var t = Trim(s);
	if (t.length < n){ 
		return true;
	}else{
		return false;
	}		
}
function Trim(TRIM_VALUE){
     if(TRIM_VALUE.length < 1){
               return"";
     }
     TRIM_VALUE = RTrim(TRIM_VALUE);
     TRIM_VALUE = LTrim(TRIM_VALUE);
     if(TRIM_VALUE==""){
           return "";
     }else{
          return TRIM_VALUE;
     }
} 
function RTrim(VALUE){
     var w_space = String.fromCharCode(32);
     var v_length = VALUE.length;
     var strTemp = "";
     if(v_length < 0){
       return"";
     }
     var iTemp = v_length -1;
     while(iTemp > -1){
       if(VALUE.charAt(iTemp) == w_space){
       }else{
          strTemp = VALUE.substring(0,iTemp +1);
          break;
       }
       iTemp = iTemp-1;

     } //End While
     return strTemp;
} //End Function
function LTrim(VALUE){
     var w_space = String.fromCharCode(32);
     if(v_length < 1){
        return"";
     }
     var v_length = VALUE.length;
     var strTemp = "";
     var iTemp = 0;
     while(iTemp < v_length){
        if(VALUE.charAt(iTemp) == w_space){
        }else{
             strTemp = VALUE.substring(iTemp,v_length);
             break;
        }
        iTemp = iTemp + 1;
     } //End While
     return strTemp;
} //End Function
function checkEmail(emailStr) {
       if (emailStr.length == 0) {
           return true;
       }
       var emailPat=/^(.+)@(.+)$/;
       var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
       var validChars="\[^\\s" + specialChars + "\]";
       var quotedUser="(\"[^\"]*\")";
       var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/;
       var atom=validChars + '+';
       var word="(" + atom + "|" + quotedUser + ")";
       var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
       var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$");
       var matchArray=emailStr.match(emailPat);
       if (matchArray == null) {
           return false;
       }
       var user=matchArray[1];
       var domain=matchArray[2];
       if (user.match(userPat) == null) {
           return false;
       }
       var IPArray = domain.match(ipDomainPat);
       if (IPArray != null) {
           for (var i = 1; i <= 4; i++) {
              if (IPArray[i] > 255) {
                 return false;
              }
           }
           return true;
       }
       var domainArray=domain.match(domainPat);
       if (domainArray == null) {
           return false;
       }
       var atomPat=new RegExp(atom,"g");
       var domArr=domain.match(atomPat);
       var len=domArr.length;
       if ((domArr[domArr.length-1].length < 2) ||
           (domArr[domArr.length-1].length > 3)) {
           return false;
       }
       if (len < 2) {
           return false;
       }
       return true;
}
//-------------------------- GOOGLE MAPS-------------------------------------------   
    //<![CDATA[

    var map = null;
	var map1 = null;
    var geocoder = null;
	 var geocoder1 = null;

    function load(address) {
      if(load.arguments.length == 0 || address == null || address == ""){
         return;
      } 
	  if (address == "elencoShop"){
		  showMappaElencoShop();
		  return;
	  }
	  if (address == "aeroporti"){
		  showMappaAeroporti();
		  return;
	  }
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
		//map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(46.075255085800116, 11.122970581054687), 13);
        geocoder = new GClientGeocoder();
        showAddress(address);
		map1 = new GMap2(document.getElementById("map1"));       
        map1.setCenter(new GLatLng(46.075255085800116, 11.122970581054687),8); 
		//geocoder1 = new GClientGeocoder();
        showAddress1(address);
		
      }
    }

    function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert("Адрес " + address + " не найден!");
              map.openInfoWindow(map.getCenter(), document.createTextNode("Шоппинг в Италии - KupimItaly.com - Trento, Italy"));
              
            } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml(address);
            }
          }
        );
      }
    }
	function showAddress1(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              //alert("Адрес " + address + " не найден!");
             // map.openInfoWindow(map.getCenter(), document.createTextNode("Шоппинг в Италии - KupimItaly.com - Trento, Italy"));
              
            } else {
              map1.setCenter(point,6);
              var marker = new GMarker(point);
              map1.addOverlay(marker);
              //marker.openInfoWindowHtml(address);
            }
          }
        );
      }
    }
   function unload(address) {
      if(address == null || address == ""){
         return;
      } 
      GUnload();
    }
    //]]>

//----------------------------------------------------------------------------------
function ExpandDiv(idDiv, vedi, chiudi) {
		document.getElementById(idDiv).style.display = (document.getElementById(idDiv).style.display=="none" ? "block" : "none");
		document.getElementById(vedi).style.display = (document.getElementById(vedi).style.display=="none" ? "block" : "none");
		document.getElementById(chiudi).style.display = (document.getElementById(chiudi).style.display=="none" ? "block" : "none");
}