// JavaScript Document
var browser=navigator.appName;

function changeMenuOver(index){
	document.getElementById('m'+index+'1').style.textDecoration='underline';
	document.getElementById('m'+index+'2').style.textDecoration='underline';
}

function changeMenuOut(index){
	document.getElementById('m'+index+'1').style.textDecoration='none';
	document.getElementById('m'+index+'2').style.textDecoration='none';
}

var onoffarray = new Array();
var onoffactivity = new Array();
var onoffbuscomm = new Array();
var onoffjob = new Array();
var onoffscheme = new Array();
//var onofflms = new Array();
//var onoffcapture = new Array();
//var onoffdm = new Array();
//var onoffq = new Array();

var activitymenus = new Array();
var buscommmenus = new Array();
var jobmenus = new Array();
var schememenus = new Array();
//var lmsmenus = new Array();
//var capturemenus = new Array();
//var dmmenus = new Array();
//var qmenus = new Array();


var numofactivitymenus=8;
var numofbuscommmenus = 3;
var numofjobmenus = 4;
var numofschememenus = 6;
//var numoflmsmenus=3;
//var numofcapturemenus=5;
//var numofdmmenus=3;
//var numofqmenus=13;

activitymenus[0]="<p class='innermaintext'>Earlier the 10 day Raas - Garba program was limited to women and children and used to be organised in the afternoons. Since the last 5 years this festival is celebrated by all men, women and children and is organised as per the convenience of all.<br><br>On the day of Sharapoornima, various competitions are organised based on the traditional attire of the crowd for various age groups. Since the last 3 years the 10 day program period has been reduced to 3 days due to the inconvenience faced by the lohana members in commuting.</p>";

activitymenus[1]="<p class='innermaintext'>In the winter season a picnic cum community lunch is organised in and around Poona. Various games, housie, prices for the winners gracve the occasion of Undhya party.</p>";

activitymenus[2]="<p class='innermaintext'></p>";

activitymenus[3]="<p class='innermaintext'></p>";

activitymenus[4]="<p class='innermaintext'></p>";

activitymenus[5]="<p class='innermaintext'></p>";

activitymenus[6]="<p class='innermaintext'></p>";

activitymenus[7]="<p class='innermaintext'></p>";

buscommmenus[0]="<p class='innermaintext' style='width:170px; cursor:pointer' onclick='makeRequest(\"registerbusiness.php\", \"contentdiv\")'>Register your business and find out potential customers from the available list.</p>";

buscommmenus[1]="<p class='innermaintext' style='width:170px; cursor:pointer' onclick='makeRequest(\"requestsellrent.php\", \"contentdiv\")'>Want to sell / rent commodities?</p><p class='innermaintext' style='width:170px; cursor:pointer' onclick='makeRequest(\"requestbuy.php\", \"contentdiv\")'>Put in your request to buy commodities.</p>";

buscommmenus[2]="<p class='innermaintext' style='width:170px'>Advertise your business in the classifieds. Free / Paid classifieds are available.</p>";

jobmenus[0]="<p class='innermaintext' style='width:170px; cursor:pointer' onclick='makeRequest(\"uploadcv.php\", \"contentdiv\")'>Register and upload your resumes for job oportunities.</p>";

jobmenus[1]="<p class='innermaintext' style='width:170px; cursor:pointer' onclick='makeRequest(\"joblogin.php\", \"contentdiv\")'>You need to login to access this the job opening feature in detail.</p>";

jobmenus[2]="<p class='innermaintext' style='width:170px; cursor:pointer' onclick='makeRequest(\"employerjobrequirements.php\", \"contentdiv\")'>Employers can put in their job requirements here.</p>";

jobmenus[3]="<p class='innermaintext' style='width:170px; cursor:pointer' onclick='makeRequest(\"searchjob.php\", \"contentdiv\")'>Job hunters can find a job match as per their requirements.</p>";

schememenus[0]="<p class='innermaintext'></p>";

schememenus[1]="<p class='innermaintext'></p>";

schememenus[2]="<p class='innermaintext'></p>";

schememenus[3]="<p class='innermaintext'></p>";

schememenus[4]="<p class='innermaintext'></p>";

schememenus[5]="<p class='innermaintext'></p>";


for (loop=0; loop<numofactivitymenus; loop++){
 onoffactivity[loop]=0;
}

for (loop=0; loop<numofbuscommmenus; loop++){
 onoffbuscomm[loop]=0;
}

for (loop=0; loop<numofjobmenus; loop++){
 onoffjob[loop]=0;
}

for (loop=0; loop<numofschememenus; loop++){
 onoffscheme[loop]=0;
}

