URL:    [ Dan Winchester Home ] [ View Source Home ] 
HTTP/1.1 200 OK
Date: Fri, 06 Aug 2010 12:39:17 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Wed, 07 Feb 2007 06:42:43 GMT
ETag: "5de835d-1221-3bccbec0"
Accept-Ranges: bytes
Content-Length: 4641
Connection: close
Content-Type: application/x-javascript

// control the max width of image

function resize_me(img,maxwidth){
	if (img.width > maxwidth){
		img.width=maxwidth;
		}
	}
	

function check_elements(elements,elementtype){
	if((!elementtype)||(elementtype=='')){
		elementtype=0;
	}
	
	var returns=true;
	var item_value, item_mode;
	elementlists=new Array();
	elementlists=elements.split("||");
	for(i=0;i<elementlists.length;i++){
		if(elementlists[i].substring(0,4) == "fck-") {
			var fck_id = elementlists[i].substr(4);
			item_mode = 'fck';
			item_value = FCKeditorAPI.GetInstance(fck_id).GetXHTML();			
		}
		else if(document.getElementById(elementlists[i])){
			item_mode = 'id';
			item_value = document.getElementById(elementlists[i]).value;
		}
		else {
			returns=false;
			alert("エラー、管理者とご連絡ください。");
			return returns;
		}
		if(item_value == '') {
			returns=false;
			alert("全ての項目を記入してください。");
		}
		else if((elementtype==1)&&(isNaN(document.getElementById(elementlists[i]).value)==true)){
			returns=false;
			alert("全ての項目をチェックしてください。");			
		}
		if(returns == false) {
			if(item_mode == 'id') {
				document.getElementById(elementlists[i]).focus();
			}
			else {
				FCKeditorAPI.GetInstance(fck_id).Focus();
			}
			return false;
		}
	}
	return returns;		
}

function form_check() {
	var i, id, args, conds, value, check2;
	for(i=0; i<arguments.length; i++) {
		args = arguments[i].split("|");
		id = args[0];
		switch(args.length) {
			case 1:
				if(document.getElementById(id).value == '') {
					document.getElementById(id).focus();
					alert("全ての項目を記入してください。");
					return false;
				}
				break;
			case 2:
				check2 = false;
				conds = args[1].split(":");
				if(conds.length == 2) check2 = true;		
				switch(conds[0]) {
					case 'fck':
						value = FCKeditorAPI.GetInstance(id).GetXHTML();
						if(value == '') {
							FCKeditorAPI.GetInstance(id).Focus();
							alert("全ての項目を記入してください。");
							return false;
						}
						break;
					case 'num':
						value = document.getElementById(id).value;
						if(isNaN(value)) {
							document.getElementById(id).focus();
							alert("全ての項目をチェックしてください。");
							return false;
						}
						break;
					case 'email':
						value = document.getElementById(id).value;
						var arr,email_re = new RegExp("^[_a-z0-9-]+(\.[_a-z0-9-]*)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$","ig");
						if(arr = email_re.exec(value) == null && ((check2)?(!length_check(value,conds[1])):true)) {
							document.getElementById(id).focus();
							alert("Eメールアドレスをチェックしてください");
							return false;
						}
						break;
					case 'http':
						value = document.getElementById(id).value;
						var http_re = new RegExp("^http://{1}([_a-z0-9-]+[.]){1,3}","i");
						if(http_re.exec(value) == null && ((check2)?(!length_check(value,conds[1])):true)) {
							document.getElementById(id).focus();
							alert("サイトURLをチェックしてください");
							return false;
						}
						break;
				}				
				break;
		}		
	}
	return true; 
}

function DrawImage(ImgD, width, height){ 
	var image=new Image(); 
 	image.src=ImgD.src; 
 	if(image.width>0 && image.height>0){ 
  		flag=true; 
  		if(image.width/image.height>= width/height){ 
   			if(image.width>width){  
   				ImgD.width=width; 
   				ImgD.height=(image.height*width)/image.width; 
   			}else{ 
   				ImgD.width=image.width;  
   				ImgD.height=image.height; 
   			}	 
   		}else{ 
   			if(image.height>height){  
  				ImgD.height=height; 
   				ImgD.width=(image.width*height)/image.height;    
   			}else{ 
   				ImgD.width=image.width;  
   				ImgD.height=image.height; 
   			} 
   		} 
  	} 
} 

function showItem(id)
{
	document.getElementById(id).style.display = "block";
}

function hideItem(id)
{
	document.getElementById(id).style.display = "none";
}

function htmlTag(code)
{
	var re0 = /<br \/>/ig;
	code = code.replace(re0, '');
	var str='';
	var re = /<(\/\s*)?((\w+:)?\w+)(\w+(\s*=\s*((["'])(\\["'tbnr]|[^\7])*?\7|\w+)|.{0})|\s)*?(\/\s*)?>/ig;
	var tags = code.match(re);
	if(tags == null) {
		str = '';
	} else {
		var br_pos = Math.floor(tags.length/2) -1;
		for(var i=0;i<tags.length;i++) {
			if(tags[i].substr(0,4) == '<img') {
				br_pos--;
			} else if(tags[i].substr(0,5) == '</img') {
				
			} else {
				str += tags[i];
			}
			if(i == br_pos) str+= '<br />';
		}
	}
	return str;
}

function ImgError(imgthis){
	imgthis.src='img/error.gif';
}
 Questions or comments welcome: contact me.