//this javascript page is for redirecting urls to the original mapmyindia.com home page

// REDIRECT SECTION

function dirHomeSubmit()    {
    var fromAddr = document.getElementById('dirFrom').value;
    var toAddr   = document.getElementById('dirTo').value;
    var viaAddr  = document.getElementById('addVia').value;
    
    if(fromAddr == "")   {
        alert("The 'From' field cannot be empty. Please, enter a location name.");
    }
    else if(toAddr == "")   {
        alert("The 'To' field cannot be empty. Please, enter a location name.");
    }  
    
    var dirHomeForm = document.getElementById('dirHomeForm'); 
    dirHomeForm.action = "http://www.mapmyindia.com/online/?from="+fromAddr+"&to="+toAddr+"&via="+viaAddr+"&type=best&q=dir";
    dirHomeForm.method = "post";
    dirHomeForm.submit();
    
};

function mapHomeSubmit()    {
    var mapAddr = document.getElementById('mapWhere').value;
      
    if(mapAddr == "")   {
        alert("The 'Where' field cannot be empty. Please, enter a location name.");
    }
    
    var mapHomeForm = document.getElementById('mapHomeForm'); 
    mapHomeForm.action = "http://mapmyindia.com/online/?addr="+mapAddr+"&type=best&q=map";
    mapHomeForm.method = "post";
    mapHomeForm.submit();
};

function localHomeSubmit()    {
    var localAddr = document.getElementById('localWhere').value;
    var catCode   = document.getElementById('localWhat').value;
    
    if(localAddr == "")   {
        alert("The 'Where' field cannot be empty. Please, enter a location name.");
    } else if (catCode == "")   {
        alert("The 'What' field cannot be empty. Please, select a sub-category.");
        return null;        
    }
    //TODO: cat dropdown
    var localHomeForm = document.getElementById('mapHomeForm'); 
    localHomeForm.action = "http://mapmyindia.com/online/?cx=&cy=&cz=&cat="+catCode+"&q=localStr&where="+localAddr;
    //localHomeForm.action = "http://192.168.44.22:8080/online/?cx=&cy=&cz=&cat="+catCode+"&q=localStr&where="+localAddr;
    localHomeForm.method = "post";
    localHomeForm.submit();
};

function bizHomeSubmit()    {
    var bizWhat  = document.getElementById('businessWhat').value;
    var bizWhere = document.getElementById('businessWhere').value;
      
    if(bizWhat.value == "")   {
        alert("The 'What' field cannot be empty. Please, enter a category.");
    } else if(bizWhere.value == "")   {
        alert("The 'Where' field cannot be empty. Please, enter a location name.");
    }
    
    var bizHomeForm = document.getElementById('bizHomeForm'); 
    bizHomeForm.action = "http://mapmyindia.com/online/index.jsp";
    bizHomeForm.method = "post";
    bizHomeForm.submit();
};

function elocHomeSubmit()   {
    var elocAddr = document.getElementById('elocWhere').value;
      
    if(elocAddr.value == "")   {
        alert("The 'Which' field cannot be empty. Please, enter an eLocation name.");
    }
    
    var elocHomeForm = document.getElementById('mapHomeForm'); 
    elocHomeForm.action = "http://mapmyindia.com/online/?cx=&cy=&cz=&elocid="+elocAddr+"&type=elocSearch&q=eloc";
    elocHomeForm.method = "post";
    elocHomeForm.submit();
};

