//
//  MyScripts - MyScripts.js
//  Copyright (c) 2009 AngiyokDesigns. All rights reserved.
//


//Usage:  href="javascript:iEmail()"

function iEmail() { //This email sets the email handler globally
//alert('"' + 'mailto:gremelm@yahoo.com?subject=A.Yankowski%20website' + '"');

var toEmail = "andrea.yankowski@fulbrightmail.org";
var Esubject = "A.Yankowski%20website";
var Ebody = "Comment/Question here.";
this.location.href = "mailto:" + toEmail + "?subject=" + Esubject + "&body=" + Ebody;
//this.location.href = "mailto:andrea.yankowski@fulbrightmail.org?subject=A.Yankowski%20website";
}


function copyright(file) {
  self.name = "parent";
  window.open(file, "CopyRight", "width=300,height=120,scrollbars=no,status=no,resizable=no,toolbar=no");
}


function opennewwindow(file) {
  self.name = "parent";
  window.open(file, "");
}


function getlastupdateDATE() {

			var month = new Array("Jan","Feb","March","April","May","June","July","August","Sept","Oct","Nov","Dec")
			dayName = new Array("Saturday","Sunday","Monday","Tuesday", "Wednesday", "Thursday","Friday")

			var today = new Date(document.lastModified)
			var theday = today.getDay() + 1
			var themonth = today.getMonth()
			var thedate = today.getDate()
			var theyear = today.getYear()
			var thehour =  (today.getHours() > 12 ? today.getHours()-12 : today.getHours())
			var themin = (today.getMinutes()>9 ? ":" : ":0") +today.getMinutes()
			var AMPM = (today.getHours() > 12 ? "PM" : "AM")



	var theyear = theyear % 100
	theyear += (theyear < 38) ? 2000 : 1900

			//var sContentUpdate = dayName[theday] + ", " + 
			//month[themonth] + " " + thedate + ", " + theyear + ", " + thehour +  themin + " " + AMPM

			var sContentUpdate = month[themonth] + " " + thedate + ", " + theyear 

			document.write(sContentUpdate)
}

function returnDocument() {
        var file_name = document.location.href;
        var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
        var nameoffile =  file_name.substring(file_name.lastIndexOf("/")+1, end);


	if (nameoffile == 'Welcome.html')
	{
	   var x=document.getElementById("id6");
	   x.style.visibility = 'hidden'; 
	}

    }

function GetCopyRightYear() {
	//Start date of year of copyright
	var SDY = "2009"
	var d = new Date()
	var theyear = d.getYear() % 100
	theyear += (theyear < 38) ? 2000 : 1900
	if (theyear == 2004)
	{
	theyear = "2004"
	}
	else
	{
	theyear = "2004-" + theyear
	}
	document.write(theyear)
}

function getIEVersion() {
	var appV = navigator.appVersion;
	if (appV.indexOf("6.0") > 1 || appV.indexOf("5.5") > 1)
	{
		alert("You are running an older version of Internet Explorer and is incompatible with A.Yankowski's website. Please upgrade your browser. You will be redirected to an alternate site.");
	window.location="http://www.bohol-archaeology.com/";
	}
	else
	{
		alert(navigator.appName);
		alert(navigator.appName + ", " + navigator.appVersion);
	}
}


function HideCreatedText()
{
	setTimeout("HideCText()",5000);
	
}

function HideCText()
{
	opacity("ADText", 100, 0, 3000);
}

function ShowEnterSite()
{
	setTimeout("ShowES()",5000);
}

function ShowES()
{
	ShowESText.style.display = "";
}


function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

function applyzoom(h1, w1, l1, t1, href1, href2, capt, id_c, h1_c, w1_c,l1_c,t1_c) {
document.write("<div id='magnify' class='imgcontainer' style='height: "+ h1 +"px; width: "+ w1 +"px;  position: absolute; left: "+ l1 +"px; top: "+ t1 +"px;'><a class='image'></a><a href="+href1+" class='highslide' onclick='return hs.expand(this)'><img id='imgborder' src='"+href2+"' title='Click to enlarge'/></a></div><div class='highslide-caption'>"+capt+"</div><div id='closebutton' class='highslide-overlay closebutton' onclick='return hs.close(this)' title='Close'></div>");


document.write("<div id='"+id_c+"' style='position: absolute; height: "+h1_c+"px; width: "+w1_c+"px; left: "+l1_c+"px; top: "+t1_c+"px; z-index: 2; '><div class='captionboxdiv'><p id='thumbcontainer'>"+capt+"</p></div></div>");

}

function applyzoomV2(h1, w1, l1, t1, href1, href2, capt, id_c, h1_c, w1_c,l1_c,t1_c) {
document.write("<div class='imgcontainer' style='width:"+w1+"px; height:"+h1+"px; position: absolute; left:"+l1+"px; top:"+t1+"px;z-index:1;'><a href="+href1+" class='highslide' onclick='return hs.expand(this)'><div style='background-image:url("+href2+"); background-repeat: no-repeat;width:"+w1+"px; height:"+h1+"px; background-position:center; opacity:  1.0; -moz-opacity:  1.0; filter:alpha(opacity=100);'><div style='background-image: url(../AndreaYankowski/AYImages/magnifier6.png); background-repeat: no-repeat; width:"+w1+"px; height:"+h1+"px; background-position: bottom right; opacity:  0.40; -moz-opacity:  0.40; filter:alpha(opacity=40);'></div></div></a><div class='highslide-caption'>"+capt+"</div></div>");

document.write("<div id='"+id_c+"' style='position: absolute; height: "+h1_c+"px; width: "+w1_c+"px; left: "+l1_c+"px; top: "+t1_c+"px; z-index: 1; '><div class='captionboxdiv'><p id='thumbcontainer'>"+capt+"</p></div></div>");
}


function imagezoom(image, s_caption, l_caption)
{

var imagedir = '../assets/images/' + image + '.jpg';
var thumbdir = '../assets/thumbs/' + image + '_thumb.jpg';


document.write("<div class='thumbnail'>");
document.write("<a title='Click to enlarge' onclick='return hs.expand(this)' class='highslide' href=" + imagedir + "><div class='imgcontainer' style='background-image:url(" + thumbdir + "); background-repeat: no-repeat;width:75px; height:75px; background-position:center; opacity:  1.0; -moz-opacity:  1.0; filter:alpha(opacity=100);'><div style='background-image: url(../AYImages/magnifier6.png); background-repeat: no-repeat; width:80px; height:80px; background-position: bottom right; opacity:  0.40; -moz-opacity:  0.40; filter:alpha(opacity=40);'></div>");
document.write("</div></a>" + s_caption + "<div class='highslide-caption'>" + l_caption + "</div></div>");
}


function applyimaging2(image,capt)
{
var image1="../assets/images/"+image+".jpg";
var image2="../assets/thumbs/"+image+"_thumb.jpg";
var capt1=capt;

var len=47

   if (capt.length> len) {
    capt = capt.substring(0, len);
    capt = capt.replace(/\w+$/, "");
    capt = capt.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
    capt += "...";
  }

document.write("<div id='thisslideshow' class='thumbnail'><a title='Click to enlarge' onclick='return hs.expand(this)' class='highslide' href="+image1+"><div class='imgcontainer2'  style='background-image:url("+image2+");'><div class='img_style2' style='background-image:url(../AYImages/magnifier6.png);'></div></div></a><div class='desc'>"+capt+"</div><div class='highslide-caption'>"+capt1+"</div></div>");
}



