function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure ){
  var cookie_string = name + "=" + escape ( value );

  if (exp_y){
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if (path){
      cookie_string += "; path=" + escape ( path );
  }
  if (domain){
      cookie_string += "; domain=" + escape ( domain );
  }
  if (secure){
      cookie_string += "; secure";
  }

  document.cookie = cookie_string;
}

function get_cookie(cookie_name){
  var results = document.cookie.match(cookie_name + '=(.*?)(;|$)');
  if(results){
      return (unescape(results[1]));
  }else{
      return null;
  }
}

function delete_cookie( cookie_name ){
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

//获取所有name[]的数目
function getRadioValue(sName){
	var radio=document.getElementsByName(sName);
	for(i=0;i<radio.length;i++){
		if(radio[i].checked){
			return radio[i].value ;
		}

	}

	return 0 ;
}
//选中所有name[]的checkbox
function selectAllBox(sName){
	var i=0;
	var checkBox=document.getElementsByName(sName);
	for(i=0;i<checkBox.length;i++){
		checkBox[i].checked = true;
	}
}

//清空所有name[]的checkbox
function clearAllBox(sName){
	var i=0;
	var checkBox=document.getElementsByName(sName);
	for(i=0;i<checkBox.length;i++){
		checkBox[i].checked = false;
	}
}

//获取所有name[]的数目
function getCheckedBoxNumber(sName){
	var n=0;
	var checkBox=document.getElementsByName(sName);
	for(i=0;i<checkBox.length;i++){
		checkBox[i].checked?(n++):n;
	}
	return n;
}
//根据当前checkbox选择，选择所有的复选框
function checkAllBox(obj, sName){
	if( !obj.checked ){
		clearAllBox(sName) ;
	}else{
		selectAllBox(sName) ;
	}
}

//
function is_empty(value){
	if( value == '' || value == null || value == 0 || value == false){
		return true ;
	}

	return false ;
}

//数字和字母
function is_alphalet(value){
	if( !value.match( /^[A-Za-z0-9_]{1,20}$/i ) ){
        return false ;
    }

	return true ;
}

//小数
function is_decimal(value){
	if( !value.match( /^[0-9]+(\.?[0-9]+)?$/i ) ){
        return false ;
    }

	return true ;
}

//整数
function is_integer(value){
	if( !value.match( /^[0-9_]{1,20}$/i ) ){
        return false ;
    }

	return true ;
}

//Validate username
function is_username(value){
	if( !value.match( /^[A-z0-9]+$/i ) ){
        return false ;
    }

	return true ;
}
//Email格式
function is_email(value){
	if( !value.match( /^[A-z0-9-_\.]+@[A-z0-9-_\.]+\.+[A-z]+$/i ) ){
        return false ;
    }

	return true ;
}

//网址
function is_url(value){
	if( !value.match( /^http:\/\/.*/i) ){
        return false ;
    }

	return true ;
}

//图片格式
function is_image(value){
	if( !value.match( /^[^\.]+\.+(jpg|jpeg|gif|bmp|png)+$/i ) ){
        return false ;
    }
    
	return true ;
}
function popup_window(url, width, height){
	var iTop  = (window.screen.height - height) / 2; 
	var iLeft = (window.screen.width - width) / 2;
	window.open(url,"Popup","scrollbars=yes,alwaysRaised=yes,toolbar=no,location=0,status=0,direction=no,resizable=0 nor resizable=false,Width="+width+",Height="+height+",top="+iTop+",left="+iLeft) ;
}
//Available to resize the window
function popup_window2(url, width, height){
	var iTop  = (window.screen.height - height) / 2; 
	var iLeft = (window.screen.width - width) / 2;
	window.open(url,"Popup","scrollbars=yes,alwaysRaised=yes,toolbar=no,location=0,status=0,direction=no,resizable=yes,Width="+width+",Height="+height+",top="+iTop+",left="+iLeft) ;
}
function load_flash_flv(path,focus_width,focus_height,file_list){

	var write = '<object type="application/x-shockwave-flash" data="include/js/flash/vcastr3.swf" width="'+focus_width+'" height="'+focus_height+'" id="vcastr3">' ;
	write +=    '	<param name="movie" value="include/js/flash/vcastr3.swf"/> ' ;
	write +=    '	<param name="allowFullScreen" value="true" />' ;
	write +=    '	<param name="wmode" value="transparent" />' ;
	write +=    '	<param name="FlashVars" value="xml=' ;
	write +=    '		<vcastr>' ;
	write +=    '			<channel>' ;
	write +=    '				<item>' ;
	write +=    '					<source>'+file_list+'</source>' ;
	write +=    '					<duration></duration>' ;
	write +=    '					<title></title>' ;
	write +=    '				</item>' ;
	write +=    '			</channel>' ;
	write +=    '			<config>' ;
	write +=    '			<isLoadBegin>true</isLoadBegin>' ;
	write +=    '			<buffertime>0</buffertime>' ;
	write +=    '			<isAutoPlay>false</isAutoPlay>' ;
	write +=    '			<isRepeat>false</isRepeat>' ;
	write +=    '			</config> ' ;
	write +=    '			<plugIns>' ;
	write +=    '				<logoPlugIn>' ;
	write +=    '					<url>include/js/flash/logoPlugIn.swf</url>' ;
	write +=    '					<logoText>www.myshoptown.eu</logoText>' ;
	write +=    '					<logoTextAlpha>0.5</logoTextAlpha>' ;
	write +=    '					<logoTextFontSize>14</logoTextFontSize>' ;
	write +=    '					<logoTextLink>http://www.myshoptown.eu</logoTextLink>' ;
	write +=    '					<logoTextColor>0x000000</logoTextColor>' ;
	write +=    '					<textMargin>0 40 auto auto</textMargin>' ;
	write +=    '				</logoPlugIn>' ;
	write +=    '				<javaScriptPlugIn>' ;
	write +=    '					<url>include/js/flash/javaScriptPlugIn.swf</url>' ;
	write +=    '				</javaScriptPlugIn> ' ;
	write +=    '			</plugIns>' ;
	write +=    '		</vcastr>"/>' ;
	write +=    '	</object>' ;
	document.write(write) ;
}

function getDocumentHeight(){
    if(jQuery.browser.msie){
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight;
    }else{
        return self.innerHeight;
    }
}

function getDocumentWidth (){
    if(jQuery.browser.msie){
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth : document.body.clientWidth;
    }else{
        return self.innerWidth;
    }
}

function isIE(){
	var isIE = (document.all && window.ActiveXObject && !window.opera) ? true : false;
	
	return isIE ;
}

function getScrollHeight(){
	return document.documentElement.scrollTop + document.body.scrollTop ;
}

function getScrollWidth(){
	return document.documentElement.scrollLeft + document.body.scrollLeft ;
}