function trim(pstrString)
{
	if(typeof(pstrString)=="undefined") return false;
	
	var intLoop=0;
	for(intLoop=0; intLoop<pstrString.length; )
	{
		if(pstrString.charAt(intLoop)==" ")
		{
			pstrString=pstrString.substring(intLoop+1, pstrString.length);
		}
		else
			break;
	}

	for(intLoop=pstrString.length-1; intLoop>=0; intLoop=pstrString.length-1)
	{
		if(pstrString.charAt(intLoop)==" ")
				pstrString=pstrString.substring(0,intLoop);
		else
				break;
	}
return pstrString;
}

function getkey(e)
{
	if (window.event)
		return window.event.keyCode;
	else if (e)
		return e.which;
	else
		return null;
}	
function goodchars(e, goods)
{
	var key, keychar;
	key = getkey(e);
	if (key == null) 
		return true;
	// get character
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();
	// check goodkeys
	if (goods.indexOf(keychar) != -1)
		return true;
	// control keys
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
	return true;
	// else return false
	return false;
}
function process_password(e)
{
	var key;
	key = getkey(e);
	if (key==32)
	return false;
	return true;
}
function process_username(e)
{
	var key;
	key = getkey(e);
	if (key==32)
	return false;
	return true;
}
function process_cpassword(e)
{
	var key;
	key = getkey(e);
	if (key==32)
	return false;
	return true;
}
function process_coupon(e)
{
	var key;
	key = getkey(e);
	if (key==32)
	return false;
	return true;
}

// this function is used to check string contains special character or not
function special(strString) 
{
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?~_"; 
	var countSpclChar = 0;
	for (var i = 0; i < strString.length; i++) 
	{
		if (iChars.indexOf(strString.charAt(i)) != -1) 
		{
		  countSpclChar++;
		}
	}
	return countSpclChar;
}

// this function is used to render content using ajax
// parameters : url , div id , params to send with the url
function renderPage(url, renderTo, params)
{
       _showstatus(true);
		$.ajax({
			url: 	url,
			data:	params,
			type:	'POST',
			success: function(result, textStatus){
				var response = result;
				
				while (response.substring(response.length-1, response.length) == '\n')	{
					response = response.substring(0,response.length-1);
				}
				
				var renderes = renderTo.split(",");
				var responses = response.split("^^^");

				if(renderes.length>0)
				{
					for(i=0; i<renderes.length; i++)
					{
						$('#'+renderes[i]).html(responses[i]);
					}
				}				
				_showstatus(false);
			},
			error:function(XMLHttpRequest, textStatus, errorThrown){
				alert(XMLHttpRequest.status+'Request Timeout.\nPlease try again.');
				 _showstatus(false);
			}
	
		});
		return false;
}

function renderPageWithAlert(url, renderTo, params)
{
       _showstatus(true);
		$.ajax({
			url: 	url,
			data:	params,
			type:	'POST',
			success: function(result, textStatus){
					if (result != ""){
						var arr = result.split("^^^");
						if (arr[0] == 1){
							//$('#'+renderTo).html(arr[1]);
							alert(arr[1]);
							$('#'+renderTo).html(arr[2]);
						}
						else
						{
							alert(arr[1]);
							//alert(D_NOT_APPLICABLE.replace("[INFO]","news").replace("[ACTION]","featured").replace("[INFO]","news"));
						}
					}
					
					_showstatus(false);
			},
			error:function(XMLHttpRequest, textStatus, errorThrown){
				alert(XMLHttpRequest.status+'Request Timeout.\nPlease try again.');
				 _showstatus(false);
			}
	
		});
		return false;
}