/*for (loop=0; loop<numoflmsmenus; loop++){
 onofflms[loop]=0;
}

for (loop=0; loop<numofcapturemenus; loop++){
 onoffcapture[loop]=0;
}

for (loop=0; loop<numofdmmenus; loop++){
 onoffdm[loop]=0;
}

for (loop=0; loop<numofqmenus; loop++){
 onoffq[loop]=0;
}
*/

function collapse_menu(spanid, spannumber, content, menuname){
//	alert(spanid + spannumber + content + menuname);
	if(menuname == 'activitymenus'){
		onoff = onoffactivity;
	}else if(menuname == 'buscommmenus'){
		onoff = onoffbuscomm;
	}else if(menuname == 'jobmenus'){
		onoff = onoffjob;
	}else if(menuname == 'schememenus'){
		onoff = onoffscheme;
	}/*else if(menuname == 'lmsmenus'){
		onoff = onofflms;
	}else if(menuname == 'capturemenus'){
		onoff = onoffcapture;
	}else if(menuname == 'dmmenus'){
		onoff = onoffdm;
	}else if(menuname == 'qmenus'){
		onoff = onoffq;
	}*/
	var spans = document.getElementsByTagName("span");
	var presentspans = new Array();
	var k = 0;
	for(i=0;i<spans.length;i++){
		if(document.getElementById(spans[i].id)){
			presentspans[k] = spans[i];
			k++;
		}
	}

    var spanArray=[];
    var arrCount=0;
	var str;
	var str1;
	var parentdivname;
    for(x=0;x<presentspans.length;x++){
		if(spans[x].id != ''){
			if(x == spannumber){
				if(onoff[spannumber] == 0){
					onoff[spannumber] = 1;
					document.getElementById(spanid).style.display = 'block';
					document.getElementById(spanid).innerHTML = content;
					parentdivname = spanid+'div';
					str = document.getElementById(parentdivname).innerHTML;
					str1 = str.replace('+', '-');
					document.getElementById(parentdivname).innerHTML = str1;
				}else{
					onoff[spannumber] = 0;
					document.getElementById(spanid).style.display = 'none';
					document.getElementById(spanid).style.innerHTML = '';
					parentdivname = spanid+'div';
					str = document.getElementById(parentdivname).innerHTML;
					str1 = str.replace('-', '+');
					document.getElementById(parentdivname).innerHTML = str1;
				}	
//				alert(onoff);
			}else{									// reset other menus
//				alert('inside else');
				if(onoff[x] == 1){
//					alert(onoff[x]);
					onoff[x] = 0;
					document.getElementById(presentspans[x].id).style.display = 'none';
					document.getElementById(presentspans[x].id).style.innerHTML = '';
					parentdivname = presentspans[x].id+'div';
					str = document.getElementById(parentdivname).innerHTML;
					str1 = str.replace('-', '+');
					document.getElementById(parentdivname).innerHTML = str1;
				}
			}
		}
	}
	
	if(menuname == 'activitymenus'){
		onoffactivity = onoff;
	}else if(menuname == 'buscommmenus'){
		onoffbuscomm = onoff;
	}else if(menuname == 'jobmenus'){
		onoffjob = onoff;
	}else if(menuname == 'schememenus'){
		onoffscheme = onoff;
	}/*else if(menuname == 'lmsmenus'){
		onofflms = onoff;
	}else if(menuname == 'capturemenus'){
		onoffcapture = onoff;
	}else if(menuname == 'dmmenus'){
		onoffdm = onoff;
	}else if(menuname == 'qmenus'){
		onoffq = onoff;
	}*/
}

function countChar(targetField, countField, maxLimit){
	if(targetField){
		if(targetField.value.length > maxLimit)
			targetField.value = targetField.value.substring(0, maxLimit);
		else
			countField.innerHTML = "["+ (maxLimit - targetField.value.length) + "]";
	}
}

/*function callAjaxToSearch(category, commodityname){
	makeRequest('searchresultsforrequesttobuydetails.php?category='+category+'&cname='+commodityname+'' ,'resultdiv');
}*/

function toggleSelection(but,pos){
	var imgName = "";
	var str = "";
	var obj;
	for(i=1;i<=5;i++){
		var button = 'sb'+i;
		obj = document.getElementById('sb'+i);
		if(obj.currentStyle){
			if(browser == 'Microsoft Internet Explorer')
				imgName = obj.currentStyle.backgroundImage;
		}else
			imgName = getComputedStyle(obj,'').getPropertyValue('background-image');
			
		if(imgName != 'none'){
			obj.style.backgroundImage = "";
			if(but == button)
				document.getElementById('position').value = '';		// set hidden values
		}else{
			if(but==button){
				obj.style.backgroundImage = "url(images/selected.gif)";
				obj.style.backgroundRepeat = "no-repeat";
				document.getElementById('position').value = pos;		// set hidden values
			}
		}
	}
//	alert(document.getElementById('position').value);
}

