/*
***************************************************************
If you SoMeHoW managed to open this *CONGRATULATIONS*
I hope you find my scripts useful and please give credit for 
them as well as you would like to get credit for yours.

NOTE: This file was intended to be edited and used by only me, 
so if u cant understand something, go ahead and cry a lot.
Then email me at saulss1@gmail.com, ill be happy to help if 
i can.

Saul Salvatierra
***************************************************************

FUNCTIONS FOUND HERE:
splash() - writes the "see intro" button for the splah, also stablishes the cookies

cookieCreator(tcookieName,tvalue) - value is one single word only
getCookieVal(tcookieName)

cya(txt) - opens a window and closes it after some time with optional txt inside

load(url) - loads different urls into different frames of the site, ex: load(menu:menu2.html);

loadiframe(which,what)

hist(dir) - ffw,rew

loadother()

openw(url,comment)

comment(when)

loadfile()

message(type,message)

xpnd(website,w,h) - modified from the original
*/

//alert("srcpt.js functional");

//writes a button and splash setup - 4/21/2005

function lookForChild()
{
	if(getCookieVal("childUrl")&&getCookieVal("childUrl")!="none")
	{
		//alert("child found, "+getCookieVal('childUrl')+".");
		document.getElementById("mainIframe").src=getCookieVal("childUrl")
		cookieCreator("childUrl","none");
	}
}

function sendMeToParent()
{
	if(window == top)
	{
		cookieCreator("childUrl",document.location.href);
		//alert(getCookieVal("childUrl")+" looking for parent...")
		top.location.href = 'http://myarea.com.sapo.pt/';
	}
}


function splash()
{

if(document.cookie)
{
if(getCookieVal('visited')==1)
document.write("<button onclick=\"cookieCreator(\'visited\',0);document.location=\'splash.html\';\">See Intro</button>");
else
document.location="splash.html";
}
else
document.location="splash.html";

}

function cookieCreator(tcookieName,tvalue)
{
//this is my awesome cookie baker, Thursday, April 07, 2005
var value = tvalue;
var cookieName = tcookieName;

if(document.cookie != document.cookie) 
{
index = document.cookie.indexOf(cookie_name);
}
else 
{ index = -1;
}

if (index == -1)
{
document.cookie=cookieName+"="+value+"; expires=Monday, 04-Apr-2010 05:00:00 GMT;path=/;"
}
}

function getCookieVal(tcookieName)
{
//hursday, April 07, 2005
var cookieName = tcookieName;
if(document.cookie)
{
index = document.cookie.indexOf(cookieName);
if (index != -1)
{
namestart = (document.cookie.indexOf("=", index) + 1);
nameend = document.cookie.indexOf(";", index);
if (nameend == -1) {nameend = document.cookie.length;}
return document.cookie.substring(namestart, nameend);
}
}
}




function cya(txt)
{
	if (txt=="")txt="c ya!";
	dot="asdf";
	cya = window.open('','',config="height=50,width=100,location=no,status=no,resizable=no,toolbar=no,menubar=no,scrollbars=no,directories=no");
	cya.document.write("<body bgcolor='black'><scr"+"ipt>setTimeout('window.self.close()',1000);</script>");
	cya.document.write("<div style='text-align: center; color:Aqua;background-color:Black;font-family:Verdana;font-weight:bold;font-style:italic;font:25;'>"+txt);
	//setTimeout('cya.document.write("adsf")',1000);
	//setTimeout('cya.self.close()',5000);
	cya.document.write("</div></body>");
}

function load(url)
{
	var loc;
	if (url.indexOf(".com")>=0||url.indexOf(".net")>=0||url.indexOf(".org")>=0)//(loc.indexOf(".com")==-1) this is for false 
	{
		if(url.indexOf("http://www.")>=-1)
			loc="http://www."+url;
		else
			if(url.indexOf("http://")>=-1)
				loc="http://"+url;
			else
				loc=url;
		parent.frames[1].location=loc;
	}
	else
	{
		if(url.indexOf("menu:")>=0)
		{
			loc=url.replace("menu:","");
			parent.frames[0].location=loc;
		}
		else
		{
		if(url.indexOf("file:")>=0)
		{
			loc=url.replace("file:","");
			parent.frames[1].location=loc;
		}
		else
		if(url.indexOf("xpnd:")>=0)
		{
			loc=url.replace("xpnd:","");
			parent.frames[1].location=loc;
		}
		else
		if (url.indexOf(":")>=0)
			parent.frames[1].location=url;
		else
			if(confirm("Invalid address, Try again?"))
				loadother();
			else
				return;
		}
	}
	//alert(parent[1].location);
}

function loadiframe(which,what)
{
	//alert("now loading: "+what);
	if(which.indexOf('w1')>=0)
	{
		parent.frames['w1'].location.href = what;
		//i1.value = what;
		
	}
	
	if(which.indexOf('w2')>=0)
	{
		parent.frames['w2'].location.href = what;
		//i2.value = what;
		
	}
}

function hist(dir)
{
	if(dir.indexOf("fwd")>=0&&parent.frames[1].history.length>1)
	{
		parent.frames[1].history.go(1);
	}
	else
	if(dir.indexOf("rew")>=0)
	{
		parent.frames[1].history.go(-1);//history.back();
	}
	else
		alert("goin nowhere");
}