//this function is used to show or hide loader
function _showstatus(on)
{
    if(on)
	{
		if (parseInt(navigator.appVersion)>3) 
		 {
			if (navigator.appName.indexOf("Microsoft")!=-1) 
			{
				winW = document.body.offsetWidth;
				winH = document.body.offsetHeight;
				var top1 = (winH) /2;
				
				if( getIEVersionNumber() == 8 )
				{
					var left1 = (winW - 500) /2;
				}
				else
				{
					var left1 = (winW - 750) /2;
				}

			}
			else 
			{
				winW = window.innerWidth;
				winH = window.innerHeight;
				var top1 = (winH) /2;
				var left1 = (winW - 350) /2;
			}
		}
		
		var msg = "<div id='loading'><img src='"+SITEURL+"/images/loader.gif' /></div>";
		
		$.blockUI({ 
		message: msg,
		css: {
						//top:  top1 + 'px', 
						top:  '42%', 
						left: left1+'px',
						border : 'none',
						fadeIn: 0,
						fadeOut: 0
			 }
		});
    }
	else
	{
		$.unblockUI();
    }
    return true;
}

function getIEVersionNumber() {
    var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");
    
    if (MSIEOffset == -1) {
        return 0;
    } else {
        return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
    }
}

//fnction is used to redirect page to given url in 5 seconds
function redirectPage(url)
{
	var sec = setTimeout("redirectUrl('"+url+"')", 5000);
}

//fnction is used to redirect page to given url
function redirectUrl(Url)
{
	window.location.href = Url;
}

// random coupon generator
function randomString()
{
    var text = "";
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

    for( var i=0; i < 6; i++ )
        text += possible.charAt(Math.floor(Math.random() * possible.length));

    return text;
}

// only for numbers
function onlyNumbers(evt)
{
	var e = evt; 
	var charCode = e.which || e.keyCode;

	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;

	return true;
}

// email validation
function checkEmail(email)
{
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (!filter.test(email))
	{
		return true;
	}
	else
		return false;
}

// show loader in text box
function showLoader(elementId,imgUrl)
{
		//alert(imgUrl);
		if(imgUrl != '')
		{
			$('#'+elementId).css('background-image', 'url('+imgUrl+')');
			$('#'+elementId).css('background-repeat', 'no-repeat');
			$('#'+elementId).css('background-position', 'right');
		}
		else
		{
			$('#'+elementId).css('background-image', 'none');
		}
	
}

// hide loader in text box
function hideLoader(elementId)
{
		$('#'+elementId).css('background-image', 'none');
}

// show div in blockUI
function showBlockUI(content)
{
	_showstatus(true);
	var top1 = ($(window).height() - 500) /2;
	var left1 = ($(window).width() - 1020) /2;
	$.blockUI({ 
	message: content,
	css: {
					top:  '175px', 
					left: '450px',
					color: '#000000',
					width: 'auto',
					cursor: 'normal',
					border :'0px',
					background: 'none'
		 }
	});
}


function fix_window_position(div, top, position)
{//alert(widthPx);
//alert(heightPx);
	var widthPx = $("#"+div).width();
	var heightPx = $("#"+div).height();
	var windowDim = getWindowSize();
	var scroll = getScrollXY();
	if (parseInt(navigator.appVersion)>3) 
	{
		if (navigator.appName.indexOf("Microsoft")!=-1) 
		{
			//winW = document.body.offsetWidth;
		
			//var top1 = (Number(windowDim.Y)/2 - Number(heightPx)/2 +  scroll.Y) - 45;
			var top1 = (Number(windowDim.Y)/2 - Number(heightPx)/2) - 45;
			var left1 = ((Number(windowDim.X) - parseInt(widthPx)) /2 +  Number(scroll.X)) + 285;
			if( getIEVersionNumber() == 8 )
			{
				left1 = ((Number(windowDim.X) - parseInt(widthPx)) /2 +  Number(scroll.X)) + 285;
			}
			else
			{
				left1 = ((Number(windowDim.X) - parseInt(widthPx)) /2 +  Number(scroll.X)) + 285;
			}
		}
		else 
		{
			//alert(Number(windowDim.Y));
			//alert(Number(heightPx));
			//alert(scroll.Y);
			//var top1 = (Number(windowDim.Y)/2 - Number(heightPx)/2 +  scroll.Y) - 45;
			var top1 = (Number(windowDim.Y)/2 - Number(heightPx)/2) - 45;
			var left1 = ((Number(windowDim.X) - parseInt(widthPx)) /2 +  Number(scroll.X)) + 285;
		}
	}
	// POSITION: absolute; TOP: 100px;
	//$("#"+div).css("position", "absolute");
	if(position!='')
	{
		$("#"+div).css("position", position);
	}
	//alert(top1);
	$("#"+div).css("top",top1); 
	$("#"+div).css("left",left1); 
	
}

