function isURL(urlStr) {
if (urlStr.indexOf(" ") != -1) {
alert("Spaces are not allowed in a URL");
return false;
}

if (urlStr == "" || urlStr == null) {
return false;
}

urlStr=urlStr.toLowerCase();

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var atom=validChars + '+';
//var urlPat=/^http:\/\/(\w*)\.([\-\+a-z0-9]*)\.(\w*)/;
var urlPat=/^[(http:\/\/(\w*))|(\w*)]*\.([\-\+a-z0-9]*)\.(\w*)/;
var matchArray=urlStr.match(urlPat);

if (matchArray==null) {
//alert("The URL seems incorrect \ncheck it begins with http://\n and it has 2 .'s");
return false;
}

var user=matchArray[2];
var domain=matchArray[1];

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
//alert("This domain contains invalid characters.");
return false;
}
}

for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i) > 127) {
//alert("This domain name contains invalid characters.");
return false;
}
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;

for (i=0;i<len;i++) {
if (domArr[i].search(atomPat) == -1) {
//alert("The domain name does not seem to be valid.");
return false;
}
}

return true;
}

function isEmailAddress(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    
		    return false
		 }

 		 return true					
	}


function ajax(a){
	var h = getUniqueId() ;
	if(!a.b) a.b='';
	if(!a.c) a.c=function(){};
	if(!a.d) a.d=function(){};
	return jQuery.ajax({
		url:a.a+'.php',
		data:a.b,
		type:'POST',
		dataType:'php',		
		error: a.c,
		success: a.d
	});
}
function ajaxfile(a){
	var h = getUniqueId() ;
	if(!a.b) a.b='';
	if(!a.c) a.c='';
	if(!a.d) a.d='';
	if(!a.e) a.e='';
	if(!a.f) a.f=function(){};
	if(!a.g) a.g=function(){};	
	return jQuery.ajaxFileUpload({
		url:a.a+'.php',
		secureuri:false,
		fileElements:a.b,
		preForm:a.c,
		prePost:a.d,
		data:a.e,
		type:'POST',
		dataType:'php',	
		error: a.f,
		success: a.g
	});
}

function AjaxCommon(a,b,c){
	  var rFormValues = new Array();
		rFormValues[rFormValues.length] = 'act=add'; 
		rFormValues[rFormValues.length] = b+'='+escape(jQuery('#'+b).val()); 
	    rFormValues[rFormValues.length] = c+'='+escape(jQuery('#'+c).val()); 
		
		
		jQuery.ajax({
		url:a+'.php',
		data:rFormValues.join('&'),
		type:'POST',
		dataType:'php',		
			error: function(){			
			},
			success: function(data){
			$('#container').html(data);
				$("#container").hide();
		        $("#container").slideDown(1000);
		    }
		
		});
	
	}
	function AjaxEditCommon(a,b,c,d){
	  var rFormValues = new Array();
		rFormValues[rFormValues.length] = 'act=edit'; 
		rFormValues[rFormValues.length] = b+'='+escape(jQuery('#'+b).val()); 
	    rFormValues[rFormValues.length] = c+'='+escape(jQuery('#'+c).val()); 
		rFormValues[rFormValues.length] = d+'='+escape(jQuery('#'+d).val()); 
		
		jQuery.ajax({
		url:a+'.php',
		data:rFormValues.join('&'),
		type:'POST',
		dataType:'php',		
			error: function(){			
			},
			success: function(data){
				
				$('#container').html(data);
				$("#container").hide();
		        $("#container").slideDown(1000);
		    }
		
		});
	
	}
function getUniqueId(){
     var oDate = new Date();
     var uniqueId = oDate.getFullYear() + '' + oDate.getMonth() + '' + oDate.getDate() + '' + oDate.getTime();
     return uniqueId;
};
function blank(){}
function callFn(a, b){
	if(!b)b='';
	_w.setTimeout(a+'('+b+')', 1);
}
function updateConfigQS(a, b){
	a.d = b;
}

function scrollToAnchor(a, b){
	if(!b) b=function(){}
  	$objhash = '#'+a ; 
	var $target = $($objhash);
	$target = $target.length && $target || $('[name=' + $objhash.slice(1) +']');
	if ($target.length) {
		var targetOffset = $target.offset().top;
		$('html,body').animate({scrollTop: targetOffset}, 1000, '', b);
		return false;
	}  
};
function openCMWindow(url, w, h){ dWin = dhtmlmodal.open("oWindow", "iframe", url, '', "width="+w+"px,height="+h+"px,center=1,resize=1,scrolling=1", "recal"); dWin.statusarea.style.display = 'none' ; dWin.handle.style.display = 'none' ; dWin.contentarea.style.paddingTop = '0px' ; dWin.contentarea.style.paddingLeft = '0px' ; dWin.contentarea.style.paddingRight = '0px' ; dWin.contentarea.style.paddingBottom = '0px' ; dWin.contentarea.style.borderStyle = 'none' ; dWin.style.borderStyle = 'none' ; window.top.dWin=dWin; return dWin ; }
function openInlineWindow(content, w, h){ dWin = dhtmlmodal.open("oWindow", "inline", content, '', "width="+w+"px,height="+h+"px,center=1,resize=1,scrolling=1", "recal"); dWin.statusarea.style.display = 'none' ; dWin.handle.style.display = 'none' ; dWin.contentarea.style.paddingTop = '0px' ; dWin.contentarea.style.paddingLeft = '0px' ; dWin.contentarea.style.paddingRight = '0px' ; dWin.contentarea.style.paddingBottom = '0px' ; dWin.contentarea.style.borderStyle = 'none' ; dWin.style.borderStyle = 'none' ; window.top.dWin=dWin; return dWin ; }
function closeCMWindow(){window.top.dWin.hide();}
function replaceQuotes(str){ str=str.replace("'", "") ; return str.replace('"', '') ;}
function IntCast($Num){$Num = parseInt($Num, 10); return isNaN($Num)?0:$Num;}
function FloatCast($Num){$Num = parseFloat($Num); return isNaN($Num)?0:$Num;}

function tinyMCEAddID(id){
	tinyMCE.execCommand( 'mceAddControl', true, id);
}

function tinyMCERemoveID(id){
    tinyMCE.execCommand( 'mceRemoveControl', true, id);
}

function tinyMCEInit(){
tinyMCE.init({
// General options

mode : "textareas",

theme : "advanced",
editor_deselector : "mceNoEditor",
plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",

 

// Theme options

theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
/*
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",

theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",

theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
*/
theme_advanced_toolbar_location : "top",

theme_advanced_toolbar_align : "left",

theme_advanced_statusbar_location : "bottom",

theme_advanced_resizing : true,

 
content_css : "/kmch/css/style1.css"



});
}

