var popUp; 
var popUp1; 

function OpenCalendar(idname, postBack)
{
	popUp = window.open('../include/Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=295,height=239,left=200,top=250');
}

function OpenColor(idname,formn, postBack)
{
	popUp1 = window.open('../include/colorpickwsdn.aspx?formname=' + formn + 
		'&id=' + idname + '&postBack=' + postBack, 
		'popupcal1', 
		'width=260,height=172,left=200,top=250');
}

function SetDate(formName, id, newDate, postBack)
{
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	if (postBack)
		__doPostBack(id,'');
}		
function SetColor(formName, id, newDate, postBack)
{
	eval('var theform = document.' + formName + ';');
	popUp1.close();
	theform.elements[id].value = newDate;
	if (postBack)
		__doPostBack(id,'');
}		
function doselectdepartment() {
	htmlurl = "../human/Department.aspx?type=sel&name=" + document.Form1.Wsdn_StarCRM_Department.value;
	window.open(htmlurl,"Wsdn_StarCRM_Department","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=550,height=350,left=200,top=250");
}

function selectdeptment(department){
     if (window.opener != null ) {
     	   window.opener.document.Form1.Wsdn_StarCRM_Department.value = department;
           window.close();
     }
}

function doselectproduct1() {
	htmlurl = "../include/selproduct.aspx?type=sel1&name=" + document.Form1.Wsdn_StarCRM_Product.value;
	window.open(htmlurl,"Wsdn_StarCRM_Product","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=550,height=350,left=200,top=250");
}

function doselectproduct2() {
	htmlurl = "../include/selproduct.aspx?type=sel2&name=" + document.Form1.Wsdn_StarCRM_Product.value;
	window.open(htmlurl,"Wsdn_StarCRM_Product","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=550,height=350,left=200,top=250");
}

function doselectproduct3() {
	htmlurl = "../include/selproduct.aspx?type=sel3&name=" + document.Form1.Wsdn_StarCRM_Product.value;
	window.open(htmlurl,"Wsdn_StarCRM_Product","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=550,height=350,left=200,top=250");
}

function doselectproduct4() {
	htmlurl = "../include/selproduct.aspx?type=sel4&name=" + document.Form1.Wsdn_StarCRM_Product.value;
	window.open(htmlurl,"Wsdn_StarCRM_Product","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=550,height=350,left=200,top=250");
}

function selectproduct(product,unit,id,Spec,MarketPrice,AgentPrice){
     if (window.opener != null ) {
           window.close();
     	   window.opener.document.Form1.Wsdn_StarCRM_Product.value = product;
     	   window.opener.document.Form1.Wsdn_StarCRM_Unit.value = unit;
     	   window.opener.document.Form1.Wsdn_StarCRM_Productid.value = id;
     	   window.opener.document.Form1.Wsdn_StarCRM_Spec.value = Spec;
     	   window.opener.document.Form1.Wsdn_StarCRM_MarketPrice.value = MarketPrice;
     	   window.opener.document.Form1.Wsdn_StarCRM_AgentPrice.value = AgentPrice;
     	   window.opener.document.Form1.Wsdn_StarCRM_Price.value = AgentPrice;
     }
}

function doselectStorehouse() {
	htmlurl = "../Storehouse/Storehouse.aspx?type=sel";
	window.open(htmlurl,"Storehouse","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=550,height=350,left=200,top=250");
}


function selectstore(store,id){
     if (window.opener != null ) {
           window.close();
     	   window.opener.document.Form1.Wsdn_StarCRM_Storehouse.value = store;
     	   window.opener.document.Form1.Wsdn_StarCRM_Storehouseid.value = id;
     }
}


function selectproject() {
	htmlurl = "../cl/Project.aspx?type=sel&name=" + document.Form1.Wsdn_StarCRM_Project.value;
	window.open(htmlurl,"client","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=350,left=200,top=250");
}

function ProjectSelect(department){
     if (window.opener != null ) {
     	   window.opener.document.Form1.Wsdn_StarCRM_Project.value = department;
           window.close();
     }
}
function selectemployee() {
	htmlurl = "../human/Emplist.aspx?type=sel&name=" + document.Form1.Wsdn_StarCRM_Employee.value;
	window.open(htmlurl,"client","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=650,height=350,left=200,top=250");
}

function EmployeeSelect(department){
     if (window.opener != null ) {
     	   window.opener.document.Form1.Wsdn_StarCRM_Employee.value = department;
           window.close();
     }
}
function selectlinkman() {
	htmlurl = "../cl/Linkman.aspx?type=sel&name=" + document.Form1.Wsdn_StarCRM_Linkman.value;
	window.open(htmlurl,"client","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=650,height=350,left=200,top=250");
}

function selectProlink() {
	htmlurl = "../cl/Prolink.aspx?type=sel&name=" + document.Form1.Wsdn_StarCRM_Linkman1.value;
	window.open(htmlurl,"client","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=650,height=350,left=200,top=250");
}