function fix_window_positionFE(div, top, position)
{//alert(widthPx);
//alert(heightPx);
	var widthPx = $("#"+div).width();
	var heightPx = $("#"+div).height();
	var windowDim = getWindowSize();
	var scroll = getScrollXY();
	if (parseInt(navigator.appVersion)>3) 
	{
		if (navigator.appName.indexOf("Microsoft")!=-1) 
		{
			//winW = document.body.offsetWidth;
		
			var top1 = (Number(windowDim.Y)/2 - Number(heightPx)/2 +  scroll.Y) - 45;
			//var top1 = (Number(windowDim.Y)/2 - Number(heightPx)/2) - 45;
			var left1 = ((Number(windowDim.X) - parseInt(widthPx)) /2 +  Number(scroll.X)) + 285;
			if( getIEVersionNumber() == 8 )
			{
				left1 = ((Number(windowDim.X) - parseInt(widthPx)) /2 +  Number(scroll.X)) + 285;
			}
			else
			{
				left1 = ((Number(windowDim.X) - parseInt(widthPx)) /2 +  Number(scroll.X)) + 285;
			}
		}
		else 
		{
			//alert(Number(windowDim.Y));
			//alert(Number(heightPx));
			//alert(scroll.Y);
			var top1 = (Number(windowDim.Y)/2 - Number(heightPx)/2 +  scroll.Y) - 45;
			//var top1 = (Number(windowDim.Y)/2 - Number(heightPx)/2) - 45;
			var left1 = ((Number(windowDim.X) - parseInt(widthPx)) /2 +  Number(scroll.X)) + 285;
		}
	}
	// POSITION: absolute; TOP: 100px;
	//$("#"+div).css("position", "absolute");
	if(position!='')
	{
		$("#"+div).css("position", position);
	}
	//alert(top1);
	$("#"+div).css("top",top1); 
	$("#"+div).css("left",left1); 
	
}


function getScrollXY() 
{

		var scrOfX = 0, scrOfY = 0;
		
		if (typeof (window.pageYOffset) == 'number') {
		
		//Netscape compliant
		
		scrOfY = window.pageYOffset;
		
		scrOfX = window.pageXOffset;
		
		} else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
		
		//DOM compliant
		
		scrOfY = document.body.scrollTop;
		
		scrOfX = document.body.scrollLeft;
		
		} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
		
		//IE6 standards compliant mode
		
		scrOfY = document.documentElement.scrollTop;
		
		scrOfX = document.documentElement.scrollLeft;
		
		}
		
		return { X: scrOfX, Y: scrOfY };

}


function getWindowSize()
{
	var myWidth = 0, myHeight = 0;
	if (typeof (window.innerWidth) == 'number') {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
	//IE 4 compatible
	myWidth = document.body.clientWidth;
	myHeight = document.body.clientHeight;
	}
	return { X: myWidth, Y: myHeight }
}

function openDhtmlWithElmt(eId,widthPx,heightPx)
{
	if (parseInt(navigator.appVersion)>3) {
		 if (navigator.appName=="Netscape") {
			  winW = window.innerWidth;
			  winH = window.innerHeight;
		 }
		 if (navigator.appName.indexOf("Microsoft")!=-1) {
			  winW = document.documentElement.clientWidth;
			  winH = document.documentElement.clientHeight;
		 }
	}
	var top1 = (winH - heightPx) /2;
	var left1 = (winW - widthPx) /2;

	$.blockUI({ 
		message: $('#'+eId),
		css: { 
			left: left1 + 'px',
			top:  top1 + 'px',
			border: 'none',
			cursor: 'default',
			background: 'transparent',
			"text-align":'left'
			
		}
	});
}

