﻿	jQuery.fn.extend({
		doFocusInput:function(settings){
			return this.each(function() {
				var options = jQuery.extend({
				defaultWord:this.defaultValue ,
				focus:{
					border:"0",
					color:"#242424"
				},
				blur:{
					border:"0",
					color:"#B0B0B0"
				}}, settings);
				
				$(this).css(options.blur)
				.bind("focus",function(){
					$(this).css(options.focus);
					
					if($.trim(this.value) == $.trim(options.defaultWord) ){
						this.value = "";
					}else {this.select();}
				})
				.bind("blur",function(){
					$(this).css(options.blur);
					if($.trim(this.value) == "" || $.trim(this.value) == options.defaultWord ){
						this.value = $.trim(options.defaultWord);
						$(this).css(options.blur);
					}else{
						this.style.color = options.focus.color;
					}
				});
			});
		}
		,embedFlash:function(settings , pluginOptions ){
		
				var options = jQuery.extend({ expressInstall: false ,update: false ,version:'8.0.0'}, pluginOptions);
				var settings = jQuery.extend({ id:this.id}, settings);
				$(this).flash(settings, options , 
						function(htmlOptions) {
							$this = $(this);
							//htmlOptions.flashvars.file = $this.attr('href');
							$this.replaceWith($.fn.flash.transform(htmlOptions));						
						}
				);
		}
		,embedSWF:function(settings , pluginOptions ){
			var o = jQuery.extend({ expressInstall:"js/swfobject/expressInstall.swf",version:'8.0.0'}, settings);
			if(swfobject.flagSwitchOff){
				swfobject.switchOffAutoHideShow();
				swfobject.flagSwitchOff = false;
			}
			for(var key in o.flashvars) o.flashvars[key] = encodeURIComponent(o.flashvars[key]);
			
			return this.each(function() {
				
				var swfId = this.id||("swfobject_"+Math.round(Math.random()* 1000));
				var swfName = this.name||swfId;
				var swfWidth = o.width||$(this).width();
				var swfHeight = o.height||$(this).height();
				swfobject.embedSWF(o.src, swfId, swfWidth, swfHeight, o.version,o.expressInstall ,o.flashvars,$.extend({wmode:o.wmode||"opaque"},o.params));
			});
		}
	});

function openPopup(popup_width,popup_height,popup_url,var_name){
	var windowHeight = popup_height;
	var windowWidth = popup_width;
	var windowName = var_name;
	var windowUri = popup_url;
	var newwindow;

	var centerWidth = (window.screen.width - windowWidth) / 2;
	var centerHeight = (window.screen.height - windowHeight) / 2;

	if ( !newwindow || newwindow.closed ){
		newwindow = window.open(windowUri, windowName,'addressbar=0,menubar=0,location=0,status=0,scrollbars=yes,resizable=0,width=' + windowWidth + ',height=' + windowHeight +',left=' + centerWidth + ',top=' + centerHeight);
	}
	else  if ( newwindow && ! newwindow.closed ){
		newwindow.location = windowUri;
		// newwindow.focus();
	}
}
	//===========================================
	function pushDataToFlash(flashName,data){
		var flashMovie=getFlashMovieObject(flashName);
			flashMovie.SetVariable("/:status", data);
	};
	//===========================================
	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 isEmailPattern(email_content){
		  var pattern=/^[a-z0-9][a-z0-9\_\-.]*@[a-z][a-z0-9\_\-]*(\.[a-z][a-z0-9\_\-]*)|(\s,\s)+$/i;
		 return pattern.test(email_content);
	};
	//====================
	function isUserPattern(user_content){
		  var pattern=/^([a-z0-9][0-9\-\.@\_]*)+$/i;
		 return (user_content.length >=4)?pattern.test(user_content):false;
	};
	//====================
	function isPicPattern(pic_content){
		 var pattern=/[^.]+[.](jpg|jpeg)$/i; 
		return pattern.test(pic_content);
	};
	//====================
	function reloadImg(elm){
		 mydate = new Date();
		 url_img=elm.src.split("?")[0];
		 elm.src=url_img+"?"+mydate.getTime();
	};
	//====================

	
	
