
function showinnerWidget(id,action) {
	

	
	dijit.byId(id).attr("href",action);
}


function transaction(form,action) {
	submitFormforTransaction(form, action, '');
}
function submitFormforTransaction(form, action, callback) {
	// submit the form in the background   

	dojo.xhrPost( {
		url :action,
		form :form,
		handleAs :"text",
		load : function(data) {
		//showMessage(data, "ok");
		dijit.byId('loadingDialog').hide();
        dijit.byId('transactionInfo').attr('content',data);

	},
	error : function(error) {
		showMessage(data, "error");
		dijit.byId('loadingDialog').hide();

	}

	});
}
function searchuser(phonenumber) {

	dijit.byId('userInfo').attr("href","usersearch.do?service_phonenumber="+phonenumber);
}
function resellerbuy(action) {	
	resellermainpage.attr('href',action);
}


function loadAdvertisement(id) {
	dijit.byId('mainTab').attr("href", 'selectadvertisement.do?id='+id);
}

function loadPage(value) {	
	if (value=='images/banner1.png' || value=='http://www.shabakieh.com/images/banner1.png' ) {
		document.getElementById('maincontentpane').style.background='#636363';
		dijit.byId('mainpage').attr("href", 'service.jsp');
	}else if (value=='images/banner2.png' || value=='http://www.shabakieh.com/images/banner2.png') {
		document.getElementById('maincontentpane').style.background='#636363';
		dijit.byId('mainpage').attr("href", 'internetcard.jsp');
	}else if (value=='images/banner3.png' || value=='http://www.shabakieh.com/images/banner3.png') {
		document.getElementById('maincontentpane').style.background='#636363';
		dijit.byId('mainpage').attr("href", 'intelligent.jsp');
	}
}

function editproduct(name,value) {
	if (value=='1') {
		dijit.byId('category_edit').attr("href", 'editcategory.do?categoryId='+name);
	}else if (value=='2') {
		dijit.byId('subcategory_edit').attr("href", 'editcategory.do?subcategoryId='+name);
	}else if (value=='3') {
		dijit.byId('product_edit').attr("href", 'editcategory.do?productId='+name);
	}

}
function editcategorycompelete(form,action) {
	submitFormByRefresh(form,action,'');
}


function deleteservice2(form,action) {
	submitFormDeletefactor(form,action,'');
	resellermainpage.attr("href", 'checkoutreseller.do');
}
function deleteservice(form,action) {	
	submitFormDeletefactor(form,action,'');
	dijit.byId('mainpage').attr("href", 'checkout.jsp');
}
function submitFormDeletefactor(form, action, callback) {
	// submit the form in the background   

	dojo.xhrPost( {
		url :action,
		form :form,
		handleAs :"text",
		load : function(data) {
		showMessage(data, "ok");
		dijit.byId('loadingDialog').hide();
		dijit.byId('mainTab').refresh();


	},
	error : function(error) {
		showMessage(data, "error");
		dijit.byId('loadingDialog').hide();
		dijit.byId('mainTab').refresh();
	}

	});
}



function uploadcomplete(value) {
	alert(value);
}

function showmassage(value) {
	alert("ok");
	advertisementDialog.show();
	advertisementDialog.attr('href',value);
}

function submitPurchase(form,action) {
	// submit the form in the background   

	if(dijit.byId(form).validate()){
		dijit.byId(form).submit();

	}
}
function submitPurchaseMellat(refId) {
	// submit the form in the background   
	loadNewPageIndex("payment.do?refId="+refId,"adsl.jsp");
	
}
/*function loadSell(product){


	dijit.byId("mainTab").attr("href","buy.do?serviceId="+product);
	document.getElementById('courseDialog').style.background="#57B6E6";
	dijit.byId('courseDialog').show();

}
 */
function adminserviceview(value) {
	dijit.byId('adminservice').attr('href','service.do?isAdmin='+true+'&service='+value);
}