function openDhtmlWithElmtMap(eId,blockElementId,widthPx,heightPx)
{
	if (parseInt(navigator.appVersion)>3) 
	{
		if (navigator.appName.indexOf("Microsoft")!=-1) 
		{
			winW = screen.width;
			winH = screen.height;
			var top1 = (winH) /2;
			var left1 = (winW - parseInt(widthPx)) /2;
		}
	//if (navigator.appName=="Netscape") 
		else 
		{
			winW = screen.width;
			winH = screen.height;
			var top1 = (winH) /2;
			var left1 = (winW - parseInt(widthPx)) /2;
		}
	}
		var top1 = ($(window).height() - 450) /2;
		//var left1 = ($(window).width() - 950) /2;
		//alert(winH);
		$.blockUI({ 
			message: $('#'+eId),
			css: {
					top:  '30px', 
					left: left1+'px',
					width: widthPx,
					height: '390px',
					border : '0px',
					cursor: 'normal',
					padding: '0px'
				 }
			});
		//alert(document.getElementById(eId).style.top);
}

function win2col(url2col){
	window.open(url2col,'BP','width=433,height=500,status=no,resizable=no,top=110,left=200,toolbar=no,menubar=no,scrollbars=yes')
}

function setVisibility(id, visibility) {
	if(visibility == 'show')
		$('#'+id).show();
	else
		$('#'+id).hide();
	
	return false;
}

///News and Expert Advise Section-----Done By Sujay on 23rd June 2011

function MakeActiveInactive(Params,PageName,Section,Status)
{
	var section = SetVariable(Section);
	if(Status == 1) {
		var STATUS_CONFIRM = C_ACTION.replace("[ACTION]","activate this "+section);
	}
	else	{
		var STATUS_CONFIRM = C_ACTION.replace("[ACTION]","deactivate this "+section);
	}
	if(confirm(STATUS_CONFIRM))
	{
		var action =  'deactivate this';
		if(Section == 'expert-advice')
		{
			action =  'deactivate this';
		}
		_showstatus(true);
		$.ajax({
		   type: "POST",
		   url: PageName,
		   data: Params,
		   success: function(response){
				_showstatus(false);
				if (response != ""){
					var arr = response.split("^^^");
					if (arr[0] == 1){
						//alert(S_CHANGED.replace("[INFO]","Status"));
						$("#grid").html(arr[1]);
					}
					else
					{
						alert(S_NOT_CHANGED.replace("[INFO]",""+section).replace("[ACTION]",""+action).replace("[INFO]",""+section));
					}
				}
		   }
		});
		return false;
	}
	
}

function ShowInHomePage(Params,PageName,Section)
{
	var section = SetVariable(Section);
	if(confirm(SHOW_IN_HOME.replace("[INFO]",""+section)))
	{
		_showstatus(true);
		$.ajax({
		   type: "POST",
		   url: PageName,
		   data: Params,
		   success: function(response){
				_showstatus(false);
				if (response != ""){
					var arr = response.split("^^^");
					if (arr[0] == 1){
						//alert(F_SUCCESS.replace("[INFO]",""+section));
						$("#grid").html(arr[1]);
					}
					else if (arr[0] == 2){
						alert(SHM_UNSUCCESS.replace("[INFO]",""+section));
					}
					else
					{
						alert(E_TECH_PROBLEM);
					}
				}
		   }
		});
		return false;
	}
	
}

