function e(elementName) {
	return document.getElementById(elementName)
}

function gopage(n) {
	var f = document.forms['sysrequery'];
	if (f) {
		var p = f.formCurrentPageNumber;
		if (p) {
			p.value = n;
		}
		f.submit();
	}
}

function turnpage(n) {
	var f = document.forms['sysrequery'];
	if (f) {
		var p = f.formCurrentPageNumber;
		if (p) {
			p.value = parseInt(p.value) + parseInt(n);
		}
		f.submit();
	}
}

function sortby(url, sortbyid, obj) {
	if (obj && obj.parentNode) {
		var list = obj.parentNode.getElementsByTagName("LI");
		for (var i=0; i<list.length; i++) {
			
			var o = list[i];
			var cls = o.className;
			if ((cls.indexOf('_hover_') != -1) && (cls.indexOf('sort'+sortbyid) == -1)) {
				//被选中，且当前点击不是自己，则变成未激活classname
				o.className = 'sort' + i;
			}
		}
	}
	
	if (obj.className.indexOf('desc') >= 0) {
		obj.className = 'sort' + sortbyid + '_hover_asc';
		self.location.href = url + '&sortby=' + sortbyid + '&orient=asc';
	}
	else {
		obj.className = 'sort' + sortbyid + '_hover_desc';
		self.location.href = url + '&sortby=' + sortbyid + '&orient=desc';
	}

}



function viewbigpic(pic) {
	window.open('/html/preview.html?pic=' + escape(pic));
}


function getOffsetY(o) 
{ 
  var y = 0; 
  do{ 
	  y += o.offsetTop  || 0; 
	  o  = o.offsetParent;
  }while(o); 
  return y;
}


function JeffImage(ImgD,iwidth,iheight){
	//参数(图片,允许的宽度,允许的高度)
	var image = new Image();
	image.src = ImgD.src;
	
	if(image.width>0 && image.height>0) {
		if(image.width/image.height >= iwidth/iheight) {
			alert(1);
			if(image.width > iwidth) {
				ImgD.width = iwidth;
				ImgD.height = (image.height*iwidth)/image.width;
			}else{
				ImgD.width = image.width;
				ImgD.height = image.height;
			}
		}
		else {
			if(image.height > iheight) {
				ImgD.height = iheight;
				ImgD.width = (image.width*iheight)/image.height;
			}else{
				ImgD.width = image.width;
				ImgD.height = image.height;
			}
		}
	}
}

function viewoption(optname, optvalue) {
	window.open('/template/design/' + optname+ '.html?code=' + optvalue);
}

function viewfabrics(fabricscode) {
	var win = window.open('/fabrics/' + fabricscode + '.html');
	if (win) {
		win.focus();
	}
}
function viewproduct(productcode) {
	var win = window.open('/shirs/' + productcode + '.html');
	if (win) {
		win.focus();
	}
}

function showCurCart()
{
	var productcount= unescape(ReadCookie('cartcount'));
	if (productcount=='')
	{
		productcount='0';
	}
	document.getElementById('cartcount').innerHTML = productcount;

}


function ReadCookie (CookieName) {
  var CookieString = document.cookie;

  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var CookiePieces
  var ReturnValue = "";
  var x = 0; 
  for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++) {

	 CookiePieces = CookieSet[x].split ('=');

	 if (CookiePieces[0].substring (0,1) == ' ') {
		CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);}

	 if (CookiePieces[0] == CookieName) {
		ReturnValue = CookiePieces[1];}

  }
  return ReturnValue;
}

function submitsearch() {
		var frm = e('frmsearchorder');
		var v = frm.ordercode.value;
		if (v != '')
		{
			frm.submit();
		}
		
}


function addfavorite()
{
   if (document.all)
   {
     window.external.addFavorite(document.URL,document.title);
   }
   else if (window.sidebar)
   {
      window.sidebar.addPanel(document.title, document.URL,'');
   }
}

function sendEmail(productcode,type)
{
   window.open('/html/sendEmail.html?inputStr='+productcode+'&submitform='+type+'', 'newwindow', 'height=100, width=450, top=300,left=400, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
}
function Subscribe() {
		var win =window.frames['dingyue'];
		var Email=document.getElementById('Email');
		
	Email=Email.value;
		if (win) {
		
		   
			if (win.Check_Email) {
				
				 win.Check_Email(Email);
				Email=document.getElementById('Email').value='';
			}else{
				
			}
		}
	}


function left(mainStr,lngLen) {
	if (lngLen>0) {return mainStr.substring(0,lngLen)}
	else{return null}
} 

function right(mainStr,lngLen) {
	if (mainStr.length-lngLen>=0 && mainStr.length>=0 && mainStr.length-lngLen<=mainStr.length) {
	return mainStr.substring(mainStr.length-lngLen,mainStr.length)}
	else{return null}
}

function mid(mainStr,starnum,endnum){
	if (mainStr.length>=0){
	return mainStr.substr(starnum,endnum)
	}else{return null}
}

function setwords(obj) {
	var w = document.getElementById('wordspanel');
	if (obj.value == '') {
		w.innerHTML = '&nbsp;';
		return;
	}

	var s = obj.value;
	if (ischinese(s)) {
		alert('请输入英文');
		obj.value = '';
		s = '';
	}
	s = s.substring(0, 7);
	s = s.toUpperCase();
	obj.value = s;

	//w.innerHTML = '';	

	var color = 0;
	var fc = document.getElementById('wordscolorcode');
	if (fc) {
		color = fc.value;
	}

	var ftval = '72C';

	var html = '<table border="0" cellspacing="0" cellpadding="0"><tr>';
	for(var i=0; i<s.length; i++) {
		var fileimg = '';
		if (s.substr(i, 1) != '.') {
			fileimg = color + '/' + ftval + '/' + s.substr(i, 1) + '.gif';
		}else{
			fileimg = color + '/' + color + '.gif'; 
		}
		html = html + '<td><img src="/images/words/' + fileimg + '" width=32 height=32 border=0 align=center onload="javascript:JeffImage(this,32,32);"></td>';
		
	}
	html = html + '</tr></table>';
	
	w.innerHTML = html;
}

function ischinese(s){   
	var ret=true;
	for(var i=0;i<s.length;i++) {
		if (!(((s.charCodeAt(i)>=65) && (s.charCodeAt(i)<=90)) || ((s.charCodeAt(i)>=97) && (s.charCodeAt(i)<=122)))&& s.charCodeAt(i) != 46){
			return true;   
		}
	}
	
}


function opendesigncard(){
	e('designcard_s').style.display='block';
	e('designcard').style.display='block';
}

function hiddesigncard(){
	e('designcard_s').style.display='none';
	e('designcard').style.display='none';	
}