function resetPassword(){	 
	if(dijit.byId('forgotPassword').validate()){
		dijit.byId('loadingDialog').show();
		submitForm('forgotPassword', 'forgotPassword.do', 'index.jsp');
	}

}

function refresh(object){
	object.refresh()
}

function showMessage(mmessage, mtype) {
	dojo.publish("messageToaster", [ {
		message :mmessage,
		type :mtype,
		duration :10000
	} ]

	);
}

function loadNewPage(url){
	var tabs = dijit.byId("centertab");
	tabs.selectChild(dijit.byId("mainTab"));
	dijit.byId('mainTab').attr("href", url);
}

function loadNewPageIndex(url1,url2) {
	document.getElementById('maincontentpane').style.background='#636363';
	dijit.byId('mainpage').attr("href", url1);
	dijit.byId('imagemenu').attr("href", url2);
}

function loadNewPageIndex2(url) {
	dijit.byId('imagemenu').attr("href", url);
}


function loadNewPageIndex3(form,action,action2) {
	if (dijit.byId(form).validate()) {
		dijit.byId('loadingDialog').show();
		submitFormCheckout(form,action,action2,'');


	}	
}
function loadNewPageIndex4(url) {
	dijit.byId('mainpage').attr("href", url);
}
function registerbuy(form) {	
	basketDialog.hide();
	dijit.byId('mainpage').attr("href", 'checkout.do');	
}

function linkSubmit3(form, action,action2) {
	if (dijit.byId(form).validate()) {
		submitFormCheckout(form,action,action2,'');
		
	}
}
function linkSubmitReseller3(form, action,action2) {
	if (dijit.byId(form).validate()) {
		submitFormCheckoutReseller(form,action,action2,'');
		
	}
}
function submitFormCheckout(form, action,action2, callback) {
	// submit the form in the background   

	dojo.xhrPost( {
		url :action,
		form :form,
		handleAs :"text",
		load : function(data) {
		//showMessage(data, "ok");
		dijit.byId('loadingDialog').hide();	
		
		if (data=="1") {
			showMessage("<font color=white size=2px>&#1583;&#1585;&#1582;&#1608;&#1575;&#1587;&#1578; &#1588;&#1605;&#1575; &#1579;&#1576;&#1578; &#1711;&#1585;&#1583;&#1740;&#1583;</font>", "ok");
			dijit.byId('mainpage').attr("href", action2);
		}else{
			showMessage(data, "ok");
		}

	},
	error : function(error) {
		//showMessage(data, "error");
		dijit.byId('loadingDialog').hide();
		
	}

	});
}
function submitFormCheckoutReseller(form, action,action2, callback) {
	// submit the form in the background   
	
	dojo.xhrPost( {
		url :action,
		form :form,
		handleAs :"text",
		load : function(data) {
		//showMessage(data, "ok");
		dijit.byId('loadingDialog').hide();	
		
		if (data=="1") {
			showMessage("<font color=white size=2px>&#1583;&#1585;&#1582;&#1608;&#1575;&#1587;&#1578; &#1588;&#1605;&#1575; &#1579;&#1576;&#1578; &#1711;&#1585;&#1583;&#1740;&#1583;</font>", "ok");
			resellermainpage.attr("href", action2);
		}
		
	},
	error : function(error) {
		//showMessage(data, "error");
		dijit.byId('loadingDialog').hide();
		
	}
	
	});
}
function confirmDialogForPurchase(id,title, question, form, action, e) {
	var errorDialog = new dijit.Dialog({ id: 'queryDialog', title: title });
	var callback = function(mouseEvent) {		
		errorDialog.hide();
		errorDialog.destroyRecursive();	
		if (window.event) e = window.event;
		var srcEl = mouseEvent.srcElement? mouseEvent.srcElement : mouseEvent.target; //IE or Firefox		
		if (srcEl.id == 'yes_label') {
			submitForm(form, action, '');
			document.getElementById(id).style.visibility="hidden";
		} else {
			errorDialog.hide();
		}
	};
	var questionDiv = dojo.create('div', { innerHTML: question });
	var yesButton = new dijit.form.Button(
			{ label: '&#1576;&#1604;&#1740;', id: 'yes', onClick: callback });
	var noButton = new dijit.form.Button(
			{ label: '&#1582;&#1740;&#1585;', id: 'no', onClick: callback });
	errorDialog.containerNode.appendChild(questionDiv);
	errorDialog.containerNode.appendChild(yesButton.domNode);
	errorDialog.containerNode.appendChild(noButton.domNode);
	errorDialog.show();
}
function confirmDialog(title, question, form, action, e) {
	var errorDialog = new dijit.Dialog({ id: 'queryDialog', title: title });
	var callback = function(mouseEvent) {		
		errorDialog.hide();
		errorDialog.destroyRecursive();	
		if (window.event) e = window.event;
		var srcEl = mouseEvent.srcElement? mouseEvent.srcElement : mouseEvent.target; //IE or Firefox		
		if (srcEl.id == 'yes_label') {
			submitFormByRefresh(form, action, '');
		} else {
			errorDialog.hide();
		}
	};
	var questionDiv = dojo.create('div', { innerHTML: question });
	var yesButton = new dijit.form.Button(
			{ label: '&#1576;&#1604;&#1740;', id: 'yes', onClick: callback });
	var noButton = new dijit.form.Button(
			{ label: '&#1582;&#1740;&#1585;', id: 'no', onClick: callback });
	errorDialog.containerNode.appendChild(questionDiv);
	errorDialog.containerNode.appendChild(yesButton.domNode);
	errorDialog.containerNode.appendChild(noButton.domNode);
	errorDialog.show();
}

