SRESelectedPage = "index";
sr_mode='AUTH';
SREUsertype ='INDV';
var DynDetail =  new Array();
utype='N';
var primemail='';
var bizalias='';
accountType='0';
var SREHostPath='';
var usercountry='';
usercountrydesc='';
var password='';
//keepsignin='N';
srepath='';
sre_cgivar='';
sre_ipvar='';
sre_sessvar='';
sre_extramsg='';
thirdparty='';
language='';
country='';

fullname='';
lastname='';
firstname='';
gender='';
dateofbirth='';
refemail='';
brandtype='';
acceptYN='';
redirect='';
sre_flag='';
invitorservalias='';
invitationId='';
invusertype='';
/******************************************************/
function definePage(){
	if(sr_mode =='REGIS'){
		sre_core.initializeList(DynDetail);
			DynDetail[0] = "Personal entity&nbsp;|RADIO|E|accountType|40|10|N|N|N| | | |<span>A \"Personal account\" has limited service options and are optimized for individual non-commercial use. Servies offered under \"Business or branded account\" offer services that can be customized for each account's specific need. Basic services are <b><i>FREE</i></b> for either category.</span>";
			DynDetail[1] = "Business or branded entity&nbsp;|RADIO|E|accountType|40|10|N|N|N| | | |";
		if (SREUsertype =='INDV') {
			utype='N';
		} else if (SREUsertype =='BIZGEN') {
			utype='Y';
		}
	} else if(sr_mode =='AUTH'){
		sre_core.initializeList(DynDetail);
		if(SREUsertype =='INDV') {
			utype='N';
			DynDetail[0] = "Business or branded entity&nbsp;|CHECKBOX|E|utype|40|10|N|N|N| ";
			DynDetail[1] = "Your email (sign in)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|TEXT|E|primemail|25|50|Y| |N| | ";
//			DynDetail[2] = "Password |PASSWORD|E|password|20|20|Y| |Y| | | |<span class=\"menuReg\" style=\"text-decoration:underline;background:transparent;\" onclick=\"AdvancedSignIn()\">Advanced</span>";
		//	DynDetail[3] = "Keep signed in ?|CHECKBOX|E|keepsignin|40|10|N|N|N| | | |<span class=\"menuReg\" style=\"text-decoration:underline;background:transparent;\" onclick=\"AdvancedSignIn()\">Advanced</span>";
		} else if (SREUsertype =='BIZGEN') {
			utype='Y';
			DynDetail[0] = "Business or branded entity&nbsp;|CHECKBOX|E|utype|40|10|N|N|N| ";
			DynDetail[1] = "Business or brand sign in&nbsp;|TEXT|E|bizalias|25|50|Y| |N| | ";
//			DynDetail[2] = "Password |PASSWORD|E|password|20|20|Y| |Y| | | |<span class=\"menuReg\" style=\"text-decoration:underline;background:transparent;\" onclick=\"AdvancedSignIn()\">Advanced</span>";
		//	DynDetail[3] = "Keep signed in ?|CHECKBOX|E|keepsignin|40|10|N|N|N| | | |<span class=\"menuReg\" style=\"text-decoration:underline;background:transparent;\" onclick=\"AdvancedSignIn()\">Advanced</span>";
		} 
	}
}
function CreatePage(){
//	SetIpCountry();
	mainform= null;$("sr_pages").innerHTML='';
	sre_controls.cancelDone("index");
	definePage();
	mainform = new sre_dynform.Settings();
	mainform.borderColor='aaaaaa';
	mainform.backColor='rgb(230,230,255)';
	mainform.fromName="index";
	mainform.divName="sr_pages";
	mainform.addDynArray(DynDetail);
	sre_dynform.dynForm ("srpages",mainform);
	if(sr_mode =='REGIS'){
		var htm1='';$("sr_actions").innerHTML='';
		if (SREUsertype =='INDV') {
			$("accountType_0").checked = true;
		} else if (SREUsertype =='BIZGEN') {
			$("accountType_1").checked = true;
		}
		htm1 +=addActionButton('BUTTON','BUTTON','SRE_JOIN','Join','Join','AUTH_00001');
		displayActionButton(htm1,"sr_actions"); 
	}else if(sr_mode =='AUTH'){
		var htm='';$("sr_actions").innerHTML='';
		htm +=addActionButton('BUTTON','BUTTON','SRE_CONTINUE','Continue','Continue','AUTH_00013');
		htm +='<br>';
		htm +=addActionButton('','LINK','SRE_FORGOT','Forgot password ?','Forgot','AUTH_00015');
		htm +='<br>';
		htm +=addActionButton('','LINK','SRE_JOIN','Join ProDuniya','JoinTab','AUTH_00015');
		displayActionButton(htm,"sr_actions"); 
	}
}
function SetIpCountry(){
	Page='';
	var redirecturl = "/srp/srp_usr/sub/gen/gen_ip_country.srp";
	srePHPAsyncSubmit(Page,redirecturl,INDX_COUNTRY_FOUND,true,"CTY_FND",'Y');
}
function INDX_COUNTRY_FOUND(response,obj,id){
	defcountry = sre_ajax.parseAsyncNameValueResponse(response,'defcountry','^');
	defcountrydesc = sre_ajax.parseAsyncNameValueResponse(response,'defcountrydesc','^');
	usercountry = defcountry;
	usercountrydesc = defcountrydesc;
}
function Join(){
	sreAssignServer('REGIS',SREUsertype,'eMilieu','EN','ALL','APPL','');
}
function AdvancedSignIn(){
	Continue();
}
function Continue(){
	var complete=1;extramsg='';
	if(SREUsertype =='INDV') {
		if(password=='' || primemail =='' ){
			complete = 0;
		}
		extramsg = '<primemail>'+primemail+'</primemail>';
	} else if(SREUsertype =='BIZGEN') {
		if(password=='' || bizalias =='' ){
			complete = 0;
		} 
		extramsg = '<bizalias>'+bizalias+'</bizalias>';
	}
	if(complete == 0){
	//	extramsg += '<keepsignin>'+keepsignin+'</keepsignin>';
	//	extramsg=DoAsciiHex(extramsg,'A2H');
		sreAssignServer('AUTH',SREUsertype,'eMilieu','EN','ALL','APPL','');
	} else {
		sreAssignServer('AUTH',SREUsertype,'eMilieu','EN','ALL','APPL',extramsg,'',DIR_AUTH_SERV,"id5234");
	}
}
function DIR_AUTH_SERV(response,obj,id){
alert(response);	
	clearError();
	if(id == "id5234") {
		if(sre_ajax.errorPresent(response) ){
			sre_ajax.processAsyncError(response);
		} else {
			var Page ='';path='';
			SREUsertype = sre_ajax.parseAsyncNameValueResponse(response,'usertype');
			channel = sre_ajax.parseAsyncNameValueResponse(response,'channel');
			thirdparty = sre_ajax.parseAsyncNameValueResponse(response,'thirdparty');
			language = sre_ajax.parseAsyncNameValueResponse(response,'language');
			country = sre_ajax.parseAsyncNameValueResponse(response,'country');
			action = sre_ajax.parseAsyncNameValueResponse(response,'action');
			cgi = sre_ajax.parseAsyncNameValueResponse(response,'cgi');
			ip = sre_ajax.parseAsyncNameValueResponse(response,'ip');
			sess = sre_ajax.parseAsyncNameValueResponse(response,'sess');
			extramsg = sre_ajax.parseAsyncNameValueResponse(response,'extramsg');
			extrafunc = sre_ajax.parseAsyncNameValueResponse(response,'extrafunc');
			srepath +='http://';
			srepath += sre_core.trim(channel);
			srepath +='.';
			srepath += SREHost;
			//alert(password);
			//password=DoAsciiHex(password,'A2H');
			Page += sre_dynform.dynamicMsg("srpages",'mainform','Y'); //---last parameter shows that we want to add extra tags before submission.
			Page += '<thirdparty>eMilieu</thirdparty>';
			Page += '<language>EN</language>';
			Page += '<country>ALL</country>';
			Page += '<usertype>'+SREUsertype+'</usertype>';
			Page += '<member>N</member>';
			alert(Page);
			path = "/srp/srp_usr/sub/auth/auth_authmain.srp";
			srePHPAsyncSubmit(Page,path,AUTH_CONFIRMED_INDX,true,'AUTH_MAIN_i','Y'); //---last parameter to show user processing state.
		}
	}
}
function AUTH_CONFIRMED_INDX(response,obj,id) {
//alert(response);	
	if(id == 'AUTH_MAIN_i') {
		if(sre_ajax.errorPresent(response) ){
			sre_ajax.processAsyncError(response);
		} else {
			SEND_PORTAL_PROFILE(response,srepath);
		}
	}
}
/******************************************************/