function LinkmanSelect(linkman,linkmanid){
     if (window.opener != null ) {
            window.close();
    	   window.opener.document.Form1.Wsdn_StarCRM_Linkman.value = linkman;
     	   window.opener.document.Form1.Wsdn_StarCRM_Linkmanid.value = linkmanid;
     }
}

function ProLinkSelect(linkman,linkmanid){
     if (window.opener != null ) {
            window.close();
    	   window.opener.document.Form1.Wsdn_StarCRM_Linkman1.value = linkman;
     	   window.opener.document.Form1.Wsdn_StarCRM_Linkman1id.value = linkmanid;
     }
}

function selectclient() {
	htmlurl = "../include/selcl.aspx?type=5&name=" + document.Form1.Wsdn_StarCRM_Client.value;
	window.open(htmlurl,"client","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=350,left=200,top=250");
}

function selectProvide() {
	htmlurl = "../cl/Provide.aspx?type=sel&name=" + document.Form1.Wsdn_StarCRM_Client1.value;
	window.open(htmlurl,"client","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=350,left=200,top=250");
}



function selectclienttype(clienttype) {
	htmlurl = "../include/selcl.aspx?type=5&clienttype="+clienttype+"&name=" + document.Form1.Wsdn_StarCRM_Client.value;
	window.open(htmlurl,"client","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=350,left=200,top=250");
}

function selectProvidetype(clienttype) {
	htmlurl = "../cl/Provide.aspx?type=sel&clienttype="+clienttype+"&name=" + document.Form1.Wsdn_StarCRM_Client1.value;
	window.open(htmlurl,"client","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=350,left=200,top=250");
}

function ClientSelect(Client,Clientid){
     if (window.opener != null ) {
             window.close();
    	   window.opener.document.Form1.Wsdn_StarCRM_Client.value = Client;
     	   window.opener.document.Form1.Wsdn_StarCRM_Clientid.value = Clientid;
    }
}

function ProvideSelect(Client,Clientid){
     if (window.opener != null ) {
             window.close();
    	   window.opener.document.Form1.Wsdn_StarCRM_Client1.value = Client;
     	   window.opener.document.Form1.Wsdn_StarCRM_Client1id.value = Clientid;
    }
}

function ClientEmail(Client){
    	   window.document.Form1.TextBox2.value = window.document.Form1.TextBox2.value+Client+' ;';
}


function doselect(selwaht,tran) {
	//htmlurl = "../Include/DoSelect.aspx?name=" + document.Form1.elements[selwaht].value;
	htmlurl = "../Include/DoSelect.aspx?tran="+tran+"&Stringname=" + selwaht;
	window.open(htmlurl,"client","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=400,left=200,top=250");
}

function doselectID(selwaht,tran) {
	//htmlurl = "../Include/DoSelect.aspx?name=" + document.Form1.elements[selwaht].value;
	htmlurl = "../Include/DoSelectID.aspx?tran="+tran+"&Stringname=" + selwaht;
	window.open(htmlurl,"client","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=400,left=200,top=250");
}

function finishselect(tran,selwaht){
     if (window.opener != null ) {
     	   window.opener.document.Form1.elements[tran].value = selwaht;
           window.close();
     }
}

function finishselectID(tran,selwaht,typeinfo){
     if (window.opener != null ) {
     	   window.opener.document.Form1.elements[tran].value = selwaht;
     	   window.opener.document.Form1.TypeName.value = typeinfo;
           window.close();
     }
}



function showWebDialog(url, w, h) {
	if(!validateInteger(w)) w = 503;
	if(!validateInteger(h)) h = 385;
	var dwh = "dialogWidth:" + w + "px; dialogHeight:" + h + "px;";
	return showModalDialog(url, "", "status:no;left:yes;help:no;minimize:no;maximize:yes;border:thin;" + dwh);
}
function validateInteger( strValue ) {
  var objRegExp  = /(^-?\d\d*$)/;

  //check for integer characters
  return objRegExp.test(strValue);
}

function selectcityE(tran) {
	htmlurl = "../Include/Selcity.aspx?tran="+tran+"&prov="+document.Form1.Wsdn_StarCRM_NationPlace.value;
	window.open(htmlurl,"_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=390,left=200,top=250");
}

function selectcityC(tran) {
	htmlurl = "../Include/Selcity.aspx?tran="+tran+"&prov="+document.Form1.Wsdn_StarCRM_Provine.value;
	window.open(htmlurl,"_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=390,left=200,top=250");
}

function selectcity(tran) {
	htmlurl = "../Include/Selcity.aspx?tran="+tran+"&prov=";
	window.open(htmlurl,"_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=390,left=200,top=250");
}

function selectprov(tran) {
	htmlurl = "../Include/Selprov.aspx?tran="+tran;
	window.open(htmlurl,"_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=390,left=200,top=250");
}