function confirmDialogForm(title, question, form, action, e) {
	var errorDialog = new dijit.Dialog({ id: 'queryDialog', title: title });
	var callback = function(mouseEvent) {	 
		errorDialog.hide();
		errorDialog.destroyRecursive();	 
		if (window.event) e = window.event;
		var srcEl = mouseEvent.srcElement? mouseEvent.srcElement : mouseEvent.target; //IE or Firefox
		if (srcEl.id == 'yes_label1_label') {
			linkSubmit(form,action);		
		} else {	
			errorDialog.hide();
		}
	};
	var questionDiv = dojo.create('div', { innerHTML: question });
	var yesButton = new dijit.form.Button(
			{ label: '&#1576;&#1604;&#1740;', id: 'yes_label1', onClick: callback });
	var noButton = new dijit.form.Button(
			{ label: '&#1582;&#1740;&#1585;', id: 'no', onClick: callback });
	errorDialog.containerNode.appendChild(questionDiv);
	errorDialog.containerNode.appendChild(yesButton.domNode);
	errorDialog.containerNode.appendChild(noButton.domNode);
	errorDialog.show();
}


function linkSubmit(form, action) {
	if (dijit.byId(form).validate()) {
		dijit.byId('loadingDialog').show();
		submitFormByRefresh(form, action, '');
	}
}
function linkSubmit2(form, action) {
	if (dijit.byId(form).validate()) {
		dijit.byId('loadingDialog').show();
		submitFormByRefresh2(form, action, '');
	}
}
function linkSubmit4(form, action) {
	if (dijit.byId(form).validate()) {
		dijit.byId('loadingDialog').show();
		submitForm(form, action, '');
		dijit.byId('mainpage').attr('href','service.jsp');
	}
}
function linkSubmitReseller(form, action) {
	if (dijit.byId(form).validate()) {
		dijit.byId('loadingDialog').show();
		submitForm(form, action, '');
		resellermainpage.attr('href','service.do?id=-2');
	}
}
function submit(form, action, callback) {
	// submit the form in the background   

	dojo.xhrPost( {
		url :action,
		form :form,
		handleAs :"text",
		load : function(data) {
		showMessage(data, "ok");

		dijit.byId('loadingDialog').hide();

	},
	error : function(error) {
		showMessage(data, "error");
		dijit.byId('loadingDialog').hide();
	}

	});
};
function submitFormDialog(form, action, callback) {
	// submit the form in the background   

	dojo.xhrPost( {
		url :action,
		form :form,
		handleAs :"text",
		load : function(data) {
		showMessage(data, "ok");
		dijit.byId('loadingDialog').hide();
		productDialog.hide();
		basketDialog.show();
		dijit.byId('mainTab').refresh();
		dijit.byId('productTab').attr('href','categorylist.do?id=1');


	},
	error : function(error) {
		showMessage(data, "error");
		dijit.byId('loadingDialog').hide();
		dijit.byId('productTab').attr('href','categorylist.do?id=1');
		productDialog.hide();
		basketDialog.show();
		dijit.byId('mainTab').refresh();
	}

	});
}
function submitForm(form, action, callback) {
	// submit the form in the background   

	dojo.xhrPost( {
		url :action,
		form :form,
		handleAs :"text",
		load : function(data) {
		showMessage(data, "ok");
		dijit.byId('loadingDialog').hide();


	},
	error : function(error) {
		showMessage(data, "error");
		dijit.byId('loadingDialog').hide();

	}

	});
}
function submitFormservice(form, action, callback) {
	// submit the form in the background   

	dojo.xhrPost( {
		url :action,
		form :form,
		handleAs :"text",
		load : function(data) {
		showMessage(data, "ok");
		dijit.byId('loadingDialog').hide();
		dijit.byId('mainpage').attr('href',action);		

	},
	error : function(error) {
		showMessage(data, "error");
		dijit.byId('loadingDialog').hide();
		dijit.byId('mainpage').attr('href',action);
	}

	});
}
function submitFormSetContentPane(form, action, callback) {
	// submit the form in the background   

	dojo.xhrPost( {
		url :action,
		form :form,
		handleAs :"text",
		load : function(data) {
		dijit.byId('mainpage').attr('content',data);		
	},
	error : function(error) {
		dijit.byId('mainpage').attr('content',data);
	}

	});
};
function submitFormByRefresh2(form, action, callback) {
	// submit the form in the background   

	dojo.xhrPost( {
		url :action,
		form :form,
		handleAs :"text",
		load : function(data) {
		showMessage(data, "ok");
		dijit.byId('loadingDialog').hide();



	},
	error : function(error) {
		showMessage(data, "error");
		dijit.byId('loadingDialog').hide();

	}

	});
};
function submitFormByRefresh(form, action, callback) {
	// submit the form in the background   

	dojo.xhrPost( {
		url :action,
		form :form,
		handleAs :"text",
		load : function(data) {
		showMessage(data, "ok");
		dijit.byId('loadingDialog').hide();
		dijit.byId('mainTab').refresh();


	},
	error : function(error) {
		showMessage(data, "error");
		dijit.byId('loadingDialog').hide();
		dijit.byId('mainTab').refresh();
	}

	});
};