function Delete(Params,PageName,Section,Status)
{
	var section = SetVariable(Section);
	if(Status == 1) {
		var DELETE_CONFIRM = "This "+section+" is active. "+C_ACTION.replace("[ACTION]","delete this "+section);
	}
	else	{
		var DELETE_CONFIRM = C_ACTION.replace("[ACTION]","delete this "+section);
	}
	if(confirm(DELETE_CONFIRM))
	{
		var action =  'delete this';
		if(Section == 'expert-advice')
		{
			action =  'delete this';
		}
		
		_showstatus(true);
			$.ajax({
			   type: "POST",
			   url: PageName,
			   data: Params,
			   success: function(response){
			   		_showstatus(false);
					if (response != ""){
						var arr = response.split("^^^");
						if (arr[0] == 1){
							$("#grid").html(arr[1]);
							
						}
						else if(arr[0] == 2)
						{
							
							alert(D_NOT_APPLICABLE_FOR_ACTIVE.replace("[INFO]",""+section).replace("[ACTION]",action).replace("[INFO]",""+section));
						}
						else
						{
							alert(D_NOT_APPLICABLE.replace("[INFO]",""+section).replace("[ACTION]",action).replace("[INFO]",""+section));
						}
					}
			   }
			});
			return false;
	}
}

function SetVariable(Section)
{
	var variable = '';
	if(Section == 'news')
	{
		variable = 'News';
	}
	else if(Section == 'expert-advice')
	{
		variable = 'Expert Advice';
	}
	return variable;
}

function Find(PageName,Section)
{
	//var Send = Params
	//renderPage(PageName, 'grid',"name="+escape($('#name').val())+"&list_page=yes");
	_showstatus(true);
		$.ajax({
		   type: "POST",
		   url: PageName,
		   data: "name="+escape($('#name').val())+"&list_page=yes",
		   success: function(response){
				_showstatus(false);
				if (response != ""){
					var arr = response.split("^^^");
					if (arr[0] == 1){
						$("#grid").html(arr[1]);
						//$('#name').val();
					}
				}
		   }
		});
		return false;
}

function openEditorNew(fieldName, width, height)
	{
		//alert(Toolbar);
		if($("#"+fieldName).val() != undefined){
			
			if(CKEDITOR.instances[fieldName])
			{
				//CKEDITOR.instances[fieldName].destroy();
				delete CKEDITOR.instances[fieldName];
			}
			//'Bold','Italic','Underline','-','Smiley','-','Link','Unlink'
			CKEDITOR.replace( fieldName,
			{
				 width: width+'px',
				 height: height+'px'/*,
				 toolbar :
				[
					['Bold','Italic','Underline','Link','Unlink']
				]*/
			});
			CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;
			//CKEDITOR.config.toolbarLocation = 'bottom';
			CKEDITOR.config.resize_enabled = false;
			$('#editorId').val(fieldName);
		}
	}
	
	function InstantiateOpenEditor(FieldId,Width,Height,Status,Toolbar)
	{
		$(document).ready(function(){
			var Ndesc = $('#'+FieldId).val();
			if($("#"+FieldId).val() != undefined){
				openEditorNew(FieldId, Width, Height);
				
				var oEditor = CKEDITOR.instances[FieldId];
				oEditor.setData('');
			}
			CKEDITOR.instances[FieldId].setData(Ndesc.replace(/\\/g, ''));
		});
	}
	
	function isUrl(value) 
	{
		var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
		if(regexp.test(value))
		{
			return(true);
		}
		return(false);
	}

////End of the news and expert advise section

/**** Auto suggest ****/
/**********************/
function autoSuggest(renderTo,urlWithparams)
{
	$("#"+renderTo).autocomplete(urlWithparams, {
		selectFirst: false
	});
	
}

function hideAutoSuggest(elementId){
	$('#'+elementId).blur();
	$('#'+elementId).focus();
}


function showTxt(fldid,val){
	if(val == 'Enter postcode'){
		$('#'+fldid).val('');
	}
}

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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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];}
}


function alertMsgWithCallBack(msg, callBackFnc)
{
	
	var div = '<div class="alert"><div class="alercont"><div class="forgotgraydiv"><p>'+msg+'</p><input type="button" class="okbtn" value="CLOSE" onclick="javascript:'+callBackFnc+';" /></div></div></div>';
	
	var top1 = ($(window).height() - 500) /2;
	var left1 = ($(window).width() - 1020) /2;
	$.blockUI({ 
	message: div,
	css: {
					top:  '175px', 
					left: '450px',
					cursor: 'normal',
					border :'0px',
					background:'transparent'
					
		 }
	});
}

