// JavaScript Document

	function validate(f){	
		if(f.s_name.value == ""){
			alert("Some essential information is missing: Your Name");
			f.s_name.focus(); 
			return false;
		}
		else if(f.s_email.value == ""){
			alert("Some essential information is missing: Your E-mail Address");
			f.s_email.focus(); 
			return false;
		}
		else if(f.r_name.value == ""){
			alert("Some essential information is missing: Name of Person who will Receive the Message");
			f.r_name.focus(); 
			return false;
		}
		else if(f.r_email.value == ""){
			alert("Some essential information is missing: The E-mail Address of the Person who will Receive the Message");
			f.r_email.focus(); 
			return false;
		}
		else{
			return true;
		}	
	}		

	function getPos(el,sProp) {
		var x=-1;
		var y=-1;
		
		var iPos = 0;
			if (el.offsetParent)
				while (el.offsetParent) {
					iPos+=el["offset" + sProp];
					el = el.offsetParent;
				}
			else{
				if ((sProp == "Left") && (el.x)){
					iPos += el.x;
				}
				else{
					iPos += el.y;
				}
			}
		return iPos;
	}

	function hide_div(c_name){
		var y = document.getElementsByTagName('div');
		var y_len = y.length;
		
		var i;
		for (i=0; i<y_len; i++ ){
			if(y[i].className == c_name){
				y[i].style.display = "none";
			}
		}
	}	
	
	function display_card(c, fid){
		if (document.layers) {browserType = "nn4"}
		if (document.all) {browserType = "ie"}
		if (window.navigator.userAgent.toLowerCase().match("gecko")) {browserType= "gecko"}

		
		if (browserType == "gecko" ){
			x = document.getElementById(fid);
			var le;
			if (x.style.display == "none"){
				hide_div('float_story');
				le = getPos(c,"Left") + c.offsetWidth
				x.style.left = le + "px";
				x.style.top = (getPos(c,"Top")+c.offsetHeight)+ "px";
				x.style.display = "block";
			}
			else{
				hide_div('float_story');
			}				
		}
		else if (browserType == "ie"){
			x = document.all[fid];
			if (x.style.display == "none"){
				hide_div('float_story');
				le = getPos(c,"Left") + c.offsetWidth
				x.style.left = le + "px";
				x.style.top = (getPos(c,"Top")+c.offsetHeight)+ "px";
				x.style.display = "block";
			}
			else{
				hide_div('float_story');
			}							
		}
		else {
			x = document.layers[fid];
			if (x.style.display == "none"){
				hide_div('float_story');
				x = document.layers[fid];
				x.style.left = (getPos(c,"Left") + c.offsetWidth) + "px";
				x.style.top = (getPos(c,"Top")) + "px";
				x.style.display = "block";
			}
			else{
				hide_div('float_story');
			}
		}		
	}

	function change_class(c1, c2, id, id_prefix, total){
		var i;
		for (i = 0; i < total; i++){
			var a = document.getElementById(id_prefix+i);
			if (a.className == c1){
				a.className = c2;
			}
		}
		document.getElementById(id).className = c1;
	}

	function findURL(url){
		var c, cc, c_ind, l, pos1, pos2, str1, str2;

		c = url.lastIndexOf("/Welsh/");
		cc = url.lastIndexOf("/Cymraeg/");
		c_ind = url.lastIndexOf("dysguars4c");
		l = url.length;
		pos1 = url.lastIndexOf("/");
		str2 = url.substr(pos1+1);
		
		if ((c < 0) && (cc<0)){
			str1 = url.substr(0,pos1+1);
			if (c_ind<0){
				return (str1 + "Welsh/" + str2);
			}
			else{
				return (str1 + "Cymraeg/" + str2);
			}
			// return (c);
		}
		else{
			if (c>0){
				pos2 = url.indexOf("/Welsh/");
			}
			if(cc>0){
				pos2 = url.indexOf("/Cymraeg/");			
			}			
			str1 = url.substr(0, pos2+1);
			return (str1+str2);
		}
	}	