/*function refreshpage(url){

	dijit.byId('mainTab').refresh();
	//dijit.byId('mainTab').attr("href",url );
}*/

function citychange(filteringselect) {
    filteringselect.reset();
	var provinceId = dijit.byId('province').getValue(false);
	var citystore = new dojo.data.ItemFileReadStore({url:'city.do?provinceId='+provinceId});
	filteringselect.store=citystore;
}
function centerchange(filteringselect) {
	filteringselect.reset();
	var centerId = dijit.byId('center_name').getValue(false);
	var centerstore = new dojo.data.ItemFileReadStore({url:'centernumber.do?centerId='+centerId});
	filteringselect.store=centerstore;

}
function editcenter(form,number){
	submitForm(form,'deletecenter.do?number='+number,'');
	dijit.byId('mainTab').refresh(); 
	//dijit.byId('center_edit').refresh();

}
function reseller(){
	//dijit.byId('resellerContentPane').attr("href", "reseller.jsp");
}

function display(value){
	dijit.byId('display').attr("href", "searchcenterdata.do?number="+value);
}
function searchcenter(form,value){
	submitForm(form,"searchcenterdata.do?number="+value,'');
	//dijit.byId('display').attr("href", "searchcenter.do?number="+value);

}
/*function loadProduct(form,id){
	var tabs = dijit.byId("centertab");
	tabs.selectChild(dijit.byId("mainTab"));
	dijit.byId('mainTab').attr("href", 'productlist.do?id='+id);

}*/
function loadModemProduct(href) {	
	dijit.byId('productTab').attr("href", href);
	productDialog.show();
}
function loadsubcategory(form,id){
	dijit.byId('productTab').attr("href", 'categorylist.do?id='+id);

}
function order(form,id){
	dijit.byId('productTab').attr("href", 'order.do?productId='+id);	

}
function productrefresh() {
	dijit.byId('productTab').attr('href','categorylist.do');
}
function calculateTotalPrice(price) {
	var quantity = dijit.byId('quantity').getValue(false);
	if(quantity == '' || price=='')
		return;
	dijit.byId('totalPrice').setValue(quantity * price);

}
/*function refreshproduct() {
	var tabs = dijit.byId("centertab");
	tabs.selectChild(dijit.byId("mainTab"));
	dijit.byId('mainTab').attr("href",'categorylist.do' );
}*/


