/*navigate to new url*/
function navigateUrl(url)
{
	window.location.href=url;
}
/*opwn window with max window*/
function openSendEmail()
{
	
	var url="view/SendEmail.aspx";
	
	
	window.open(url,"_blank","scrollbars=0,location =0,toolbar=0, titlebar =1,status=0,menubar =0,resizable =0,left=0,top=0,width=600,height=600");

}
function openHelp(url)
{
	return window.showModalDialog(url,"","dialogHeight:600px,dialogWidth:500px");
} 

/*
function checkDateTime(val)
{
	var check=/[0-2]\d[:][0-6]\d/;
	
	if(check.test(val)==true)
	{
		if(val.substr(0,2)<24 && val.substr(3,2)<60)
		{
		    return true;
		}
		else
		{
		    return false;
		}
	}
	else
	{
		return false;
	}
}
*/


function toNextCtl()
{
	if (event.keyCode ==  13)
		event.keyCode = 9;
}
		     
//去左空格; 
function ltrim(s){ 
 return s.replace( /^\s*/, ""); 
} 
//去右空格; 
function rtrim(s){ 
 return s.replace( /\s*$/, ""); 
} 
//去左右空格; 
function trim(s){ 
 return rtrim(ltrim(s)); 
} 
//是否为空值; 
function IsEmpty(_str){ 
 var tmp_str = trim(_str); 
 return tmp_str.length == 0; 
} 
//是否有效的Email; 
function IsMail(_str){ 
 var tmp_str = trim(_str); 
 var pattern = /^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*$/; 
 return pattern.test(tmp_str);   
} 
//是否有效的数字; 
function IsNumber(_str){ 
 var tmp_str = trim(_str);
 if (tmp_str == "") //dwc add
	return true; 
 var pattern = /^[0-9]/; 
 return pattern.test(tmp_str);   
} 
//是否有效的颜色值; 
function IsColor(color){ 
 var temp=color; 
 if (temp=="") return true; 
 if (temp.length!=7) return false; 
 return (temp.search(/\#[a-fA-F0-9]{6}/) != -1); 
} 
//是否有效的链接; 
function IsURL(url){ 
 var sTemp; 
 var b=true; 
 sTemp=url.substring(0,7); 
 sTemp=sTemp.toUpperCase(); 
 if ((sTemp!="HTTP://")||(url.length<10)){ 
  b=false; 
 } 
 return b; 
} 
//是否有效的手机号码; 
function IsMobile(_str){ 
 var tmp_str = trim(_str); 
 var pattern = /13\d{9}/; 
 return pattern.test(tmp_str);   
}

function addFavorite( name)
{
	var href = window.location.href;
	var index = href.indexOf("/",7);
	href = href.substr(0,index+1);
	window.external.AddFavorite(href,name);
}
function setToHomePage(){

    var href = window.location.href;
	var index = href.indexOf("/",7);
	href = href.substr(0,index+1);
	document.all("_setFirstPage").style.behavior='url(#default#homepage)';
	document.all("_setFirstPage").setHomePage(href);
	
}
/*tab function*/
function tabClick(tabId,newIndex,newAllIndex)
{
		
	var tab = document.all(tabId);
	var row = tab.rows[0];
	
	var oldIndex=tab.visibleSelectedIndex;     //*old visible items index
	var items = tab.visibleItemsCount;         //*visible items count
	
	var curIndex;//*cur visible items  index
	var allIndex;//*cur all items index
	if(arguments.length == 1)
	{
		curIndex=event.srcElement.visibleIndex;
		allIndex=event.srcElement.allIndex;//*cur all items index
	}
	else
	{
		curIndex=newIndex;
		allIndex=newAllIndex;
		
	}
	
	document.all("__" + tab.id +"_SelectedIndex").value=allIndex;// modify cur all items index
	tab.visibleSelectedIndex = curIndex;//modify cur visible items index
	
		
	if(oldIndex<0||oldIndex >= items) oldIndex=0;
	if(curIndex<0||curIndex >= items) curIndex=0;
	
	if(oldIndex==curIndex) return;//no changed
	
	var oldtdLeftIndex = oldIndex*2;
	var oldtdIndex = oldIndex*2+1
	var oldtdRightIndex=oldIndex*2+2;
	var curtdLeftIndex = curIndex*2
	var curtdIndex = curIndex*2+1;
	var curtdRightIndex = curIndex*2+2
	
	/******************** show tab content**************************/
	try
	{
		showTab(allIndex,curIndex);
	}
	catch(e)
	{;}
	
	/***************old style changed************************/
	
	//old Left
	if(oldIndex==0)
	{
		
		row.cells[oldtdLeftIndex].all.tags('img')[0].src="/images/tab_left_pic2.jpg";
	}
	else if(oldIndex == curIndex+1)
	{
		row.cells[oldtdLeftIndex].all.tags('img')[0].src="/images/tab_center_pic.jpg";
	}
	else 
	{
		row.cells[oldtdLeftIndex].all.tags('img')[0].src="/images/tab_center_pic3.jpg";
		
	}
	//*old
	row.cells[oldtdIndex].background="/images/tab_right_bg.jpg";
	row.cells[oldtdIndex].className="font_black";
	
	//*old right
	if(oldIndex==items-1)
	{
		
		row.cells[oldtdRightIndex].all.tags('img')[0].src="/images/tab_right_pic.jpg";
	}
	else if(oldIndex == curIndex-1)
	{
		row.cells[oldtdRightIndex].all.tags('img')[0].src="/images/tab_center_pic2.jpg";
	}
	else 
	{
		row.cells[oldtdRightIndex].all.tags('img')[0].src="/images/tab_center_pic3.jpg";
		
	}
	
	/***************cur style changed************************/
	
	//cur Left
	if(curIndex==0)
	{
		
		row.cells[curtdLeftIndex].all.tags('img')[0].src="/images/tab_left_pic.jpg";
	}
	else 
	{
		row.cells[curtdLeftIndex].all.tags('img')[0].src="/images/tab_center_pic2.jpg";
	}
	
	//*cur
	row.cells[curtdIndex].background="/images/tab_left_bg.jpg";
	row.cells[curtdIndex].className="font_blackB";
	
	//*cur right
	if(curIndex==items-1)
	{
		
		row.cells[curtdRightIndex].all.tags('img')[0].src="/images/tab_right_pic2.jpg";
	}
	else 
	{
		row.cells[curtdRightIndex].all.tags('img')[0].src="/images/tab_center_pic.jpg";
	}
	

}
function tab2Click(tabId,newIndex,newAllIndex)
{
		
	var tab = document.all(tabId);
	var row = tab.rows[0];
	
	var oldIndex=tab.visibleSelectedIndex;     //*old visible items index
	var items = tab.visibleItemsCount;         //*visible items count
	
	var curIndex;//*cur visible items  index
	var allIndex;//*cur all items index
	if(arguments.length == 1)
	{
		curIndex=event.srcElement.visibleIndex;
		allIndex=event.srcElement.allIndex;//*cur all items index
	}
	else
	{
		curIndex=newIndex;
		allIndex=newAllIndex;
		
	}
	
	document.all("__" + tab.id +"_SelectedIndex").value=allIndex;// modify cur all items index
	tab.visibleSelectedIndex = curIndex;//modify cur visible items index
	
		
	if(oldIndex<0||oldIndex >= items) oldIndex=0;
	if(curIndex<0||curIndex >= items) curIndex=0;
	
	if(oldIndex==curIndex) return;//no changed
	
	var oldtdLeftIndex = oldIndex*2;
	var oldtdIndex = oldIndex*2+1
	var oldtdRightIndex=oldIndex*2+2;
	var curtdLeftIndex = curIndex*2
	var curtdIndex = curIndex*2+1;
	var curtdRightIndex = curIndex*2+2
	
	/******************** show tab content**************************/
	try
	{
		showTab(allIndex,curIndex);
	}
	catch(e)
	{;}
	
	/***************old style changed************************/
	
	//old Left
	if(oldIndex==0)
	{
		
		row.cells[oldtdLeftIndex].all.tags('img')[0].src="/images/2tab_left_pic2.gif";
	}
	else if(oldIndex == curIndex+1)
	{
		row.cells[oldtdLeftIndex].all.tags('img')[0].src="/images/2tab_center_pic.gif";
	}
	else 
	{
		row.cells[oldtdLeftIndex].all.tags('img')[0].src="/images/2tab_center_pic3.gif";
		
	}
	//*old
	row.cells[oldtdIndex].background="/images/2tab_right_bg.gif";
	row.cells[oldtdIndex].className="2font_black";
	
	//*old right
	if(oldIndex==items-1)
	{
		
		row.cells[oldtdRightIndex].all.tags('img')[0].src="/images/2tab_right_pic.gif";
	}
	else if(oldIndex == curIndex-1)
	{
		row.cells[oldtdRightIndex].all.tags('img')[0].src="/images/2tab_center_pic2.gif";
	}
	else 
	{
		row.cells[oldtdRightIndex].all.tags('img')[0].src="/images/2tab_center_pic3.gif";
		
	}
	
	/***************cur style changed************************/
	
	//cur Left
	if(curIndex==0)
	{
		
		row.cells[curtdLeftIndex].all.tags('img')[0].src="/images/2tab_left_pic.gif";
	}
	else 
	{
		row.cells[curtdLeftIndex].all.tags('img')[0].src="/images/2tab_center_pic2.gif";
	}
	
	//*cur
	row.cells[curtdIndex].background="/images/2tab_left_bg.gif";
	row.cells[curtdIndex].className="2font_blackB";
	
	//*cur right
	if(curIndex==items-1)
	{
		
		row.cells[curtdRightIndex].all.tags('img')[0].src="/images/2tab_right_pic2.gif";
	}
	else 
	{
		row.cells[curtdRightIndex].all.tags('img')[0].src="/images/2tab_center_pic.gif";
	}
	

}
function changeFrameSetPage(newFrameSetPage,defaultMeuPage)
{
	if(arguments.length == 2)
	{
		newFrameSetPage += "?url=" + defaultMeuPage;
	}
	parent.location.href=newFrameSetPage;
	
}
