var markersgroup = new Array();   

// ONLOAD_JS
// called by onload body, initialize everything
function onload_js(ishome)
{               
 load_js_localization();
 if (ishome == "B")
  {
  }
} 


// JSREDIRECT
// redirect to another page
function jsredirect(where)
{
 if (where != '')
  document.location.href=where;
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function strpos (haystack, needle, offset) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Onno Marsman    
    // +   bugfixed by: Daniel Esteban
    // *     example 1: strpos('Kevin van Zonneveld', 'e', 5);
    // *     returns 1: 14
 
    var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
    return i === -1 ? false : i;
}

function noCache(uri)
{return uri.concat(/\?/.test(uri)?"&":"?","noCache=",(new Date).getTime(),".",Math.random()*1234567)};

function verify_email(stremail)
{
var status = false;
var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
     if (stremail.search(emailRegEx) == -1) {
          status = false;
     }
     else {
          status = true;
     }
     return status;
}

function IsNumeric(sText)
{
 var ValidChars = "0123456789.";
 var IsNumber=true;
 var Char;

 for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
    Char = sText.charAt(i); 
    if (ValidChars.indexOf(Char) == -1) 
       {
       IsNumber = false;
       }
    }
 return IsNumber;
}

function showdiv(divname)
{
 dv = document.getElementById(divname);
 if (dv.style.display == '')  { dv.style.display = 'none'; }
 if (dv.style.display == 'none')
  { dv.style.display = 'block'; }
 else
  { dv.style.display = 'none' }
}

var Utf8 = {
 
	// public method for url encoding
	encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// public method for url decoding
	decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}

function chkObject(theVal) {
if (document.getElementById(theVal) != null) {
return true;
} else {
return false;
}
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
  do {
  			curleft += obj.offsetLeft;
  			curtop += obj.offsetTop;
  } while (obj = obj.offsetParent);
return curleft+"|"+curtop;
}                          
}

function dayendmonth(month)
{
 day = "";
 if (month == "01")
  { day = "31"; }
 if (month == "02")
  { day = "28"; }
 if (month == "03")
  { day = "31"; }
 if (month == "04")
  { day = "30"; }
 if (month == "05")
  { day = "31"; }
 if (month == "06")
  { day = "30"; }
 if (month == "07")
  { day = "31"; }
 if (month == "08")
  { day = "31"; }
 if (month == "09")
  { day = "30"; }
 if (month == "10")
  { day = "31"; }
 if (month == "11")
  { day = "30"; }
 if (month == "12")
  { day = "31"; }
 return day;
}

function gofiletrials(dove, agg, mail, domain)
{
 setTimeout("window.location='" + dove + "';", 2000)
 if (mail == "S")
  {
   //setTimeout("window.location=domain+'/inviomail/trials/<? echo $_GET["id"] ?>/" + dove + "/';", 10000)
   setTimeout(function()
   {
     $.post(domain+'/inviomail/trials/',
     { vdove : dove },
     function(data, textStatus){  
        if (textStatus == "success")
          {
           //alert(data);
          }
         else
         {
           //alert(data);
         }
     }, 
     "html");
   }
   , 3000)
  }
}
function gofileupdates(dove, agg, mail, domain)
{
 setTimeout("window.location='" + dove + "';", 2000)
 if (mail == "S")
  {
   //setTimeout("window.location=domain+'/inviomail/trials/<? echo $_GET["id"] ?>/" + dove + "/';", 10000)
   setTimeout(function()
   {
     $.post(domain+'/inviomail/updates/',
     { vdove : dove },
     function(data, textStatus){  
        if (textStatus == "success")
          {
           //alert(data);
          }
         else
         {
           //alert(data);
         }
     }, 
     "html");
   }
   , 3000)
  }
}

function open_popup_video(videourl)
{
 ww = 2;
 ww = document.getElementById('dv_main_body_wrapper').style.width;
 /*
 if (navigator.appName == "Microsoft Internet Explorer")
  { ww = document.body.clientWidth; }
 else
  { ww = window.outerWidth; }
 */
 //document.getElementById('dv_video').style.left = (ww / 2) - (document.getElementById('dv_video').style.width.replace('px','') / 2) + 'px';
 document.getElementById('dv_video').style.left = "30px";
 document.getElementById('dv_video').style.top = "130px";
 document.getElementById('dv_video').style.display = 'block';
 setTimeout(mostra(videourl), 2000);

}

function mostra(videourl)
{
 document.getElementById('dv_video_loading').style.display = 'none';

 domain = "http://www.cimsystem.it/";
 if ((window.location.host != "www.sum3ddental.com") && (window.location.host != "sum3ddental.com"))
 {
   if ((window.location.host != "www.cimsystem.it") && (window.location.host != "www.cimsystem.com"))
   { domain = "http://10.0.0.70/cimsystem/"; }
 }
 txtvideo = '<object data="'+domain+'images/player_flv_maxi.swf" ';
 txtvideo += 'width="690" height="400" type="application/x-shockwave-flash"> ';
 txtvideo += '<param name="movie" value="'+domain+'images/player_flv_maxi.swf" /> ';
 txtvideo += '<param name="allowFullScreen" value="true" /> ';
 txtvideo += '<param name="wmode" value="opaque" /> ';
 txtvideo += '<param name="allowScriptAccess" value="sameDomain" /> ';
 txtvideo += '<param name="quality" value="high" /> ';
 txtvideo += '<param name="menu" value="true" /> ';
 txtvideo += '<param name="autoplay" value="false" /> ';
 txtvideo += '<param name="autoload" value="false" /> ';
 txtvideo += '<param name="width" value="690" /> ';
 txtvideo += '<param name="height" value="400" /> ';
 txtvideo += '<param name="FlashVars" value="configxml='+domain+'xmlflv.php?nf='+videourl+'" /></object>';
 //alert(txtvideo);
 document.getElementById('dv_video_content').innerHTML = txtvideo;
 
 document.getElementById('dv_video_content').style.display = 'block';
}

function togglediv(divname)
{
 dv = document.getElementById(divname);
 if (dv.style.display == '')  { dv.style.display = 'none'; }
 if (dv.style.display == 'none')
  {
   //alert("down");
   $(dv).stop(true,true).show('fast');
  }
 else
  {
   //alert("up");
   $(dv).stop(true,true).hide('slow');
  }
}