var objwin;
function openpopup(appl, x, y){
	var top = 100;
	if((top + 300) > (y-50))	top = (y - 400);
	if(top <= 0) top = 10;
	objwin = window.open('papplications.php?appl='+appl+'', 'product_applications', 'width=500, height=300, top='+top+', left=400, toolbars=no, scrollbar=yes, resizable=no, statusbar=no'); 
	return true
}


function openreadmore(table, column, wherecol, id, x, y){
	var top = 100;
	if((top + 300) > (y-50))	top = (y - 400);
 	if(top <= 0) top = 10;
	objwin = window.open('readmore.php?table='+table+'&column='+column+'&wherecol='+wherecol+'&id='+id+'', 'product_applications', 'width=500, height=300, top='+top+', left=400, toolbars=no, scrollbar=yes, resizable=no, statusbar=no'); 
	return true
}

function closepopup(){
	if(objwin && !objwin.closed)
		objwin.close();
}


function keyPressed(){
	document.body.onkeypress = function (event) {
		event = event || window.event;
		if (event.keycode = 13) {
			document.getElementById('search').submit;
			return false;
		}
		return true;
	}
}

// function called when the button is clicked from the search results
function showSearchDetails(recid, tblname, cat, cname, website, email, pname, start, limit, page, txt, pid, mid){
	var url = "show-search-details.php?recid="+recid+"&tablename="+tblname+"&cat="+cat+"&cname="+cname+"&ws="+website+"&email="+email+"&pname="+pname+"&start="+start+"&limit="+limit+"&page="+page+"&txt="+txt+"&pid="+pid+"&srccat=P&mid="+mid;
	makeRequest(url, 'contentdiv');
	makeRequest('srcdetails.php?recid='+recid+'&tablename='+tblname+'&pid='+pid, 'contentdiv1');
	if(cat == 'cdetails')
		makeRequest('srcdetails.php?recid='+recid+'&tablename='+tblname+'&pid='+pid, 'contentdiv1');
	else if(cat == 'pdetails')	
		makeRequest('srpdetails.php?recid='+recid+'&tablename='+tblname+'&pid='+pid, 'contentdiv1');	
	else if(cat == 'cpdetails')	
		makeRequest('srcpdetails.php?recid='+recid+'&tablename='+tblname+'&pid='+pid+'&mid='+mid, 'contentdiv1');	
	else if(cat == 'opdetails')	
		makeRequest("sropdetails.php?recid="+recid+"&tablename="+tblname+"&cat="+cat+"&start="+start+"&limit="+limit+"&page="+page+"&txt="+txt+"&pid="+pid+"&srccat=P", 'contentdiv1');	
//		alert("sropdetails.php?recid="+recid+"&tablename="+tblname+"&cat="+cat+"&cname="+cname+"&ws="+website+"&email="+email+"&pname="+pname+"&start="+start+"&limit="+limit+"&page="+page+"&txt="+txt+"&pid="+pid+"&srccat=P&mid="+mid+"", 'contentdiv1');
}

// function called when the button is clicked from the search results
/*function showSearchDetailsForCompanyNames(recid, tblname, cat, cname, website, email, start, limit, page, txt, mid){
	var srccat = '';
	if(txt != '')	srccat = 'C';
	else 			srccat = 'EC';	
	alert('srccat = ' + srccat);
	var url = "show-search-details.php?recid="+recid+"&tablename="+tblname+"&cat="+cat+"&cname="+cname+"&ws="+website+"&email="+email+"&start="+start+"&limit="+limit+"&page="+page+"&txt="+txt+"&mid="+mid+"&srccat="+srccat;
	makeRequest(url, 'contentdiv');
	//makeRequest('srcdetails.php?recid='+recid+'&tablename='+tblname+'&mid='+mid, 'contentdiv1');
	if(cat == 'cdetails')
		makeRequest('srcdetails.php?recid='+recid+'&tablename='+tblname+'&mid='+mid, 'contentdiv1');
	else if(cat == 'cpdetails')	
		makeRequest('srcpdetails.php?recid='+recid+'&tablename='+tblname+'&mid='+mid, 'contentdiv1');	
	else if(cat == 'opdetails')	
		makeRequest("sropdetails.php?recid="+recid+"&tablename="+tblname+"&cat="+cat+"&start="+start+"&limit="+limit+"&page="+page+"&txt="+txt+"&pid="+pid+"&srccat=P", 'contentdiv1');	
}*/