function loadother()
{
	var what = prompt("Enter the address, a regular url. OR\nTo open a local or online file, type \"file:\" followed by the complete path.","here!");
	if (what==null||what=="")
		alert("Operation canceled by user.");
	else
	if (what.indexOf("file:")>=0&&(what.indexOf("scrpt.js")>=0||what.indexOf("stl.css")>=0||what.indexOf("frms")>=0)||what.indexOf("menu")>=0)
	{
		what=what.replace("file:","");
		alert("Access denied.\nUnable to open file: \'"+what+"\'.");
	}
	else
		load(what);
}

function openw(url,comment)
{
url="http://www"+url;
window.open(url,'asdf',config="height=500,width=700,location=yes,status=yes,resizable=yes,toolbar=no,menubar=no,scrollbars=no,directories=no");
}


function comment(when)
{
	if(when=="")
	{
		var newdate=document.lastModified;
		var date=newdate.substring(3, 6)+newdate.substring(0, 3)+newdate.substring(8, 10);
	}
	else
		date==when;
	alert('Created by: \nSaul Salvatierra\nsaulss1@hotmail.com\n\nLast updated on: '+date+'.');
}

function loadfile()
{
loc=document.f.a.value;
alert(loc);
w=window.open(loc,'wind');
}
function opener()
{
window.open('opener.html','opner',config='height=100,width=500,location=no,status=no,resizable=no,toolbar=no,menubar=no,scrollbars=no,directories=no');
}

function message(type,message)
{
	if(type.indexOf('alert')>=0)
	{
		alert(message);
	}
	else
	if(type.indexOf('window')>=0)
	{
		message.replace("\n","<br>");
		msgw = window.open('','',config="height=100,width=300,location=no,status=no,resizable=no,toolbar=no,menubar=no,scrollbars=auto,directories=no");
		msgw.document.write("<body bgcolor='blue'>");
		msgw.document.write("<p><div style='text-align: left; color:white;background-color:none;font-family:Verdana;font-weight:bold;font-style:italic;font:15;'>"+message);
		msgw.document.write("</p></div></body>");
	}
	else
	{
		//message.replace("<br>","\n"); doesnt work for som reason
		alert(message);
	}
}

//http://home.wanadoo.nl/sinnemavlieger/martin

function xpnd(website,w,h) {
var heightspeed = 4; // vertical scrolling speed (higher = slower)
var widthspeed = 9;  // horizontal scrolling speed (higher = slower)
var leftdist = 220;    // distance to left edge of window
var topdist = 0;     // distance to top edge of window
if (document.all) {
var winwidth = w;
var winheight = h; 
var  sizer=    window.open("","","left=" + leftdist + ",top="+topdist +",width=1,height=1,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=yes");
for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) {
sizer.resizeTo("1", sizeheight);
}
for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed) {
sizer.resizeTo(sizewidth, sizeheight);
}
sizer.location = website;
}
else
window.location = website;
}
//  End -- designtimesp=28105>
//var winwidth = window.screen.availWidth - leftdist;
//var winheight = window.screen.availHeight - topdist;

<!-- ----------------------- My Timebar ----------------------> 
//this script was not written by me, got it from htmlgoodies i think.
function timebar()
{
document.write("<style>.hide 	{visibility:hidden; position:absolute}.showit {visibility:visible}</style>");
document.write("<table id='timetable' bgcolor=black width='650' ondblclick='this.className='hide';' onclick='this.className='showit';'>");
document.write("<td><img align=left src=exit.gif alt=EXIT onclick=window.self.close() height=30 width=60>"+
"<div  align=left>"+
"<FONT color=00ff00 face=Verdana>");
var weekdays = new Array(6);
var months = new Array(11);

var today = new Date();

var month = today.getMonth();
var date = today.getDate();
var weekday = today.getDay();
var year = today.getYear();
if (year <= 1000){
	year = year + 1900;
}
today = null;
	
weekdays[0] = "Sunday";
weekdays[1] = "Monday";
weekdays[2] = "Tuesday";
weekdays[3] = "Wednesday";
weekdays[4] = "Thursday";
weekdays[5] = "Friday";
weekdays[6] = "Saturday";

months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";
document.write(weekdays[weekday] + ", " + months[month] + "  " + date  + ", " + year);
// -->
document.write("</font></div>");




<!-- ----------clock----------- -->
//some script i got from somwhere i dont remember
function MakeArrayday(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function MakeArraymonth(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function theClock() {
if (!document.layers && !document.all)
return;
var runTime = new Date();
var hours = runTime.getHours();
var minutes = runTime.getMinutes();
var seconds = runTime.getSeconds();
var dn = "AM";
if (hours > 12) {
dn = "PM";
hours = hours - 12;
}
if (hours == 0) {
hours = 12;
}
if (minutes <= 9) {
minutes = "0" + minutes;
}
if (seconds <= 9) {
seconds = "0" + seconds;
}
movingtime = hours + ":" + minutes + ":" + seconds + " " + dn;
if (document.layers) {
document.layers.clock.document.write(movingtime);
document.layers.clock.document.close();
}
else if (document.all) {
clock.innerHTML = movingtime;
}
setTimeout("funClock()", 1000)
}
window.onload = theClock;
//  End -->


document.write("</td><td algn=right>"+
"<FONT color=00ff00 face=Verdana>"+
"<div align=right>"+
"<span id=clock></span>"+
"</div>"+
"</font>"+
"</td>"+
"</table>");

}
<!-- ----------------------- End My Timebar ---------------------- -->