function buyReportSubmit(form,id){
	dijit.byId('loadingDialog').show();
	var quantity = dijit.byId('quantity').getValue(false);
	submitFormDialog(form, 'orderreport.do?productId='+id+'&quantity='+quantity, '');

}

function buy(form,id){	
	//submitFormforservice(form,"setsession.do?serviceId="+id,'');
	dijit.byId('mainpage').attr('href','buy.do?serviceId='+id);

}
function submitFormforservice(form, action, callback) {
	// submit the form in the background   

	dojo.xhrPost( {
		url :action,
		form :form,
		handleAs :"text",
		load : function(data) {
		//showMessage(data, "ok");
		dijit.byId('loadingDialog').hide();


	},
	error : function(error) {
		//showMessage(data, "error");
		dijit.byId('loadingDialog').hide();

	}

	});
}

function purchase(value){
	dijit.byId('purchase_service').attr("href", "purchase.do?isverify="+value);
}

function reseller(value) {
	dijit.byId('display_reseller').attr("href", "newreseller.do?displayreseller="+value);
}

/*function serviceactive(form,userId){
	submitForm(form, 'serviceactive.do?&userId='+userId, '');
	dijit.byId('purchase_service').refresh();
}*/

function getbusinesspartner(){	
	var person=dijit.byId('personRadio').attr('checked');
	var company=dijit.byId('companyRadio').attr('checked');
	if(person==true){		
		businesspartnerContentPane.setAttribute('href','personprofile.jsp');
	}
	if (company==true){
		businesspartnerContentPane.setAttribute('href','companyprofile.jsp');
	} 
}

function getbusinesspartner2(){	

	if(document.getElementById('personRadio').checked){

		document.getElementById('personContentPane').style.visibility='visible';
		document.getElementById('companyContentPane').style.visibility='hidden';
	}
	if(document.getElementById('companyRadio').checked){	

		document.getElementById('companyContentPane').style.visibility='visible';
		document.getElementById('personContentPane').style.visibility='hidden';
	}
}
function loaduseraccount(){	

	document.getElementById('useraccountpanel').style.visibility='visible';


}

function loadCallRequest(){
	dijit.byId('callrequestDialog').attr('href', "callrequest.jsp");
	document.getElementById('callrequestDialog').background="#FFF200";
	dijit.byId('callrequestDialog').show();
}

function searchcenter(){
	var number = dijit.byId('search_number').getValue(false);
	dijit.byId('mainpage').attr('href','searchcenterdata.do?number='+number);

}
/*function loadmodemDialog() {
	if(dijit.byId('modemcheck').checked){
		modemDialog.show();

	}else{

		modemDialog.hide();
	}

}*/