function showTerms(){
	turl = '/SUPPORT/INFO/T_C.html';
	tpop = new sre_pop_msg.Settings();
	tpop.setHeader("ProDuniya Terms & Conditions");
	tpop.PageName = 'index';  //---MUST HAVE parameters
	tpop.popWidth = 500; //--- Mandatory set up
	tpop.popHeight = 300; //--- Mandatory set up 	
	sre_pop_msg.msgPop ("sre_tpop",tpop,"tpopup");
}
function tpopup(){
	html='';
	html+='<table border="0" width="500" height="300" cellpadding="0" cellspacing="0" >';
	html+='<tr><td align="center" valign="top">';
	html+='<span class="blkBig" style="font-weight:bold;">';
	html+='<iframe src="'+turl+'" width="500" height="300" scroll="y" frameborder="0">';
	html+='</iframe>';
	html+='</span></td></tr>';
	html+='</table>';	
	return html;
}
function index_OnFocus(varname,value){
}
function index_OnChange(ids,value){
}
function index_MenuCancel(menuname) {
}
function index_CalendarClick(calName,date,unformated,datedisplay) {
}
function index_MenuScroll(menuname,dir){
}
function index_MenuOut(num,indx){
}
function index_MenuOver(num,indx){
}
function index_MenuClick(menuname,menuidx,menuCode,menuDesc){

}
function index_OnBlur(id,val){
}
function index_ControlOver(flag,varname){
}
function index_ControlOut(flag){
}
function index_PopMsgClose(id,action,param){
}
function index_OnRadio(name,val){
	$("accountType"+'_'+val).value=val;
	accountType=val;
	if(val=='0'){
		SREUsertype='INDV';
	} else if(val=='1'){
		SREUsertype='BIZGEN';
	}
	CreatePage();
}
function index_TabChanged(name,code,desc){
	if(name=='regtab'){
		sr_mode = code;
		CreatePage();
	}
	if(sr_mode =='REGIS'){
		x=$("accountType_0");
		x.checked = true;
	}
}
function JoinTab(){
	sre_tab.changeTabs('REGIS','Join',1,"registab",'regtab');
}
function index_ToggleCheck(name,val){
	if(name == 'utype'){
		if(val=='N'){
			SREUsertype='INDV';
		} else if (val=='Y'){
			SREUsertype='BIZGEN';
		}
		CreatePage();
		if(sr_mode =='AUTH'){
			CreatePage();
		}
	}
//	if(name == 'keepsignin'){
//		keepsignin=val;
//	}
}
function index_PopMsgClose(msgid,action,param) {
}
function index_GridClick(num,rw,cl,curcolval,fullcol,indx) {
}

