//THIS IS THE INTERFACE POPUP SCRIPT
function OpenWindow(page, popup) {
	
	var yes = 1;
	var no = 0;

	var menubar = no;      // The File, Edit, View Menus
	var scrollbars = no;   // Horizontal and vertical scrollbars
	var locationbar = no;  // The location box with the site URL
	var directories = no;  // the "What's New", "What Cool" links
	var resizable = yes;    // Can the window be resized?
	var statusbar = yes;    // Status bar (with "Document: Done")
	var toolbar = no;      // Back, Forward, Home, Stop toolbar

	var myleftpos = (window.screen.width/2) - (415); //+ 30);
	var mytoppos = (window.screen.height/2) - (320); //+ 40);

	windowprops = "width=" + (770) + ",height=" + (560) + ",top=" + mytoppos + ",left=" + myleftpos + "";

	windowprops += (menubar ? ",menubars" : "") +
	(scrollbars ? ",scrollbars" : "") +
	(locationbar ? ",location" : "") +
	(directories ? ",directories" : "") +
	(resizable ? ",resizable" : "") +
	(statusbar ? ",status" : "") +
	(toolbar ? ",toolbar" : "");


	window.open(page, popup, windowprops);
}
//to here



//THIS IS THE SCRIPT FOR ANY POPUPS IE IN THE GALLERY ETC
function popup(page, name, xsize, ysize, menubars, scrollbars, location, directories, resizable, status, toolbar) {

	var yes = 1;
	var no = 0;

	var myleftpos = (window.screen.width/2) - ((xsize/2) + 30);
	var mytoppos = (window.screen.height/2) - ((ysize/2) + 40);

	windowprops = "width=" + xsize + ",height=" + ysize + ",top=" + mytoppos + ",left=" + myleftpos + "";
	windowprops += "menubars=" + menubars + ",scrollbars=" + scrollbars + ",location=" + location + ",directories=" + directories + ",resizable=" + resizable + ",status=" + status + ",toolbar=" + toolbar;

	window.open(page, name, windowprops);
}
//to here




//THIS IS THE FIX WINDOW SCRIPT
function fixWin() {

  if (window.screen) {
    var mywidth = 786;
    var myheight = 591;
		var myleftpos = (window.screen.width/2) - (415);
		var mytoppos = (window.screen.height/2) - (320);
    window.top.moveTo(myleftpos, mytoppos);
    window.top.resizeTo(mywidth, myheight);
  }

}
//to here




//THIS IS THE MAXIMISE/MINIMISE SCRIPT
function maximiseWin() {
  if (window.screen) {
    var mywidth = screen.availWidth;
    var myheight = screen.availHeight;
    window.top.moveTo(0, 0);
    window.top.resizeTo(mywidth,myheight);
  }
}

function minimiseWin() {
	var leftpos = (window.screen.width/2) - (415);
	var toppos = (window.screen.height/2) - (320);
  window.top.moveTo(leftpos,toppos);
	window.top.resizeTo(786,591);
}
//to here




//THIS IS THE SCROLLBAR SCRIPT
//NOTE THIS WORKS WITH SELF AND PARENT

var H=null;
var speed=1;
var amount=10;
var nF=null;


function scrollme(frame,frameset){

	if (frameset == 'parent')
	{
		nF=parent[frame];
	}

	if (frameset == 'self')
	{
		nF=self[frame];
	}

	nF.document.body.appendChild(nF.document.createElement('<DIV id=iend>'));
    H=nF.iend.offsetTop-nF.document.body.offsetHeight;
}

function movedown(){
	if (nF.document.body.scrollTop!=H){
		nF.document.body.scrollTop+=amount;
		gdown=setTimeout('movedown();', speed);
	}
}

function moveup(){
	if (nF.document.body.scrollTop != 0){
		nF.document.body.scrollTop-=amount;
		gup=setTimeout('moveup();', speed);
	}
}

function stopdown(){
window.status='';
if(nF.document.body.scrollTop!=H){clearTimeout(gdown);}
}

function stopup(){
window.status='';
if(nF.document.body.scrollTop!=0){clearTimeout(gup);}
}