function generateSubCatDropdown()    {
var mainCat    = document.getElementById('mainCat').value;
var subCatSpan = document.getElementById('subCatSpan');
if(mainCat == "default")   {
subCatSpan.innerHTML = "";
subCatSpan.innerHTML = "<select id='localWhat' class='black_txt'> <option value='' selected='selected'>&nbsp;</option> </select>";
} else if(mainCat == "COMSER") {
subCatSpan.innerHTML = "";
subCatSpan.innerHTML = "<select id='localWhat' class='black_txt'> <option value='' selected='selected'>--------Select Sub-category---------</option> <option value='COMBAN'>Banquet &amp; Marriage Hall</option> <option value='COMCRM'>Crematorium, Burial Ground</option> <option value='COMEDU'>Educational Institution</option> <option value='COMEMB'>Embassies &amp; Consulates</option> <option value='COMFIR'>Fire Station</option> <option value='COMGOV'>Government Office</option> <option value='COMLIB'>Educational Institution</option> <option value='COMOTH'>Others</option> <option value='COMPOL'>Police Station</option> <option value='COMPTO'>Post Office</option> </select>";
} else if(mainCat == "FINSER") {
subCatSpan.innerHTML = "";
subCatSpan.innerHTML = "<select id='localWhat' class='black_txt'> <option value='' selected='selected'>--------Select Sub-category---------</option> <option value='FINBNK'>Bank</option> <option value='FINATM'>ATM</option> </select>";
} else if(mainCat == "HTHWEL") {
subCatSpan.innerHTML = "";
subCatSpan.innerHTML = "<select id='localWhat' class='black_txt'> <option value='' selected='selected'>--------Select Sub-category---------</option> <option value='HLTAMB'>Ambulance Service</option> <option value='HLTAUR'>Fitness Center &amp; Yoga</option> <option value='HLTBLD'>Blood Bank</option> <option value='HLTMED'>Medical Service</option> <option value='HLTGYM'>Fitness Center &amp; Yoga</option> </select>";
} else if(mainCat == "HISPLC") {
subCatSpan.innerHTML = "";
subCatSpan.innerHTML = "<select id='localWhat' class='black_txt'> <option value='' selected='selected'>--------Select Sub-category---------</option> <option value='HISPLC'>Historical Places</option> </select>";
} else if(mainCat == "HOTDIN") {
subCatSpan.innerHTML = "";
subCatSpan.innerHTML = "<select id='localWhat' class='black_txt'> <option value='' selected='selected'>--------Select Sub-category---------</option> <option value='HOTALL'>Hotels - Budget</option> <option value='HOTPRE'>Hotels - Premium</option> </select>";
} else if(mainCat == "NATURE") {
subCatSpan.innerHTML = "";
subCatSpan.innerHTML = "<select id='localWhat' class='black_txt'> <option value='' selected='selected'>--------Select Sub-category---------</option> <option value='NTCHLS'>Hill Stations</option> <option value='NTCLAB'>Lakes &amp; Beaches</option> <option value='NTCWNT'>National Parks</option> </select>";
} else if(mainCat == "PILPLC") {
subCatSpan.innerHTML = "";
subCatSpan.innerHTML = "<select id='localWhat' class='black_txt'> <option value='' selected='selected'>--------Select Sub-category---------</option> <option value='PLPBUD'>Religious - Buddhist</option> <option value='PLPCHU'>Religious - Christian</option> <option value='PLPGUR'>Religious - Sikh</option> <option value='PLPHIN'>Religious - Hindu</option> <option value='PLPISL'>Religious - Islamic</option> <option value='PLPJAN'>Religious - Jain</option> <option value='PLPOTH'>Religious - Others</option></select>";
} else if(mainCat == "RCEENT") {
subCatSpan.innerHTML = "";
subCatSpan.innerHTML = "<select id='localWhat' class='black_txt'> <option value='' selected='selected'>--------Select Sub-category---------</option> <option value='RCNADV'>Tourist Venues</option> <option value='RCNAUD'>Cinemas &amp; Theatres</option> <option value='RCNCLB'>Club &amp; Golf Courses</option> <option value='RCNFRM'>Banquet & Marriage Hall</option> </select>";
} else if(mainCat == "RESDIN") {
subCatSpan.innerHTML = "";
subCatSpan.innerHTML = "<select id='localWhat' class='black_txt'> <option value='' selected='selected'>--------Select Sub-category---------</option> <option value='FODFFD'>Restaurant - Fast Food</option> <option value='FODIND'>Restaurant - Indian</option> <option value='FODOTL'>Restaurant - Oriental</option> <option value='FODCON'>Restaurant - Continental</option> <option value='FODPUB'>Restaurant - Pubs &amp; Bars</option> <option value='FODOTH'>Restaurant - Others</option> </select>";
} else if(mainCat == "SHPCMC") {
subCatSpan.innerHTML = "";
subCatSpan.innerHTML = "<select id='localWhat' class='black_txt'> <option value='' selected='selected'>--------Select Sub-category---------</option> <option value='COMGAS'>Commercial &amp; Industrial</option> <option value='SHPMAL'>Shopping Malls</option> <option value='SHPMKT'>Shopping Markets</option> <option value='SHPRTC'>Shopping Retail Chain</option> <option value='SHPRTS'>Shopping Retail Shops</option> <option value='SHPAUT'>Automotive Dealers</option> <option value='SHPOTH'>Shopping Others</option> </select>";
} else if(mainCat == "TRNPRT") {
subCatSpan.innerHTML = "";
subCatSpan.innerHTML = "<select id='localWhat' class='black_txt'> <option value='' selected='selected'>--------Select Sub-category---------</option> <option value='TRNAIR'>Airport</option> <option value='TRNBUS'>Bus Terminal</option> <option value='TRNCAR'>Taxi Service</option> <option value='TRNPMP'>Petrol Pump &amp; CNG</option> <option value='TRNRAL'>Railway Station</option> <option value='TRNSEA'>Seaport</option> <option value='TRNTRO'>Tour Operators,Information Center</option> </select>";
}     
};