function index_GridEdited(num,rw,cl,oldcolval,fullcol,newval) { 
}
function index_OnSubmit(retval,vals) {
}


function Remind(){
	Page='';Page=GET_GEN_DTSTRUCT();
/*	
	Page +='<thirdparty>eMilieu</thirdparty>';
	Page +='<language>EN</language>';
	Page +='<country>ALL</country>';
	Page +='<usertype>BIZGEN</usertype>';
	Page +='<processlabel>APPL</processlabel>';
	Page +='<action>REGISTER</action>';
*/	
	var redirecturl = "/srp/srp_gen/remind.srp";
	srePHPSubmit(Page,redirecturl);
}
function Contact() {
	Remind();
}
function PerServices() {
	Page='';Page=GET_GEN_DTSTRUCT();
/*	
	Page +='<thirdparty>eMilieu</thirdparty>';
	Page +='<language>EN</language>';
	Page +='<country>ALL</country>';
	Page +='<usertype>BIZGEN</usertype>';
	Page +='<processlabel>APPL</processlabel>';
	Page +='<action>REGISTER</action>';
*/	
	var redirecturl = "/srp/srp_gen/perservices.srp";
	srePHPSubmit(Page,redirecturl);
}
function BizServices() {
	Page='';Page=GET_GEN_DTSTRUCT();
/*	
	Page +='<thirdparty>eMilieu</thirdparty>';
	Page +='<language>EN</language>';
	Page +='<country>ALL</country>';
	Page +='<usertype>BIZGEN</usertype>';
	Page +='<processlabel>APPL</processlabel>';
	Page +='<action>REGISTER</action>';
*/	
	var redirecturl = "/srp/srp_gen/bizservices.srp";
	srePHPSubmit(Page,redirecturl);
}
function Terms() {
	showTerms();
}
function Faq() {
	Page='';Page=GET_GEN_DTSTRUCT();
/*
 	Page +='<thirdparty>eMilieu</thirdparty>';
	Page +='<language>EN</language>';
	Page +='<country>ALL</country>';
	Page +='<usertype>BIZGEN</usertype>';
	Page +='<processlabel>APPL</processlabel>';
	Page +='<action>REGISTER</action>';
*/	
	var redirecturl = "/srp/srp_gen/faq.srp";
	srePHPSubmit(Page,redirecturl);
}
function Forgot(){
	sreAssignServer('FORGOT',SREUsertype,'eMilieu','EN','ALL','APPL','');
}