//	var y = 0;
//	var when = null;
//
//
//function movedown(frame,frameset) {
//
//	if (frameset == 'parent')
//	{
//		if (document.all && y < parent[frame].document.body.scrollHeight || document.height && y < parent[frame].document.height)
		//if (document.all && y < parent[frame].document.body.scrollHeight)
		//if (y < parent[frame].document.body.scrollHeight || y < parent[frame].document.height)
//		{ 
//			parent[frame].scroll(0,y); 
//			y = y + 4; 
//			when = setTimeout('movedown("' + frame + '","' + frameset + '")',1); 
//		}
//	} else {
//		if (document.all && y < self[frame].document.body.scrollHeight || document.height && y < self[frame].document.height)
		//if (y < self[frame].document.height)
//		{
//			self[frame].scroll(0,y); 
//			y = y + 4; 
//			when = setTimeout('movedown("' + frame + '","' + frameset + '")',1); 
//		}
//	}
//
//
//}
//
//
//
//function moveup(frame,frameset) {
//
//	if (frameset == 'parent') {
//  	if (y >= 0)
//		{
//   	  parent[frame].scroll(0,y);
//    	y = y - 4;
//    	when = setTimeout('moveup("' + frame + '","' + frameset + '")',1);
//  	}
//	} else {
//  	if (y >= 0)
//		{
//   	 	self[frame].scroll(0,y);
//    	y = y - 4;
//    	when = setTimeout('moveup("' + frame + '","' + frameset + '")',1);
//  	}
//	}

//}



//function stopme() {
//	clearTimeout(when);
//}
//to here




//THIS IS THE LOAD IMAGES AND ROLLOVER SCRIPT
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//to here




//THIS IS THE TABLE ROLLOVER EFFECT
function setCellBGcolor(id,color) { 
var c = document.getElementById ? document.getElementById(id) : 
document.all ? document.all[id] : 
document.layers ? document[id+'Outer'].document[id+'Inner'] : null; 
if (document.layers) { 
c.background.src = ''; 
c.bgColor = color; 
} else { 
c.style.background = ''; 
c.style.backgroundColor = color; 
} 
} 

function setCellBGimage(id,sImgSrc) { 
var c = document.getElementById ? document.getElementById(id) : 
document.all ? document.all[id] : 
document.layers ? document[id+'Outer'].document[id+'Inner'] : null; 
if (document.layers) { 
c.background.src = sImgSrc; 
} else { 
c.style.backgroundImage = 'url('+sImgSrc+')'; 
} 
} 
//to here




//THIS IS THE CLOCK

pX = 100;
pY = 100;
obs = new Array(13);

function ob() {
for (i = 0; i < 13; i++) {
if (document.all) obs[i] = new Array (eval('ob'+i).style,-100,-100);
else obs[i] = new Array (eval('document.ob'+i),-100,-100);
   }
}

function cl(a, b, c) {
if (document.all) {
if (a != 0) b += -1;
eval('c'+a+'.style.pixelTop='+(pY+(c)));
eval('c'+a+'.style.pixelLeft='+(pX+(b)));
}
else {
if (a != 0) b += 10;
eval('document.c'+a+'.top='+(pY+(c)));
eval('document.c'+a+'.left='+(pX+(b)));
   }
}

function runClock() {
for (i = 0; i < 13; i++) {
obs[i][0].left=obs[i][1]+pX;
obs[i][0].top=obs[i][2]+pY;
   }
}