function focusModal(id)
{
	$.unblockUI();
	if(id != '')
	{
		$('#'+id).focus();
	}
}

function strip_tags(input){

   return input.replace(/]+>/gi, '');

}

function showVideo(videoParamObj)
{
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) 
	{
		$('#'+videoParamObj.videoBlock).html('<iframe class="youtube-player" type="text/html" width="500" height="369" src="http://www.youtube.com/embed/'+videoParamObj.videoId+'?wmode=transparent&autoplay=1&rel=0" frameborder="0" ></iframe>');
	}else{
		//$('#'+videoParamObj.videoBlock).html('<iframe class="youtube-player" type="text/html" width="500" height="369" src="http://www.youtube.com/embed/'+videoParamObj.videoId+'?wmode=transparent&autoplay=1&rel=0" frameborder="0" ></iframe>');
		swfobject.embedSWF(videoParamObj.PlayerPath, videoParamObj.videoBlock, videoParamObj.stageWidth, videoParamObj.stageHeight, '9.0.45', videoParamObj.expressInstallPath+'/include/js/swfobject/expressinstall.swf', {}, {bgcolor: '#000000', menu: 'false', wmode: 'transparent', allowfullScreen: 'true', allowScriptAccess: 'always',flashvars:'videoType='+videoParamObj.videoType+'&videoId='+videoParamObj.videoId+'&autoPlay='+videoParamObj.autoPlay+'&isIntroImage='+videoParamObj.isIntroImage+'&isReplayImage='+videoParamObj.isReplayImage+'&stageWidth='+videoParamObj.stageWidth+'&stageHeight='+videoParamObj.stageHeight}, {id: videoParamObj.videoBlock});
	}
}

function CountWordsCharacter(evt, this_field, show_word_count, show_char_count,max_limit, show_char_left_val, wordCountContainer)
{
	if(wordCountContainer == undefined)
		wordCountContainer = 'wordCount';
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if(charCode != 8 && charCode != 46 && charCode != 37 && charCode != 38 && charCode != 39 && charCode != 40){
		if (show_word_count == null) {
			show_word_count = true;
		}
		if (show_char_count == null) {
			show_char_count = false;
		}
		if (show_char_left_val == null) {
			show_char_count = true;
		}
		var char_count = this_field.value.length;
		if(show_char_count)
		$('#'+wordCountContainer).html (char_count>=max_limit?0:Number(max_limit) - Number(char_count));
		if(char_count > max_limit){
			var text = this_field.value.substring(0, Number(max_limit)+1);
			this_field.value = text;
			//adminAlertMsg("You cannot have more than "+max_limit+" characters");
			//alert("You cannot have more than "+max_limit+" characters");
			return false;
		}
		else if(char_count == max_limit)
		{
			// adminAlertMsg("WARNING:\nYou are one character away from your limit.\nIf you continue you could lose any formatting");*/
			//alert('WARNING:\nYou are one character away from your limit.\nIf you continue you could lose any formatting');
			return false;
		}
	}
	// return word_count;
} 

/* Function to set the DHTML div position at the center of the window.*/