// END REDIRECT SECTION



// TOGGLE SEARCH BAR SECTION

	function showdirVia() {
			document.getElementById('dirViaLink').style.display = "none";
			document.getElementById('dirVia').style.display = "";
		};
		
		function showOption(obj) {
			hideOptions();
			var el = document.getElementById(obj);
			el.style.display = "";
						
			if (obj == 'directions') {			
				el.style.display = "";
				document.getElementById('tab1').className = "tabselected";				
			} else if (obj == 'maps') {			
				el.style.display = "";
				document.getElementById('tab2').className = "tabselected";
			} else if (obj == 'local') {			
				el.style.display = "";
				document.getElementById('tab3').className = "tabselected";
			} else if (obj == 'elocation') {			
				el.style.display = "";
				document.getElementById('tab4').className = "tabselected";
			}
		};		
		
		function hideOptions() {
			var el;
			el = document.getElementById('directions');
			el.style.display = "none";
			el = document.getElementById('maps');
			el.style.display = "none";
			el = document.getElementById('local');
			el.style.display = "none";
			el = document.getElementById('elocation');
			el.style.display = "none";			
			document.getElementById('tab1').className = "tabunselected";
            document.getElementById('tab2').className = "tabunselected";
            document.getElementById('tab3').className = "tabunselected";
            document.getElementById('tab4').className = "tabunselected";
		};
		
		function showOption1(obj) {
			hideOptions1();
			var el = document.getElementById(obj);
			el.style.display = "";
						
			if (obj == 'newsSection1') {			
				el.style.display = "";
				document.getElementById('newstab1').className = "newstabselected";				
			} else if (obj == 'newsSection2') {			
				el.style.display = "";
				document.getElementById('newstab2').className = "newstabselected";
			} else if (obj == 'newsSection3') {			
				el.style.display = "";
				document.getElementById('newstab3').className = "newstabselected";
			} else if (obj == 'newsSection4') {			
				el.style.display = "";
				document.getElementById('newstab4').className = "newstabselected";
			}
			
		};		
		
		function hideOptions1() {
			var el;
			el = document.getElementById('newsSection1');
			el.style.display = "none";
			el = document.getElementById('newsSection2');
			el.style.display = "none";
			el = document.getElementById('newsSection3');
			el.style.display = "none";
			el = document.getElementById('newsSection4');
			el.style.display = "none";
			document.getElementById('newstab1').className = "newstabunselected";
            document.getElementById('newstab2').className = "newstabunselected";
            document.getElementById('newstab3').className = "newstabunselected";
			document.getElementById('newstab4').className = "newstabunselected";

		};
		
		function tabTop() {
			if (document.all) {
				//alert("ie");
				document.getElementById("tab1").style.top = "49px";
				document.getElementById("tab2").style.top = "49px";
				document.getElementById("tab3").style.top = "49px";
				document.getElementById("tab4").style.top = "49px";
			}else {
				//alert("moz");
				document.getElementById("tab1").style.top = "48px";
				document.getElementById("tab2").style.top = "48px";
				document.getElementById("tab3").style.top = "48px";
				document.getElementById("tab4").style.top = "48px";
			}	
		};
		
		function tabNews() {
			if (document.all) {
				//alert("ie");
				document.getElementById("newstab1").style.top = "134px";
				document.getElementById("newstab2").style.top = "134px";
				document.getElementById("newstab3").style.top = "134px";
				document.getElementById("newstab4").style.top = "134px";
			}else {
				//alert("moz");
				document.getElementById("newstab1").style.top = "133px";
				document.getElementById("newstab2").style.top = "133px";
				document.getElementById("newstab3").style.top = "133px";
				document.getElementById("newstab4").style.top = "133px";
			}	
		};
		
		

// END TOGGLE SEARCH BAR SECTION

// GENERAL SECTION

		function MM_openBrWindow(theURL,winName,features) { //v2.0
		  window.open(theURL,winName,features);
		};
		
		function marqueeLeft() {
			document.getElementById("videoStrip").direction="left";
		};
		
		function marqueeRight() {
			document.getElementById("videoStrip").direction="right";
		};


// END GENERAL SECTION