function showSearchDetailsForCompanyNames(recid, tblname, cat, cname, website, email, start, limit, page, txt, mid){
	var srccat = '';
	if(txt != '')	srccat = 'C';
	else 			srccat = 'EC';	
	var url = "show-search-details.php?recid="+recid+"&tablename="+tblname+"&cat="+cat+"&cname="+cname+"&ws="+website+"&email="+email+"&start="+start+"&limit="+limit+"&page="+page+"&txt="+txt+"&mid="+mid+"&srccat="+srccat;
	makeRequest(url, 'contentdiv');
	//makeRequest('srcdetails.php?recid='+recid+'&tablename='+tblname+'&mid='+mid, 'contentdiv1');
	if(cat == 'cdetails')
		makeRequest('srcdetails.php?recid='+recid+'&tablename='+tblname+'&mid='+mid, 'contentdiv1');
	if(cat == 'cpdetails')	
		makeRequest('srcpdetails.php?recid='+recid+'&tablename='+tblname+'&mid='+mid, 'contentdiv1');	
	if(cat == 'pdetails')	
		makeRequest('srpdetails.php?recid='+recid+'&tablename='+tblname+'&pid='+pid, 'contentdiv1');	
	if(cat == 'opdetails')	
		makeRequest("sropdetails.php?recid="+recid+"&tablename="+tblname+"&cat="+cat+"&start="+start+"&limit="+limit+"&page="+page+"&txt="+txt+"&pid="+pid+"&srccat=P", 'contentdiv1');	
}


// function called when the button is clicked from the advanced search results
function showSearchDetailsForAdvancedSearch(recid, tblname, cat, cname, website, email, pname, start, limit, page, txt, pid, mid, srccat){
	var url = "show-search-details.php?recid="+recid+"&tablename="+tblname+"&cat="+cat+"&cname="+cname+"&ws="+website+"&email="+email+"&pname="+pname+"&start="+start+"&limit="+limit+"&page="+page+"&txt="+txt+"&pid="+pid+"&mid="+mid+"&srccat="+srccat;
	makeRequest(url, 'contentdiv');
	makeRequest('srcdetails.php?recid='+recid+'&tablename='+tblname+'&mid='+mid, 'contentdiv1');
	if(cat == 'cdetails')
		makeRequest('srcdetails.php?recid='+recid+'&tablename='+tblname+'&mid='+mid, 'contentdiv1');
	else if(cat == 'cpdetails')	
		makeRequest('srcpdetails.php?recid='+recid+'&tablename='+tblname+'&mid='+mid, 'contentdiv1');	
	else if(cat == 'opdetails')	
		makeRequest("sropdetails.php?recid="+recid+"&tablename="+tblname+"&cat="+cat+"&start="+start+"&limit="+limit+"&page="+page+"&txt="+txt+"&pid="+pid+"&srccat="+srccat, 'contentdiv1');	
}

function changeTab(id){
	if(id == 't1'){
		document.getElementById(id).style.backgroundColor = "#ffffff";
		if(document.getElementById('t2'))
			document.getElementById('t2').style.backgroundColor = "#f5f5dc";
		if(document.getElementById('t3'))
			document.getElementById('t3').style.backgroundColor = "#f5f5dc";
		if(document.getElementById('t4'))
			document.getElementById('t4').style.backgroundColor = "#f5f5dc";
	}
	if(id == 't2'){
		document.getElementById(id).style.backgroundColor = "#ffffff";
		if(document.getElementById('t1'))
			document.getElementById('t1').style.backgroundColor = "#f5f5dc";
		if(document.getElementById('t3'))
			document.getElementById('t3').style.backgroundColor = "#f5f5dc";
		if(document.getElementById('t4'))
			document.getElementById('t4').style.backgroundColor = "#f5f5dc";
	}
	if(id == 't3'){
		document.getElementById(id).style.backgroundColor = "#ffffff";
		if(document.getElementById('t1'))
			document.getElementById('t1').style.backgroundColor = "#f5f5dc";
		if(document.getElementById('t2'))
			document.getElementById('t2').style.backgroundColor = "#f5f5dc";
		if(document.getElementById('t4'))
			document.getElementById('t4').style.backgroundColor = "#f5f5dc";
	}
	if(id == 't4'){
		document.getElementById(id).style.backgroundColor = "#ffffff";
		if(document.getElementById('t1'))
			document.getElementById('t1').style.backgroundColor = "#f5f5dc";
		if(document.getElementById('t2'))
			document.getElementById('t2').style.backgroundColor = "#f5f5dc";
		if(document.getElementById('t3'))
			document.getElementById('t3').style.backgroundColor = "#f5f5dc";
	}
}