function fix_window_position(div, top, position)
{
	var widthPx = $("#"+div).width();
	var heightPx = $("#"+div).height();
	var windowDim = getWindowSize();
	var scroll = getScrollXY();
	if (parseInt(navigator.appVersion)>3) 
	{
		if (navigator.appName.indexOf("Microsoft")!=-1) 
		{
			//winW = document.body.offsetWidth;
		
			//var top1 = (Number(windowDim.Y)/2 - Number(heightPx)/2 +  scroll.Y) - 45;
			var top1 = (Number(windowDim.Y)/2 - Number(heightPx)/2) - 45;
			var left1 = ((Number(windowDim.X) - parseInt(widthPx)) /2 +  Number(scroll.X)) + 285;
			if( getIEVersionNumber() == 8 )
			{
				left1 = ((Number(windowDim.X) - parseInt(widthPx)) /2 +  Number(scroll.X)) + 285;
			}
			else
			{
				left1 = ((Number(windowDim.X) - parseInt(widthPx)) /2 +  Number(scroll.X)) + 285;
			}
		}
		else 
		{
			//var top1 = (Number(windowDim.Y)/2 - Number(heightPx)/2 +  scroll.Y) - 45;
			var top1 = (Number(windowDim.Y)/2 - Number(heightPx)/2) - 45;
			var left1 = ((Number(windowDim.X) - parseInt(widthPx)) /2 +  Number(scroll.X)) + 285;
		}
	}
	// POSITION: absolute; TOP: 100px;
	//$("#"+div).css("position", "absolute");
	if(position!='')
	{
		$("#"+div).css("position", position);
	}

	$("#"+div).css("top",top1); 
	$("#"+div).css("left",left1); 
	
}

function getScrollXY() 
{

		var scrOfX = 0, scrOfY = 0;
		
		if (typeof (window.pageYOffset) == 'number') {
		
		//Netscape compliant
		
		scrOfY = window.pageYOffset;
		
		scrOfX = window.pageXOffset;
		
		} else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
		
		//DOM compliant
		
		scrOfY = document.body.scrollTop;
		
		scrOfX = document.body.scrollLeft;
		
		} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
		
		//IE6 standards compliant mode
		
		scrOfY = document.documentElement.scrollTop;
		
		scrOfX = document.documentElement.scrollLeft;
		
		}
		
		return { X: scrOfX, Y: scrOfY };

}


function getWindowSize()
{
	var myWidth = 0, myHeight = 0;
	if (typeof (window.innerWidth) == 'number') {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
	//IE 4 compatible
	myWidth = document.body.clientWidth;
	myHeight = document.body.clientHeight;
	}
	return { X: myWidth, Y: myHeight }
}
/* Function to set the DHTML div position at the center of the window.*/


/* Function for twitter post*/

function twitterShare(tweetParams)
{
	var tweeturl = 'http://twitter.com/share?url='+encodeURI(tweetParams.url);
	tweeturl += (tweetParams.via != undefined && tweetParams.via != '') ? '&via='+tweetParams.via : '';
	tweeturl += (tweetParams.text != undefined && tweetParams.text != '') ? '&text='+encodeURI(tweetParams.text) : '';
	tweeturl += (tweetParams.related != undefined && tweetParams.related != '') ? '&related='+tweetParams.related : '';
	tweeturl += (tweetParams.count != undefined && tweetParams.count != '') ? '&count='+tweetParams.count : '';
	tweeturl += (tweetParams.lang != undefined && tweetParams.lang != '') ? '&lang='+tweetParams.lang : '';
	tweeturl += (tweetParams.counturl != undefined && tweetParams.counturl != '') ? '&counturl='+tweetParams.counturl : '';
	
	var newWindowParams = (tweetParams.popupWidth != undefined && tweetParams.popupWidth != '') ? 'width='+tweetParams.popupWidth : '';
	newWindowParams += (tweetParams.popupHeight != undefined && tweetParams.popupHeight != '') ? ',height='+tweetParams.popupHeight : '';
	
	window.open(tweeturl, 'Twitter Share', newWindowParams);
}

function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function fieldValueShow(id,value, eventName) {
	if(eventName == 'blur')
	{
		if($('#'+id).val()==''){
			$('#'+id).val(value);
		}
	}
	else
	{
		if($('#'+id).val()==value){
			$('#'+id).val('');
		}
	}
}

function setCookie(c_name,value,exdays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function addHttpBeforeUrl(urlString)
{
	if(!urlString.match(/^(http:\/\/|https:\/\/)/i))
		return 'http://'+urlString;
	else
		return urlString;
}

function noCTRL(e)
{
	var code = (document.all) ? event.keyCode:e.which;
	var msg = "Sorry, this functionality is disabled.";
	if (parseInt(code)==17) //CTRL
	{
		alert(msg);
		window.event.returnValue = false;
	}
}