var lastsec;
function timer() {

time = new Date ();
//document.write("time = ", time, "<br>");


sec = time.getSeconds();
if (sec != lastsec) {
lastsec = sec;
sec = Math.PI * sec / 30;
min = Math.PI * time.getMinutes() / 30;
hr = Math.PI * ((time.getHours()) + 1) / 6 + Math.PI * parseInt(time.getMinutes()) / 360;  //make sure to add 1 hour for france
for (i = 1; i < 6; i++) {
obs[i][1] = Math.sin(sec) * (44 - (i-1) * 11) - 16;
if (document.layers)obs[i][1] += 10;
obs[i][2] = -Math.cos(sec) * (44 - (i-1) * 11) - 12;
}
for (i = 6;i < 10; i++) {
obs[i][1] = Math.sin(min) * (40 - (i-6) * 10) - 16;
if (document.layers)obs[i][1] += 10;
obs[i][2] = -Math.cos(min) * (40 - (i-6) * 10) - 12;
}
for (i = 10; i < 13; i++) {
obs[i][1] = Math.sin(hr) * (37 - (i-10) * 11) - 16;
if (document.layers)obs[i][1] += 10;
obs[i][2] = -Math.cos(hr) * (37 - (i-10) * 11) - 12;
      }
   }
}
function setNum() {

//round
cl (0, -72, -64);
cl (1, 10, -51);
cl (2, 28, -33);
cl (3, 35, -8);
cl (4, 28, 17);
cl (5, 10, 35);
cl (6, -16, 42);
cl (7, -40, 35);
cl (8, -58, 17);
cl (9, -65, -8);
cl (10, -58, -33);
cl (11, -40, -51);
cl (12, -16, -56);

}
function startClock() {
ob();
setNum();
setInterval('timer()', 100);
setInterval('runClock()', 100);
}
// to here




//forms
function geturl(formname, fieldname) {
	var lien = prompt("ecrit le lien title","");
	var url = prompt("ecrit le url","");

	if ((url.indexOf("http://") == 0) || (url.indexOf("ftp.") == 0)){
		var mouse_out = '(window.status=""); return true';
		var mouse_over = '(window.status="- - -| open link in popup |- - -"); return true';
		var the_name = "<a href='" + url + "' target='_blank' onMouseOut='" + mouse_out + "' onMouseOver='" + mouse_over + "'>" + lien + "</a>";
		window.document[formname][fieldname].value+=the_name;
		window.document[formname][fieldname].focus();
	}
	else
	{
	alert ("Vous duvrais a entre un url avec le format \n'http://' ou 'ftp.' ");
	}

}





function getemail(formname, fieldname) {
	var lien = prompt("ecrit le email title","");
	var email = prompt("ecrit le addresse email","");

	if ((email.indexOf("@") != -1) && (email.indexOf(".") != -1)){
		var mouse_out = '(window.status=""); return true';
		var mouse_over = '(window.status="- - -| email me |- - -"); return true';
		var the_name = "<a href='mailto:" + email + "?subject=Le site de Zendco' onMouseOut='" + mouse_out + "' onMouseOver='" + mouse_over + "'>" + lien + "</a>";
		window.document[formname][fieldname].value+=the_name;
		window.document[formname][fieldname].focus();
	}
	else
	{
	alert ("Vous duvrais a entre un address email avec le format \n'nom@domain.ext' ");
	}

}




//voids textareas, fields, tick boxes, radio buttons and selects
function voidall(formname)
{

	for (i = 0; i < document[formname].length; i++) {
		window.document[formname].elements[i].value = ""; 
		window.document[formname].elements[i].checked = false;
		window.document[formname].elements[i].selectedIndex=0;
	}

}





//selects all tick boxes
function selectall(formname)
{

	for (i = 0; i < document[formname].length; i++) {
		window.document[formname].elements[i].checked = true;
	}

}
//to here






//for the cult3d mime
function finishedLoading_ns()
{
// initlialize the Cult3D variable
	if (typeof(Cult3D)=="object")
	{
		return;
	}
	// create the Cult3D_Object that can be used to communicate with the embedded
	// Cult3D object. The given string must match the name of the embedded CultObject.
	// Make sure that you give both the embedded object the same name both in IE and
	// netscape.
	Cult3D=new Cult3D_Object_ns("CultObject","Object");
	if (Cult3D == null) {
		alert("not loaded");
	}

	if(Cult3D == null)
	{
		alert("Cult3D variable could not be initialized!");
	}
	else
	{
		// set the isLoaded variable to true, to indicate that the CultObject is
		// ready to recieve commands via the Cult3D variable.
		isLoaded = true;
	}
	tmt_DivClip('Object','0','0','372','439');
	Cult3D.setAntiAliasingDelay(0.001);
}
//to here
